@ganju/utils 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +9 -0
  3. package/README.md +23 -0
  4. package/dist/apiError.d.ts +3 -0
  5. package/dist/apiError.d.ts.map +1 -0
  6. package/dist/apiError.js +36 -0
  7. package/dist/attachment.d.ts +33 -0
  8. package/dist/attachment.d.ts.map +1 -0
  9. package/dist/attachment.js +59 -0
  10. package/dist/base64.d.ts +10 -0
  11. package/dist/base64.d.ts.map +1 -0
  12. package/dist/base64.js +50 -0
  13. package/dist/channelDebounce.d.ts +26 -0
  14. package/dist/channelDebounce.d.ts.map +1 -0
  15. package/dist/channelDebounce.js +35 -0
  16. package/dist/channelNotifier.d.ts +9 -0
  17. package/dist/channelNotifier.d.ts.map +1 -0
  18. package/dist/channelNotifier.js +31 -0
  19. package/dist/chunking.d.ts +28 -0
  20. package/dist/chunking.d.ts.map +1 -0
  21. package/dist/chunking.js +97 -0
  22. package/dist/cliConstants.d.ts +9 -0
  23. package/dist/cliConstants.d.ts.map +1 -0
  24. package/dist/cliConstants.js +47 -0
  25. package/dist/coerce.d.ts +2 -0
  26. package/dist/coerce.d.ts.map +1 -0
  27. package/dist/coerce.js +13 -0
  28. package/dist/constants.d.ts +624 -0
  29. package/dist/constants.d.ts.map +1 -0
  30. package/dist/constants.js +2220 -0
  31. package/dist/crypto.d.ts +14 -0
  32. package/dist/crypto.d.ts.map +1 -0
  33. package/dist/crypto.js +93 -0
  34. package/dist/customCodeProject.d.ts +91 -0
  35. package/dist/customCodeProject.d.ts.map +1 -0
  36. package/dist/customCodeProject.js +154 -0
  37. package/dist/customCodeToken.d.ts +41 -0
  38. package/dist/customCodeToken.d.ts.map +1 -0
  39. package/dist/customCodeToken.js +115 -0
  40. package/dist/deadline.d.ts +6 -0
  41. package/dist/deadline.d.ts.map +1 -0
  42. package/dist/deadline.js +45 -0
  43. package/dist/discordSend.d.ts +25 -0
  44. package/dist/discordSend.d.ts.map +1 -0
  45. package/dist/discordSend.js +8 -0
  46. package/dist/embeddable.d.ts +2 -0
  47. package/dist/embeddable.d.ts.map +1 -0
  48. package/dist/embeddable.js +6 -0
  49. package/dist/exposedResource.d.ts +6 -0
  50. package/dist/exposedResource.d.ts.map +1 -0
  51. package/dist/exposedResource.js +18 -0
  52. package/dist/extractedDocument.d.ts +70 -0
  53. package/dist/extractedDocument.d.ts.map +1 -0
  54. package/dist/extractedDocument.js +2 -0
  55. package/dist/fetcher.d.ts +8 -0
  56. package/dist/fetcher.d.ts.map +1 -0
  57. package/dist/fetcher.js +68 -0
  58. package/dist/formatFilename.d.ts +2 -0
  59. package/dist/formatFilename.d.ts.map +1 -0
  60. package/dist/formatFilename.js +19 -0
  61. package/dist/formatRelative.d.ts +12 -0
  62. package/dist/formatRelative.d.ts.map +1 -0
  63. package/dist/formatRelative.js +28 -0
  64. package/dist/formatRelativeTime.d.ts +2 -0
  65. package/dist/formatRelativeTime.d.ts.map +1 -0
  66. package/dist/formatRelativeTime.js +49 -0
  67. package/dist/getEnv.d.ts +5 -0
  68. package/dist/getEnv.d.ts.map +1 -0
  69. package/dist/getEnv.js +11 -0
  70. package/dist/gmailSend.d.ts +24 -0
  71. package/dist/gmailSend.d.ts.map +1 -0
  72. package/dist/gmailSend.js +9 -0
  73. package/dist/index.d.ts +2839 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +155 -0
  76. package/dist/jsonSchemaToZodShape.d.ts +38 -0
  77. package/dist/jsonSchemaToZodShape.d.ts.map +1 -0
  78. package/dist/jsonSchemaToZodShape.js +117 -0
  79. package/dist/l2Normalize.d.ts +2 -0
  80. package/dist/l2Normalize.d.ts.map +1 -0
  81. package/dist/l2Normalize.js +25 -0
  82. package/dist/languageCookieDomain.d.ts +21 -0
  83. package/dist/languageCookieDomain.d.ts.map +1 -0
  84. package/dist/languageCookieDomain.js +39 -0
  85. package/dist/localizeZodIssue.d.ts +43 -0
  86. package/dist/localizeZodIssue.d.ts.map +1 -0
  87. package/dist/localizeZodIssue.js +90 -0
  88. package/dist/mailHeaders.d.ts +4 -0
  89. package/dist/mailHeaders.d.ts.map +1 -0
  90. package/dist/mailHeaders.js +11 -0
  91. package/dist/mcpProxy.d.ts +2 -0
  92. package/dist/mcpProxy.d.ts.map +1 -0
  93. package/dist/mcpProxy.js +21 -0
  94. package/dist/mimeMessage.d.ts +21 -0
  95. package/dist/mimeMessage.d.ts.map +1 -0
  96. package/dist/mimeMessage.js +58 -0
  97. package/dist/oauth.d.ts +21 -0
  98. package/dist/oauth.d.ts.map +1 -0
  99. package/dist/oauth.js +75 -0
  100. package/dist/oauthProviders.d.ts +12 -0
  101. package/dist/oauthProviders.d.ts.map +1 -0
  102. package/dist/oauthProviders.js +99 -0
  103. package/dist/outlookSend.d.ts +19 -0
  104. package/dist/outlookSend.d.ts.map +1 -0
  105. package/dist/outlookSend.js +9 -0
  106. package/dist/parseHttpError.d.ts +2 -0
  107. package/dist/parseHttpError.d.ts.map +1 -0
  108. package/dist/parseHttpError.js +23 -0
  109. package/dist/planLimitError.d.ts +18 -0
  110. package/dist/planLimitError.d.ts.map +1 -0
  111. package/dist/planLimitError.js +35 -0
  112. package/dist/processQueueBatch.d.ts +17 -0
  113. package/dist/processQueueBatch.d.ts.map +1 -0
  114. package/dist/processQueueBatch.js +32 -0
  115. package/dist/reservedToolName.d.ts +16 -0
  116. package/dist/reservedToolName.d.ts.map +1 -0
  117. package/dist/reservedToolName.js +25 -0
  118. package/dist/resourceUri.d.ts +2 -0
  119. package/dist/resourceUri.d.ts.map +1 -0
  120. package/dist/resourceUri.js +19 -0
  121. package/dist/retry.d.ts +10 -0
  122. package/dist/retry.d.ts.map +1 -0
  123. package/dist/retry.js +37 -0
  124. package/dist/sanitize.d.ts +7 -0
  125. package/dist/sanitize.d.ts.map +1 -0
  126. package/dist/sanitize.js +69 -0
  127. package/dist/schema.d.ts +2175 -0
  128. package/dist/schema.d.ts.map +1 -0
  129. package/dist/schema.js +1382 -0
  130. package/dist/sdkConstants.d.ts +15 -0
  131. package/dist/sdkConstants.d.ts.map +1 -0
  132. package/dist/sdkConstants.js +43 -0
  133. package/dist/slackSend.d.ts +38 -0
  134. package/dist/slackSend.d.ts.map +1 -0
  135. package/dist/slackSend.js +14 -0
  136. package/dist/slug.d.ts +5 -0
  137. package/dist/slug.d.ts.map +1 -0
  138. package/dist/slug.js +34 -0
  139. package/dist/slugifyTitle.d.ts +2 -0
  140. package/dist/slugifyTitle.d.ts.map +1 -0
  141. package/dist/slugifyTitle.js +11 -0
  142. package/dist/sources.d.ts +43 -0
  143. package/dist/sources.d.ts.map +1 -0
  144. package/dist/sources.js +73 -0
  145. package/dist/ssrf.d.ts +3 -0
  146. package/dist/ssrf.d.ts.map +1 -0
  147. package/dist/ssrf.js +46 -0
  148. package/dist/tallyUsageKinds.d.ts +9 -0
  149. package/dist/tallyUsageKinds.d.ts.map +1 -0
  150. package/dist/tallyUsageKinds.js +20 -0
  151. package/dist/telegramSend.d.ts +28 -0
  152. package/dist/telegramSend.d.ts.map +1 -0
  153. package/dist/telegramSend.js +9 -0
  154. package/dist/toolCatalog.d.ts +452 -0
  155. package/dist/toolCatalog.d.ts.map +1 -0
  156. package/dist/toolCatalog.js +552 -0
  157. package/dist/validateMessageVariables.d.ts +7 -0
  158. package/dist/validateMessageVariables.d.ts.map +1 -0
  159. package/dist/validateMessageVariables.js +16 -0
  160. package/dist/vendorError.d.ts +2 -0
  161. package/dist/vendorError.d.ts.map +1 -0
  162. package/dist/vendorError.js +25 -0
  163. package/dist/whatsappSend.d.ts +31 -0
  164. package/dist/whatsappSend.d.ts.map +1 -0
  165. package/dist/whatsappSend.js +11 -0
  166. package/package.json +76 -0
  167. package/src/apiError.ts +40 -0
  168. package/src/attachment.ts +97 -0
  169. package/src/base64.ts +60 -0
  170. package/src/channelDebounce.ts +76 -0
  171. package/src/channelNotifier.ts +39 -0
  172. package/src/chunking.ts +131 -0
  173. package/src/cliConstants.ts +50 -0
  174. package/src/coerce.ts +9 -0
  175. package/src/constants.ts +2542 -0
  176. package/src/crypto.ts +108 -0
  177. package/src/customCodeProject.ts +182 -0
  178. package/src/customCodeToken.ts +198 -0
  179. package/src/deadline.ts +43 -0
  180. package/src/discordSend.ts +41 -0
  181. package/src/embeddable.ts +4 -0
  182. package/src/exposedResource.ts +40 -0
  183. package/src/extractedDocument.ts +62 -0
  184. package/src/fetcher.ts +82 -0
  185. package/src/formatFilename.ts +19 -0
  186. package/src/formatRelative.ts +36 -0
  187. package/src/formatRelativeTime.ts +45 -0
  188. package/src/getEnv.ts +13 -0
  189. package/src/gmailSend.ts +34 -0
  190. package/src/index.ts +397 -0
  191. package/src/jsonSchemaToZodShape.ts +111 -0
  192. package/src/l2Normalize.ts +19 -0
  193. package/src/languageCookieDomain.ts +37 -0
  194. package/src/localizeZodIssue.ts +124 -0
  195. package/src/mailHeaders.ts +12 -0
  196. package/src/mcpProxy.ts +20 -0
  197. package/src/mimeMessage.ts +82 -0
  198. package/src/oauth.ts +103 -0
  199. package/src/oauthProviders.ts +118 -0
  200. package/src/outlookSend.ts +44 -0
  201. package/src/parseHttpError.ts +16 -0
  202. package/src/planLimitError.ts +50 -0
  203. package/src/processQueueBatch.ts +46 -0
  204. package/src/reservedToolName.ts +27 -0
  205. package/src/resourceUri.ts +17 -0
  206. package/src/retry.ts +43 -0
  207. package/src/sanitize.ts +67 -0
  208. package/src/schema.ts +1624 -0
  209. package/src/sdkConstants.ts +44 -0
  210. package/src/slackSend.ts +65 -0
  211. package/src/slug.ts +37 -0
  212. package/src/slugifyTitle.ts +8 -0
  213. package/src/sources.ts +117 -0
  214. package/src/ssrf.ts +34 -0
  215. package/src/tallyUsageKinds.ts +20 -0
  216. package/src/telegramSend.ts +39 -0
  217. package/src/toolCatalog.ts +635 -0
  218. package/src/validateMessageVariables.ts +18 -0
  219. package/src/vendorError.ts +19 -0
  220. package/src/whatsappSend.ts +47 -0
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B,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,8BAA8B,EAC9B,mBAAmB,EACnB,oBAAoB,EACpB,iCAAiC,EACjC,kBAAkB,EAClB,mBAAmB,EACnB,gCAAgC,EAChC,mBAAmB,EACnB,oBAAoB,EACpB,iCAAiC,EACjC,SAAS,EACT,SAAS,EACT,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,MAAM,EACN,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACX,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.utils = void 0;
4
+ const schema_1 = require("./schema");
5
+ const getEnv_1 = require("./getEnv");
6
+ const fetcher_1 = require("./fetcher");
7
+ const constants_1 = require("./constants");
8
+ const slug_1 = require("./slug");
9
+ const reservedToolName_1 = require("./reservedToolName");
10
+ const crypto_1 = require("./crypto");
11
+ const base64_1 = require("./base64");
12
+ const mailHeaders_1 = require("./mailHeaders");
13
+ const mimeMessage_1 = require("./mimeMessage");
14
+ const parseHttpError_1 = require("./parseHttpError");
15
+ const apiError_1 = require("./apiError");
16
+ const coerce_1 = require("./coerce");
17
+ const validateMessageVariables_1 = require("./validateMessageVariables");
18
+ const jsonSchemaToZodShape_1 = require("./jsonSchemaToZodShape");
19
+ const mcpProxy_1 = require("./mcpProxy");
20
+ const customCodeToken_1 = require("./customCodeToken");
21
+ const oauthProviders_1 = require("./oauthProviders");
22
+ const attachment_1 = require("./attachment");
23
+ const exposedResource_1 = require("./exposedResource");
24
+ const vendorError_1 = require("./vendorError");
25
+ const deadline_1 = require("./deadline");
26
+ const customCodeProject_1 = require("./customCodeProject");
27
+ const ssrf_1 = require("./ssrf");
28
+ const formatRelative_1 = require("./formatRelative");
29
+ const formatRelativeTime_1 = require("./formatRelativeTime");
30
+ const languageCookieDomain_1 = require("./languageCookieDomain");
31
+ const localizeZodIssue_1 = require("./localizeZodIssue");
32
+ const slugifyTitle_1 = require("./slugifyTitle");
33
+ const resourceUri_1 = require("./resourceUri");
34
+ const toolCatalog_1 = require("./toolCatalog");
35
+ const tallyUsageKinds_1 = require("./tallyUsageKinds");
36
+ const formatFilename_1 = require("./formatFilename");
37
+ const sanitize_1 = require("./sanitize");
38
+ const chunking_1 = require("./chunking");
39
+ const embeddable_1 = require("./embeddable");
40
+ const l2Normalize_1 = require("./l2Normalize");
41
+ const retry_1 = require("./retry");
42
+ const processQueueBatch_1 = require("./processQueueBatch");
43
+ const channelNotifier_1 = require("./channelNotifier");
44
+ const channelDebounce_1 = require("./channelDebounce");
45
+ const sources_1 = require("./sources");
46
+ const oauth_1 = require("./oauth");
47
+ const planLimitError_1 = require("./planLimitError");
48
+ exports.utils = {
49
+ Schema: schema_1.Schema,
50
+ getEnv: getEnv_1.getEnv,
51
+ fetcher: fetcher_1.fetcher,
52
+ constants: constants_1.constants,
53
+ generateRandomSlug: slug_1.generateRandomSlug,
54
+ generateRandomToken: slug_1.generateRandomToken,
55
+ isReservedSlug: slug_1.isReservedSlug,
56
+ isValidSlugFormat: slug_1.isValidSlugFormat,
57
+ isReservedToolName: reservedToolName_1.isReservedToolName,
58
+ encryptString: crypto_1.encryptString,
59
+ decryptString: crypto_1.decryptString,
60
+ getCredentialEncryptionKey: crypto_1.getCredentialEncryptionKey,
61
+ sha256Hex: crypto_1.sha256Hex,
62
+ sha256Base64Url: crypto_1.sha256Base64Url,
63
+ hmacSha256Hex: crypto_1.hmacSha256Hex,
64
+ timingSafeEqual: crypto_1.timingSafeEqual,
65
+ bytesToBase64: base64_1.bytesToBase64,
66
+ base64ToBytes: base64_1.base64ToBytes,
67
+ hexToBytes: base64_1.hexToBytes,
68
+ utf8ToBase64: base64_1.utf8ToBase64,
69
+ base64ToUtf8: base64_1.base64ToUtf8,
70
+ toBase64Url: base64_1.toBase64Url,
71
+ fromBase64Url: base64_1.fromBase64Url,
72
+ utf8ToBase64Url: base64_1.utf8ToBase64Url,
73
+ base64UrlToUtf8: base64_1.base64UrlToUtf8,
74
+ sanitizeMailHeader: mailHeaders_1.sanitizeMailHeader,
75
+ encodeRfc2047: mailHeaders_1.encodeRfc2047,
76
+ formatMailHeader: mailHeaders_1.formatMailHeader,
77
+ buildMimeMessage: mimeMessage_1.buildMimeMessage,
78
+ sanitizeFilename: mimeMessage_1.sanitizeFilename,
79
+ formatFilenameHeader: mimeMessage_1.formatFilenameHeader,
80
+ chunkBase64: mimeMessage_1.chunkBase64,
81
+ parseHttpErrorMessage: parseHttpError_1.parseHttpErrorMessage,
82
+ isApiError: apiError_1.isApiError,
83
+ getApiErrorMessage: apiError_1.getApiErrorMessage,
84
+ toStringArray: coerce_1.toStringArray,
85
+ jsonSchemaToZodShape: jsonSchemaToZodShape_1.jsonSchemaToZodShape,
86
+ validateAgainstJsonSchema: jsonSchemaToZodShape_1.validateAgainstJsonSchema,
87
+ buildProxyToolName: mcpProxy_1.buildProxyToolName,
88
+ mintCustomCodeToken: customCodeToken_1.mintCustomCodeToken,
89
+ verifyCustomCodeToken: customCodeToken_1.verifyCustomCodeToken,
90
+ customCodeScriptName: customCodeToken_1.customCodeScriptName,
91
+ customCodePreviewScriptName: customCodeToken_1.customCodePreviewScriptName,
92
+ oauthProviders: oauthProviders_1.oauthProviders,
93
+ resolveAttachment: attachment_1.resolveAttachment,
94
+ isExposedResource: exposedResource_1.isExposedResource,
95
+ describeVendorError: vendorError_1.describeVendorError,
96
+ withDeadline: deadline_1.withDeadline,
97
+ isDeadlineError: deadline_1.isDeadlineError,
98
+ CUSTOM_CODE_PROJECT_MARKER: customCodeProject_1.CUSTOM_CODE_PROJECT_MARKER,
99
+ encodeProject: customCodeProject_1.encodeProject,
100
+ decodeProject: customCodeProject_1.decodeProject,
101
+ validateProjectFiles: customCodeProject_1.validateProjectFiles,
102
+ validateProjectPath: customCodeProject_1.validateProjectPath,
103
+ projectPathIssue: customCodeProject_1.projectPathIssue,
104
+ ipv4InPrivateRange: ssrf_1.ipv4InPrivateRange,
105
+ isBlockedHost: ssrf_1.isBlockedHost,
106
+ validateMessageVariables: validateMessageVariables_1.validateMessageVariables,
107
+ formatRelative: formatRelative_1.formatRelative,
108
+ formatRelativeTime: formatRelativeTime_1.formatRelativeTime,
109
+ languageCookieDomain: languageCookieDomain_1.languageCookieDomain,
110
+ localizeZodIssue: localizeZodIssue_1.localizeZodIssue,
111
+ languageFromHeader: localizeZodIssue_1.languageFromHeader,
112
+ slugifyTitle: slugifyTitle_1.slugifyTitle,
113
+ resourceUriFromTitle: resourceUri_1.resourceUriFromTitle,
114
+ TOOL_CATALOG: toolCatalog_1.TOOL_CATALOG,
115
+ TOOL_KEYS: toolCatalog_1.TOOL_KEYS,
116
+ describeCatalogTool: toolCatalog_1.describeCatalogTool,
117
+ findCatalogGroup: toolCatalog_1.findCatalogGroup,
118
+ findCatalogTool: toolCatalog_1.findCatalogTool,
119
+ isToolKey: toolCatalog_1.isToolKey,
120
+ tallyUsageKinds: tallyUsageKinds_1.tallyUsageKinds,
121
+ formatFilename: formatFilename_1.formatFilename,
122
+ decodeEntities: sanitize_1.decodeEntities,
123
+ escapeHtml: sanitize_1.escapeHtml,
124
+ parseOpenXmlProps: sanitize_1.parseOpenXmlProps,
125
+ stripBase64Images: sanitize_1.stripBase64Images,
126
+ sanitizeMetadataString: sanitize_1.sanitizeMetadataString,
127
+ serializeMetadataValue: sanitize_1.serializeMetadataValue,
128
+ chunkText: chunking_1.chunkText,
129
+ splitRecursive: chunking_1.splitRecursive,
130
+ buildHeader: chunking_1.buildHeader,
131
+ prepareChunks: chunking_1.prepareChunks,
132
+ isEmbeddableMimeType: embeddable_1.isEmbeddableMimeType,
133
+ l2Normalize: l2Normalize_1.l2Normalize,
134
+ sleep: retry_1.sleep,
135
+ isRateLimitError: retry_1.isRateLimitError,
136
+ withRateLimitRetry: retry_1.withRateLimitRetry,
137
+ processQueueBatch: processQueueBatch_1.processQueueBatch,
138
+ getToolStatusMessage: channelNotifier_1.getToolStatusMessage,
139
+ resolveDebounceMs: channelDebounce_1.resolveDebounceMs,
140
+ channelBufferKey: channelDebounce_1.channelBufferKey,
141
+ joinBufferedMessages: channelDebounce_1.joinBufferedMessages,
142
+ isResourceSourceEnabled: sources_1.isResourceSourceEnabled,
143
+ isDownloadableSource: sources_1.isDownloadableSource,
144
+ safeHostname: sources_1.safeHostname,
145
+ buildResourceDownloadUrl: sources_1.buildResourceDownloadUrl,
146
+ formatSourcesAsMarkdown: sources_1.formatSourcesAsMarkdown,
147
+ formatSourcesAsButtons: sources_1.formatSourcesAsButtons,
148
+ refreshOAuthToken: oauth_1.refreshOAuthToken,
149
+ OAuthReauthRequiredError: oauth_1.OAuthReauthRequiredError,
150
+ buildReauthMetadata: oauth_1.buildReauthMetadata,
151
+ clearReauthMetadata: oauth_1.clearReauthMetadata,
152
+ isCredentialNeedingReauth: oauth_1.isCredentialNeedingReauth,
153
+ PlanLimitError: planLimitError_1.PlanLimitError,
154
+ isPlanLimitError: planLimitError_1.isPlanLimitError
155
+ };
@@ -0,0 +1,38 @@
1
+ import * as z from 'zod';
2
+ export type JsonSchemaProperty = {
3
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
4
+ description?: string;
5
+ minimum?: number;
6
+ maximum?: number;
7
+ minLength?: number;
8
+ maxLength?: number;
9
+ pattern?: string;
10
+ enum?: string[];
11
+ items?: JsonSchemaProperty;
12
+ };
13
+ export type JsonSchema = {
14
+ type: 'object';
15
+ properties?: Record<string, JsonSchemaProperty>;
16
+ required?: string[];
17
+ };
18
+ export declare const jsonSchemaToZodShape: (schema: JsonSchema) => Record<string, z.ZodTypeAny>;
19
+ export interface SchemaViolation {
20
+ path: string;
21
+ message: string;
22
+ }
23
+ /**
24
+ * Check a value against a declared JSON schema, returning the violations.
25
+ *
26
+ * The same compiler the MCP boot loop registers tools with, pointed at a value
27
+ * instead of at a tool definition — so what the dashboard's Test panel calls
28
+ * invalid is exactly what an MCP client would have refused to send. Written here
29
+ * rather than in apps/api because zod lives here, and a second copy of this
30
+ * would be a second opinion about what "valid" means.
31
+ *
32
+ * Unknown keys are allowed through: a JSON Schema without
33
+ * `additionalProperties: false` does not forbid them, and refusing an extra
34
+ * field on a test input that a real client would have passed along would make
35
+ * the panel lie.
36
+ */
37
+ export declare const validateAgainstJsonSchema: (schema: JsonSchema, value: unknown) => SchemaViolation[];
38
+ //# sourceMappingURL=jsonSchemaToZodShape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonSchemaToZodShape.d.ts","sourceRoot":"","sources":["../src/jsonSchemaToZodShape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA8CF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,UAAU,KACjB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAY7B,CAAC;AAEF,MAAM,WAAW,eAAe;IAE9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GACpC,QAAQ,UAAU,EAClB,OAAO,OAAO,KACb,eAAe,EAOjB,CAAC"}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.validateAgainstJsonSchema = exports.jsonSchemaToZodShape = void 0;
37
+ const z = __importStar(require("zod"));
38
+ const propertyToZod = (prop) => {
39
+ let field;
40
+ switch (prop.type) {
41
+ case 'string': {
42
+ if (prop.enum) {
43
+ field = z.enum(prop.enum);
44
+ }
45
+ else {
46
+ let str = z.string();
47
+ if (prop.minLength !== undefined)
48
+ str = str.min(prop.minLength);
49
+ if (prop.maxLength !== undefined)
50
+ str = str.max(prop.maxLength);
51
+ if (prop.pattern !== undefined)
52
+ str = str.regex(new RegExp(prop.pattern));
53
+ field = str;
54
+ }
55
+ break;
56
+ }
57
+ case 'number': {
58
+ let num = z.number();
59
+ if (prop.minimum !== undefined)
60
+ num = num.min(prop.minimum);
61
+ if (prop.maximum !== undefined)
62
+ num = num.max(prop.maximum);
63
+ field = num;
64
+ break;
65
+ }
66
+ case 'boolean':
67
+ field = z.boolean();
68
+ break;
69
+ case 'array':
70
+ field = z.array(prop.items ? propertyToZod(prop.items) : z.any());
71
+ break;
72
+ case 'object':
73
+ field = z.record(z.string(), z.any());
74
+ break;
75
+ default:
76
+ field = z.any();
77
+ }
78
+ if (prop.description) {
79
+ field = field.describe(prop.description);
80
+ }
81
+ return field;
82
+ };
83
+ const jsonSchemaToZodShape = (schema) => {
84
+ const properties = schema.properties ?? {};
85
+ const required = schema.required ?? [];
86
+ const shape = {};
87
+ for (const [key, prop] of Object.entries(properties)) {
88
+ const field = propertyToZod(prop);
89
+ shape[key] = required.includes(key) ? field : field.optional();
90
+ }
91
+ return shape;
92
+ };
93
+ exports.jsonSchemaToZodShape = jsonSchemaToZodShape;
94
+ /**
95
+ * Check a value against a declared JSON schema, returning the violations.
96
+ *
97
+ * The same compiler the MCP boot loop registers tools with, pointed at a value
98
+ * instead of at a tool definition — so what the dashboard's Test panel calls
99
+ * invalid is exactly what an MCP client would have refused to send. Written here
100
+ * rather than in apps/api because zod lives here, and a second copy of this
101
+ * would be a second opinion about what "valid" means.
102
+ *
103
+ * Unknown keys are allowed through: a JSON Schema without
104
+ * `additionalProperties: false` does not forbid them, and refusing an extra
105
+ * field on a test input that a real client would have passed along would make
106
+ * the panel lie.
107
+ */
108
+ const validateAgainstJsonSchema = (schema, value) => {
109
+ const result = z.object((0, exports.jsonSchemaToZodShape)(schema)).safeParse(value ?? {});
110
+ if (result.success)
111
+ return [];
112
+ return result.error.issues.map(issue => ({
113
+ path: issue.path.join('.'),
114
+ message: issue.message
115
+ }));
116
+ };
117
+ exports.validateAgainstJsonSchema = validateAgainstJsonSchema;
@@ -0,0 +1,2 @@
1
+ export declare const l2Normalize: (values: number[]) => number[];
2
+ //# sourceMappingURL=l2Normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"l2Normalize.d.ts","sourceRoot":"","sources":["../src/l2Normalize.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,KAAG,MAAM,EAMpD,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.l2Normalize = void 0;
4
+ // Scale a vector to unit length.
5
+ //
6
+ // Needed because `gemini-embedding-001` only returns a normalised vector at its
7
+ // full 3072 dimensions. Ask for fewer via `outputDimensionality` — as we do, to
8
+ // halve storage — and the values come back UNNORMALISED, because truncating a
9
+ // unit vector leaves it shorter than 1. Cosine distance in pgvector assumes
10
+ // nothing about magnitude, but our stored vectors and query vectors have to be
11
+ // treated identically, and an unnormalised mix silently skews ranking rather
12
+ // than failing. So both the ingest path and the query path normalise here.
13
+ //
14
+ // Returns the input unchanged when the magnitude is zero, which would otherwise
15
+ // divide by zero and produce NaNs that poison the whole index.
16
+ const l2Normalize = (values) => {
17
+ let sum = 0;
18
+ for (const v of values)
19
+ sum += v * v;
20
+ const magnitude = Math.sqrt(sum);
21
+ if (!magnitude || !Number.isFinite(magnitude))
22
+ return values;
23
+ return values.map(v => v / magnitude);
24
+ };
25
+ exports.l2Normalize = l2Normalize;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Cookie `Domain` for the remembered language, derived from the host serving
3
+ * the request.
4
+ *
5
+ * `ganju.ai` and `app.ganju.ai` are two hosts, so a host-only cookie set by one
6
+ * is invisible to the other — someone who explicitly picks English on the
7
+ * marketing site would sign in and be handed Spanish again by the country
8
+ * lookup, which defeats the point of remembering the choice. Scoping the cookie
9
+ * to `.ganju.ai` makes one click cover both.
10
+ *
11
+ * Derived from the host rather than configured, because the two surfaces deploy
12
+ * separately and a value set in one place would silently rot in the other. The
13
+ * cost is the assumption below.
14
+ *
15
+ * **Assumes a single-label public suffix** — `ganju.ai`, `vocesqueabrazan.com`.
16
+ * A deploy under a multi-part suffix (`example.co.uk`) would compute `.co.uk`,
17
+ * which browsers reject, and the cookie would quietly go nowhere. Add that
18
+ * suffix here if it ever happens.
19
+ */
20
+ export declare const languageCookieDomain: (hostname: string) => string | undefined;
21
+ //# sourceMappingURL=languageCookieDomain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languageCookieDomain.d.ts","sourceRoot":"","sources":["../src/languageCookieDomain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,SAiBhE,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.languageCookieDomain = void 0;
4
+ /**
5
+ * Cookie `Domain` for the remembered language, derived from the host serving
6
+ * the request.
7
+ *
8
+ * `ganju.ai` and `app.ganju.ai` are two hosts, so a host-only cookie set by one
9
+ * is invisible to the other — someone who explicitly picks English on the
10
+ * marketing site would sign in and be handed Spanish again by the country
11
+ * lookup, which defeats the point of remembering the choice. Scoping the cookie
12
+ * to `.ganju.ai` makes one click cover both.
13
+ *
14
+ * Derived from the host rather than configured, because the two surfaces deploy
15
+ * separately and a value set in one place would silently rot in the other. The
16
+ * cost is the assumption below.
17
+ *
18
+ * **Assumes a single-label public suffix** — `ganju.ai`, `vocesqueabrazan.com`.
19
+ * A deploy under a multi-part suffix (`example.co.uk`) would compute `.co.uk`,
20
+ * which browsers reject, and the cookie would quietly go nowhere. Add that
21
+ * suffix here if it ever happens.
22
+ */
23
+ const languageCookieDomain = (hostname) => {
24
+ const labels = hostname.split('.');
25
+ // `localhost`, and anything else with nothing to share with.
26
+ if (labels.length < 2)
27
+ return undefined;
28
+ // A bare IP has no domain to scope to.
29
+ if (/^\d+$/.test(labels[labels.length - 1]))
30
+ return undefined;
31
+ const apex = labels.slice(-2).join('.');
32
+ // Cloudflare's preview hosts are a public suffix: every Pages project on the
33
+ // planet shares them, so browsers refuse a cookie scoped there. Falling back
34
+ // to host-only keeps previews working on their own.
35
+ if (apex === 'pages.dev' || apex === 'workers.dev')
36
+ return undefined;
37
+ return `.${apex}`;
38
+ };
39
+ exports.languageCookieDomain = languageCookieDomain;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Re-render a Zod validation issue in the reader's language.
3
+ *
4
+ * Zod already ships a complete Spanish locale, so all ~305 built-in validators
5
+ * in `schema.ts` are covered without hand-translating anything. The trick is
6
+ * *where* to apply it. There are ~100 parse call sites across the three
7
+ * services; threading a per-parse error map through all of them is a hundred
8
+ * chances to miss one. Instead this runs once, in `handleError`'s ZodError
9
+ * branch, on the way out.
10
+ *
11
+ * That works because a Zod 4 issue keeps its structured fields — `code`,
12
+ * `origin`, `minimum`, `divisor`, `keys` — alongside the rendered `message`,
13
+ * and a locale error map is exactly a function from that structured issue to a
14
+ * string. So the English message Zod produced at parse time can be thrown away
15
+ * and rebuilt in Spanish at catch time.
16
+ *
17
+ * **Do not reach for `z.config({ localeError })` instead.** It mutates a
18
+ * module-level global (`zod/src/v4/core/config.ts`), and a Workers isolate
19
+ * serves concurrent requests in different languages — one request would set the
20
+ * locale for whatever else happened to be in flight. Nothing here holds state.
21
+ *
22
+ * What lands in `error_log` is untouched: `handleError` persists `err.message`,
23
+ * which is still Zod's own English dump from parse time. Nothing about
24
+ * persistence, and no migration, is involved.
25
+ */
26
+ /** Minimal shape of the issue we need; Zod's own type lives in `zod`. */
27
+ export interface ZodIssueLike {
28
+ code?: string;
29
+ message: string;
30
+ path?: PropertyKey[];
31
+ }
32
+ /**
33
+ * Narrow an `Accept-Language` header to a language we ship.
34
+ *
35
+ * `fetcher` sends the app's own locale rather than the browser's list, so this
36
+ * is normally a bare `en` or `es` — but the header is public, and a browser
37
+ * hitting the API directly will send the full `es-CO,es;q=0.9,en;q=0.8` form.
38
+ * Take the first tag and match on its primary subtag.
39
+ */
40
+ export declare const languageFromHeader: (header?: string | null) => string;
41
+ /** The issue's message in `language`, or its original English. */
42
+ export declare const localizeZodIssue: (issue: ZodIssueLike, language: string) => string;
43
+ //# sourceMappingURL=localizeZodIssue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localizeZodIssue.d.ts","sourceRoot":"","sources":["../src/localizeZodIssue.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,yEAAyE;AACzE,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;CACtB;AAkDD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,GAAG,IAAI,KAAG,MAK3D,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,GAC3B,OAAO,YAAY,EACnB,UAAU,MAAM,KACf,MAmBF,CAAC"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.localizeZodIssue = exports.languageFromHeader = void 0;
7
+ const es_js_1 = __importDefault(require("zod/v4/locales/es.js"));
8
+ const constants_1 = require("./constants");
9
+ /**
10
+ * Messages we wrote ourselves. Zod renders a custom `message:` verbatim, so the
11
+ * locale map never sees them — they arrive here as the exact English string,
12
+ * which is what these keys are. Keying on our own text rather than on a code
13
+ * keeps `schema.ts` free of translation concerns, and keeps the English in
14
+ * `error_log` identical to what it has always been.
15
+ */
16
+ const CUSTOM_MESSAGES = {
17
+ 'This title is reserved as a bot command': {
18
+ es: 'Este título está reservado como comando del bot'
19
+ },
20
+ 'Enter a valid email address': {
21
+ es: 'Escribe un correo electrónico válido'
22
+ },
23
+ 'Unsupported mime type': {
24
+ es: 'Tipo de archivo no admitido'
25
+ },
26
+ 'Slug is reserved': {
27
+ es: 'Ese slug está reservado'
28
+ },
29
+ [constants_1.constants.RESERVED_TOOL_NAME_MESSAGE]: {
30
+ es: 'Nombre de herramienta no válido — reservado por la plataforma'
31
+ },
32
+ [constants_1.constants.CUSTOM_CODE_UNKNOWN_CONNECTION_MESSAGE]: {
33
+ es: 'Conexión no válida — no existe un proveedor gestionado con ese nombre'
34
+ },
35
+ [constants_1.constants.OUTPUT_SCHEMA_NOT_OBJECT_MESSAGE]: {
36
+ es: 'Esquema de salida no válido — debe describir un objeto'
37
+ },
38
+ [constants_1.constants.CUSTOM_CODE_RESOURCE_PAYLOAD_MESSAGE]: {
39
+ es: 'Envía exactamente uno de content (texto) o bytes (base64)'
40
+ },
41
+ [constants_1.constants.CUSTOM_CODE_RESOURCE_TEXT_TOO_LARGE_MESSAGE]: {
42
+ es: `El contenido en línea supera el límite de ${constants_1.constants.CUSTOM_CODE_MAX_RESOURCE_TEXT_BYTES / (1024 * 1024)}MB`
43
+ },
44
+ [constants_1.constants.CUSTOM_CODE_RESOURCE_FILE_TOO_LARGE_MESSAGE]: {
45
+ es: `Los bytes del archivo superan el límite de ${constants_1.constants.CUSTOM_CODE_MAX_RESOURCE_FILE_BYTES / (1024 * 1024)}MB`
46
+ }
47
+ };
48
+ // Built once. `esLocale()` allocates its dictionaries on every call, and this
49
+ // runs per issue, per failed request.
50
+ const LOCALE_ERRORS = {
51
+ [constants_1.constants.LANGUAGE_ES]: (0, es_js_1.default)().localeError
52
+ };
53
+ /**
54
+ * Narrow an `Accept-Language` header to a language we ship.
55
+ *
56
+ * `fetcher` sends the app's own locale rather than the browser's list, so this
57
+ * is normally a bare `en` or `es` — but the header is public, and a browser
58
+ * hitting the API directly will send the full `es-CO,es;q=0.9,en;q=0.8` form.
59
+ * Take the first tag and match on its primary subtag.
60
+ */
61
+ const languageFromHeader = (header) => {
62
+ const tag = header?.split(',')[0]?.trim().toLowerCase() ?? '';
63
+ return tag.startsWith(constants_1.constants.LANGUAGE_ES)
64
+ ? constants_1.constants.LANGUAGE_ES
65
+ : constants_1.constants.LANGUAGE_EN;
66
+ };
67
+ exports.languageFromHeader = languageFromHeader;
68
+ /** The issue's message in `language`, or its original English. */
69
+ const localizeZodIssue = (issue, language) => {
70
+ if (language === constants_1.constants.LANGUAGE_EN)
71
+ return issue.message;
72
+ const custom = CUSTOM_MESSAGES[issue.message]?.[language];
73
+ if (custom)
74
+ return custom;
75
+ const localeError = LOCALE_ERRORS[language];
76
+ if (!localeError)
77
+ return issue.message;
78
+ try {
79
+ const rendered = localeError(issue);
80
+ const message = typeof rendered === 'string' ? rendered : rendered?.message;
81
+ // A locale map may decline an issue it does not recognise; English is a
82
+ // better answer than an empty string.
83
+ return message || issue.message;
84
+ }
85
+ catch {
86
+ // Never let a formatting failure turn a 400 into a 500.
87
+ return issue.message;
88
+ }
89
+ };
90
+ exports.localizeZodIssue = localizeZodIssue;
@@ -0,0 +1,4 @@
1
+ export declare const sanitizeMailHeader: (value: string) => string;
2
+ export declare const encodeRfc2047: (value: string) => string;
3
+ export declare const formatMailHeader: (value: string) => string;
4
+ //# sourceMappingURL=mailHeaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mailHeaders.d.ts","sourceRoot":"","sources":["../src/mailHeaders.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,MACZ,CAAC;AAExC,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MACyB,CAAC;AAExE,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MACP,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatMailHeader = exports.encodeRfc2047 = exports.sanitizeMailHeader = void 0;
4
+ const base64_1 = require("./base64");
5
+ const ASCII_ONLY = /^[\x00-\x7F]*$/;
6
+ const sanitizeMailHeader = (value) => value.replace(/[\r\n]+/g, ' ').trim();
7
+ exports.sanitizeMailHeader = sanitizeMailHeader;
8
+ const encodeRfc2047 = (value) => ASCII_ONLY.test(value) ? value : `=?UTF-8?B?${(0, base64_1.utf8ToBase64)(value)}?=`;
9
+ exports.encodeRfc2047 = encodeRfc2047;
10
+ const formatMailHeader = (value) => (0, exports.encodeRfc2047)((0, exports.sanitizeMailHeader)(value));
11
+ exports.formatMailHeader = formatMailHeader;
@@ -0,0 +1,2 @@
1
+ export declare const buildProxyToolName: (prefix: string, remoteName: string) => string | null;
2
+ //# sourceMappingURL=mcpProxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpProxy.d.ts","sourceRoot":"","sources":["../src/mcpProxy.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,MAAM,EACd,YAAY,MAAM,KACjB,MAAM,GAAG,IAKX,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildProxyToolName = void 0;
4
+ const constants_1 = require("./constants");
5
+ // Remote MCP tool keys are untrusted (the remote chooses them). Only allow the
6
+ // charset MCP clients accept for tool names so the composed local name can't
7
+ // break registration or downstream API calls.
8
+ const REMOTE_TOOL_NAME_RE = /^[a-zA-Z0-9_-]+$/;
9
+ // Compose the local MCP tool name for a proxied remote tool (`<prefix><sep><key>`),
10
+ // or return null when the remote key can't be safely surfaced — bad charset, or
11
+ // the composed name exceeds the tool-name length limit clients enforce. Callers
12
+ // skip-and-log nulls rather than registering an unusable tool.
13
+ const buildProxyToolName = (prefix, remoteName) => {
14
+ if (!remoteName || !REMOTE_TOOL_NAME_RE.test(remoteName))
15
+ return null;
16
+ const name = `${prefix}${constants_1.constants.MCP_PROXY_TOOL_NAME_SEP}${remoteName}`;
17
+ if (name.length > constants_1.constants.MCP_PROXY_TOOL_NAME_MAX)
18
+ return null;
19
+ return name;
20
+ };
21
+ exports.buildProxyToolName = buildProxyToolName;
@@ -0,0 +1,21 @@
1
+ export interface MimeAttachment {
2
+ filename: string;
3
+ mimeType: string;
4
+ base64: string;
5
+ }
6
+ export interface MimeMessageInput {
7
+ to: string;
8
+ subject: string;
9
+ body: string;
10
+ cc?: string;
11
+ bcc?: string;
12
+ inReplyTo?: string;
13
+ references?: string;
14
+ contentType?: 'text/html' | 'text/plain';
15
+ attachments?: MimeAttachment[];
16
+ }
17
+ export declare const sanitizeFilename: (name: string) => string;
18
+ export declare const formatFilenameHeader: (name: string) => string;
19
+ export declare const chunkBase64: (b64: string) => string;
20
+ export declare const buildMimeMessage: (input: MimeMessageInput) => string;
21
+ //# sourceMappingURL=mimeMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mimeMessage.d.ts","sourceRoot":"","sources":["../src/mimeMessage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;IACzC,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;CAChC;AAED,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAG/C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,MAMnD,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MACP,CAAC;AAEpC,eAAO,MAAM,gBAAgB,GAAI,OAAO,gBAAgB,KAAG,MA6C1D,CAAC"}