@5ss/ai-tools 2.11.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.
- package/CHANGELOG.md +112 -0
- package/LICENSE +21 -0
- package/README.md +221 -0
- package/dist/ai-sdk/index.d.ts +15 -0
- package/dist/ai-sdk/index.d.ts.map +1 -0
- package/dist/ai-sdk/index.js +24 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/artifact-D064mHfK.js +44 -0
- package/dist/artifact-D064mHfK.js.map +1 -0
- package/dist/artifacts-O8g-40Pw.js +404 -0
- package/dist/artifacts-O8g-40Pw.js.map +1 -0
- package/dist/aws-json-CecFqzqX.js +23 -0
- package/dist/aws-json-CecFqzqX.js.map +1 -0
- package/dist/aws-service-msttbPrz.js +58 -0
- package/dist/aws-service-msttbPrz.js.map +1 -0
- package/dist/batch-BMM5dXqL.d.ts +22 -0
- package/dist/batch-BMM5dXqL.d.ts.map +1 -0
- package/dist/batch-Co1ujeAW.js +67 -0
- package/dist/batch-Co1ujeAW.js.map +1 -0
- package/dist/bedrock-agentcore-browser-a_qOs-NR.js +182 -0
- package/dist/bedrock-agentcore-browser-a_qOs-NR.js.map +1 -0
- package/dist/bedrock-agentcore-code-interpreter-MWK-8RhA.js +357 -0
- package/dist/bedrock-agentcore-code-interpreter-MWK-8RhA.js.map +1 -0
- package/dist/bytes-BxpimpQx.js +45 -0
- package/dist/bytes-BxpimpQx.js.map +1 -0
- package/dist/client-CCKGsTeI.js +743 -0
- package/dist/client-CCKGsTeI.js.map +1 -0
- package/dist/cloudflare/index.d.ts +37 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +41 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/cloudflare-browser-B6Yolpin.js +428 -0
- package/dist/cloudflare-browser-B6Yolpin.js.map +1 -0
- package/dist/cloudflare-email-Dy0KHeDf.js +197 -0
- package/dist/cloudflare-email-Dy0KHeDf.js.map +1 -0
- package/dist/cloudflare-sandbox-Dp_uNaqW.js +982 -0
- package/dist/cloudflare-sandbox-Dp_uNaqW.js.map +1 -0
- package/dist/content-type-CORxaxcv.js +49 -0
- package/dist/content-type-CORxaxcv.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +204 -0
- package/dist/core/index.js.map +1 -0
- package/dist/define-CvpJ_pNP.js +115 -0
- package/dist/define-CvpJ_pNP.js.map +1 -0
- package/dist/errors-DoSpNHvs.js +20 -0
- package/dist/errors-DoSpNHvs.js.map +1 -0
- package/dist/errors-aKhko9T1.d.ts +18 -0
- package/dist/errors-aKhko9T1.d.ts.map +1 -0
- package/dist/eventbridge-scheduler-Bh6GqZY2.js +349 -0
- package/dist/eventbridge-scheduler-Bh6GqZY2.js.map +1 -0
- package/dist/framework-context-DVIIY8ZO.js +24 -0
- package/dist/framework-context-DVIIY8ZO.js.map +1 -0
- package/dist/gotenberg-NuJjxyln.js +291 -0
- package/dist/gotenberg-NuJjxyln.js.map +1 -0
- package/dist/http/index.d.ts +47 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +3 -0
- package/dist/http-service-DDNCO1s4.js +254 -0
- package/dist/http-service-DDNCO1s4.js.map +1 -0
- package/dist/http-service-T7E5UjP8.d.ts +80 -0
- package/dist/http-service-T7E5UjP8.d.ts.map +1 -0
- package/dist/imessage-BSAFOI8Z.js +154 -0
- package/dist/imessage-BSAFOI8Z.js.map +1 -0
- package/dist/index-BU4gmYO8.d.ts +254 -0
- package/dist/index-BU4gmYO8.d.ts.map +1 -0
- package/dist/index-CCivzmxO.d.ts +188 -0
- package/dist/index-CCivzmxO.d.ts.map +1 -0
- package/dist/index-CLmTrcu5.d.ts +22 -0
- package/dist/index-CLmTrcu5.d.ts.map +1 -0
- package/dist/index-CZX5OeOF.d.ts +235 -0
- package/dist/index-CZX5OeOF.d.ts.map +1 -0
- package/dist/index-CdFmEfZO.d.ts +359 -0
- package/dist/index-CdFmEfZO.d.ts.map +1 -0
- package/dist/index-Cuh6eMWc.d.ts +285 -0
- package/dist/index-Cuh6eMWc.d.ts.map +1 -0
- package/dist/index-DuOGj7vc.d.ts +107 -0
- package/dist/index-DuOGj7vc.d.ts.map +1 -0
- package/dist/index-ccZ1XOHw.d.ts +69 -0
- package/dist/index-ccZ1XOHw.d.ts.map +1 -0
- package/dist/index-n8JTpNf1.d.ts +247 -0
- package/dist/index-n8JTpNf1.d.ts.map +1 -0
- package/dist/index-pwW1OsOx.d.ts +134 -0
- package/dist/index-pwW1OsOx.d.ts.map +1 -0
- package/dist/index-zK1ZwS4m.d.ts +347 -0
- package/dist/index-zK1ZwS4m.d.ts.map +1 -0
- package/dist/limits-hjrO8zUG.js +80 -0
- package/dist/limits-hjrO8zUG.js.map +1 -0
- package/dist/mastra/index.d.ts +14 -0
- package/dist/mastra/index.d.ts.map +1 -0
- package/dist/mastra/index.js +26 -0
- package/dist/mastra/index.js.map +1 -0
- package/dist/mastra-vector-Dhc6XZ8l.js +234 -0
- package/dist/mastra-vector-Dhc6XZ8l.js.map +1 -0
- package/dist/mcp/index.d.ts +80 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +97 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/modules/artifacts/index.d.ts +337 -0
- package/dist/modules/artifacts/index.d.ts.map +1 -0
- package/dist/modules/artifacts/index.js +348 -0
- package/dist/modules/artifacts/index.js.map +1 -0
- package/dist/modules/browser/index.d.ts +516 -0
- package/dist/modules/browser/index.d.ts.map +1 -0
- package/dist/modules/browser/index.js +475 -0
- package/dist/modules/browser/index.js.map +1 -0
- package/dist/modules/calendar/index.d.ts +93 -0
- package/dist/modules/calendar/index.d.ts.map +1 -0
- package/dist/modules/calendar/index.js +131 -0
- package/dist/modules/calendar/index.js.map +1 -0
- package/dist/modules/code-sandbox/index.d.ts +317 -0
- package/dist/modules/code-sandbox/index.d.ts.map +1 -0
- package/dist/modules/code-sandbox/index.js +537 -0
- package/dist/modules/code-sandbox/index.js.map +1 -0
- package/dist/modules/content-type/index.d.ts +22 -0
- package/dist/modules/content-type/index.d.ts.map +1 -0
- package/dist/modules/content-type/index.js +66 -0
- package/dist/modules/content-type/index.js.map +1 -0
- package/dist/modules/crypto/index.d.ts +115 -0
- package/dist/modules/crypto/index.d.ts.map +1 -0
- package/dist/modules/crypto/index.js +139 -0
- package/dist/modules/crypto/index.js.map +1 -0
- package/dist/modules/document/index.d.ts +575 -0
- package/dist/modules/document/index.d.ts.map +1 -0
- package/dist/modules/document/index.js +444 -0
- package/dist/modules/document/index.js.map +1 -0
- package/dist/modules/document-extract/index.d.ts +438 -0
- package/dist/modules/document-extract/index.d.ts.map +1 -0
- package/dist/modules/document-extract/index.js +127 -0
- package/dist/modules/document-extract/index.js.map +1 -0
- package/dist/modules/document-render/index.d.ts +336 -0
- package/dist/modules/document-render/index.d.ts.map +1 -0
- package/dist/modules/document-render/index.js +155 -0
- package/dist/modules/document-render/index.js.map +1 -0
- package/dist/modules/email/index.d.ts +311 -0
- package/dist/modules/email/index.d.ts.map +1 -0
- package/dist/modules/email/index.js +167 -0
- package/dist/modules/email/index.js.map +1 -0
- package/dist/modules/email-message/index.d.ts +95 -0
- package/dist/modules/email-message/index.d.ts.map +1 -0
- package/dist/modules/email-message/index.js +264 -0
- package/dist/modules/email-message/index.js.map +1 -0
- package/dist/modules/file-convert/index.d.ts +273 -0
- package/dist/modules/file-convert/index.d.ts.map +1 -0
- package/dist/modules/file-convert/index.js +103 -0
- package/dist/modules/file-convert/index.js.map +1 -0
- package/dist/modules/files/index.d.ts +452 -0
- package/dist/modules/files/index.d.ts.map +1 -0
- package/dist/modules/files/index.js +733 -0
- package/dist/modules/files/index.js.map +1 -0
- package/dist/modules/image/index.d.ts +342 -0
- package/dist/modules/image/index.d.ts.map +1 -0
- package/dist/modules/image/index.js +281 -0
- package/dist/modules/image/index.js.map +1 -0
- package/dist/modules/messaging/index.d.ts +608 -0
- package/dist/modules/messaging/index.d.ts.map +1 -0
- package/dist/modules/messaging/index.js +1067 -0
- package/dist/modules/messaging/index.js.map +1 -0
- package/dist/modules/pdf/index.d.ts +287 -0
- package/dist/modules/pdf/index.d.ts.map +1 -0
- package/dist/modules/pdf/index.js +259 -0
- package/dist/modules/pdf/index.js.map +1 -0
- package/dist/modules/presentation/index.d.ts +247 -0
- package/dist/modules/presentation/index.d.ts.map +1 -0
- package/dist/modules/presentation/index.js +12657 -0
- package/dist/modules/presentation/index.js.map +1 -0
- package/dist/modules/queue/index.d.ts +129 -0
- package/dist/modules/queue/index.d.ts.map +1 -0
- package/dist/modules/queue/index.js +131 -0
- package/dist/modules/queue/index.js.map +1 -0
- package/dist/modules/rag/index.d.ts +250 -0
- package/dist/modules/rag/index.d.ts.map +1 -0
- package/dist/modules/rag/index.js +366 -0
- package/dist/modules/rag/index.js.map +1 -0
- package/dist/modules/scheduler/index.d.ts +216 -0
- package/dist/modules/scheduler/index.d.ts.map +1 -0
- package/dist/modules/scheduler/index.js +153 -0
- package/dist/modules/scheduler/index.js.map +1 -0
- package/dist/modules/skills/index.d.ts +205 -0
- package/dist/modules/skills/index.d.ts.map +1 -0
- package/dist/modules/skills/index.js +203 -0
- package/dist/modules/skills/index.js.map +1 -0
- package/dist/modules/tasks/index.d.ts +287 -0
- package/dist/modules/tasks/index.d.ts.map +1 -0
- package/dist/modules/tasks/index.js +207 -0
- package/dist/modules/tasks/index.js.map +1 -0
- package/dist/modules/vector-store/index.d.ts +3 -0
- package/dist/modules/vector-store/index.js +3 -0
- package/dist/modules/web-fetch/index.d.ts +99 -0
- package/dist/modules/web-fetch/index.d.ts.map +1 -0
- package/dist/modules/web-fetch/index.js +242 -0
- package/dist/modules/web-fetch/index.js.map +1 -0
- package/dist/object-artifact-store-CMTzCm_G.d.ts +7 -0
- package/dist/object-artifact-store-CMTzCm_G.d.ts.map +1 -0
- package/dist/object-artifact-store-wZ2j9cto.js +28 -0
- package/dist/object-artifact-store-wZ2j9cto.js.map +1 -0
- package/dist/pinecone-umY4t6OF.js +190 -0
- package/dist/pinecone-umY4t6OF.js.map +1 -0
- package/dist/provider-CgDAlg6K.js +34 -0
- package/dist/provider-CgDAlg6K.js.map +1 -0
- package/dist/qdrant-DMp4NhKR.js +253 -0
- package/dist/qdrant-DMp4NhKR.js.map +1 -0
- package/dist/resend-BAC38_dA.js +155 -0
- package/dist/resend-BAC38_dA.js.map +1 -0
- package/dist/s3-CsOaPWMP.js +955 -0
- package/dist/s3-CsOaPWMP.js.map +1 -0
- package/dist/schemas-ChOAhdo9.js +192 -0
- package/dist/schemas-ChOAhdo9.js.map +1 -0
- package/dist/slack-Di5BBNpt.js +1455 -0
- package/dist/slack-Di5BBNpt.js.map +1 -0
- package/dist/sqs-DCwS1i2N.js +225 -0
- package/dist/sqs-DCwS1i2N.js.map +1 -0
- package/dist/supabase-vector-Dpp9mmJR.js +218 -0
- package/dist/supabase-vector-Dpp9mmJR.js.map +1 -0
- package/dist/tanstack/index.d.ts +15 -0
- package/dist/tanstack/index.d.ts.map +1 -0
- package/dist/tanstack/index.js +28 -0
- package/dist/tanstack/index.js.map +1 -0
- package/dist/teams-DYAHNb39.js +835 -0
- package/dist/teams-DYAHNb39.js.map +1 -0
- package/dist/telegram-DDXWzkfL.js +734 -0
- package/dist/telegram-DDXWzkfL.js.map +1 -0
- package/dist/textract-CPLiB22H.js +554 -0
- package/dist/textract-CPLiB22H.js.map +1 -0
- package/dist/transport-B4vn-XiQ.js +157 -0
- package/dist/transport-B4vn-XiQ.js.map +1 -0
- package/dist/transport-i96ACAI_.d.ts +46 -0
- package/dist/transport-i96ACAI_.d.ts.map +1 -0
- package/dist/types-Ccb0DXY9.d.ts +150 -0
- package/dist/types-Ccb0DXY9.d.ts.map +1 -0
- package/dist/unique-EwBH1JPB.js +19 -0
- package/dist/unique-EwBH1JPB.js.map +1 -0
- package/dist/vector-store-C3nEO80e.js +193 -0
- package/dist/vector-store-C3nEO80e.js.map +1 -0
- package/dist/vendors/amazon-sp-api/index.d.ts +526 -0
- package/dist/vendors/amazon-sp-api/index.d.ts.map +1 -0
- package/dist/vendors/amazon-sp-api/index.js +975 -0
- package/dist/vendors/amazon-sp-api/index.js.map +1 -0
- package/dist/vendors/bedrock-agentcore-browser/index.d.ts +2 -0
- package/dist/vendors/bedrock-agentcore-browser/index.js +2 -0
- package/dist/vendors/bedrock-agentcore-code-interpreter/index.d.ts +228 -0
- package/dist/vendors/bedrock-agentcore-code-interpreter/index.d.ts.map +1 -0
- package/dist/vendors/bedrock-agentcore-code-interpreter/index.js +2 -0
- package/dist/vendors/cloudflare-browser/index.d.ts +2 -0
- package/dist/vendors/cloudflare-browser/index.js +2 -0
- package/dist/vendors/cloudflare-email/index.d.ts +260 -0
- package/dist/vendors/cloudflare-email/index.d.ts.map +1 -0
- package/dist/vendors/cloudflare-email/index.js +3 -0
- package/dist/vendors/cloudflare-sandbox/index.d.ts +565 -0
- package/dist/vendors/cloudflare-sandbox/index.d.ts.map +1 -0
- package/dist/vendors/cloudflare-sandbox/index.js +2 -0
- package/dist/vendors/eventbridge-scheduler/index.d.ts +2 -0
- package/dist/vendors/eventbridge-scheduler/index.js +2 -0
- package/dist/vendors/gotenberg/index.d.ts +306 -0
- package/dist/vendors/gotenberg/index.d.ts.map +1 -0
- package/dist/vendors/gotenberg/index.js +2 -0
- package/dist/vendors/imessage/index.d.ts +420 -0
- package/dist/vendors/imessage/index.d.ts.map +1 -0
- package/dist/vendors/imessage/index.js +4 -0
- package/dist/vendors/katana/index.d.ts +1570 -0
- package/dist/vendors/katana/index.d.ts.map +1 -0
- package/dist/vendors/katana/index.js +1639 -0
- package/dist/vendors/katana/index.js.map +1 -0
- package/dist/vendors/mastra-vector/index.d.ts +120 -0
- package/dist/vendors/mastra-vector/index.d.ts.map +1 -0
- package/dist/vendors/mastra-vector/index.js +3 -0
- package/dist/vendors/pinecone/index.d.ts +75 -0
- package/dist/vendors/pinecone/index.d.ts.map +1 -0
- package/dist/vendors/pinecone/index.js +3 -0
- package/dist/vendors/qdrant/index.d.ts +75 -0
- package/dist/vendors/qdrant/index.d.ts.map +1 -0
- package/dist/vendors/qdrant/index.js +3 -0
- package/dist/vendors/resend/index.d.ts +3 -0
- package/dist/vendors/resend/index.js +3 -0
- package/dist/vendors/s3/index.d.ts +2 -0
- package/dist/vendors/s3/index.js +2 -0
- package/dist/vendors/slack/index.d.ts +576 -0
- package/dist/vendors/slack/index.d.ts.map +1 -0
- package/dist/vendors/slack/index.js +3 -0
- package/dist/vendors/sqs/index.d.ts +2 -0
- package/dist/vendors/sqs/index.js +2 -0
- package/dist/vendors/supabase-vector/index.d.ts +89 -0
- package/dist/vendors/supabase-vector/index.d.ts.map +1 -0
- package/dist/vendors/supabase-vector/index.js +3 -0
- package/dist/vendors/teams/index.d.ts +303 -0
- package/dist/vendors/teams/index.d.ts.map +1 -0
- package/dist/vendors/teams/index.js +3 -0
- package/dist/vendors/telegram/index.d.ts +319 -0
- package/dist/vendors/telegram/index.d.ts.map +1 -0
- package/dist/vendors/telegram/index.js +3 -0
- package/dist/vendors/textract/index.d.ts +2 -0
- package/dist/vendors/textract/index.js +2 -0
- package/dist/vendors/woocommerce/index.d.ts +1700 -0
- package/dist/vendors/woocommerce/index.d.ts.map +1 -0
- package/dist/vendors/woocommerce/index.js +1427 -0
- package/dist/vendors/woocommerce/index.js.map +1 -0
- package/dist/with-auth-CpKqTrGK.js +240 -0
- package/dist/with-auth-CpKqTrGK.js.map +1 -0
- package/logos/LUCIDE-ATTRIBUTION.txt +4 -0
- package/logos/README.md +89 -0
- package/logos/amazon.svg +6 -0
- package/logos/artifacts.svg +9 -0
- package/logos/browser.svg +9 -0
- package/logos/calendar.svg +15 -0
- package/logos/cloudflare-browser.svg +5 -0
- package/logos/cloudflare-email.svg +5 -0
- package/logos/cloudflare.svg +4 -0
- package/logos/code-sandbox.svg +8 -0
- package/logos/content-type.svg +10 -0
- package/logos/crypto.svg +7 -0
- package/logos/document-extract.svg +12 -0
- package/logos/document-render.svg +8 -0
- package/logos/document.svg +10 -0
- package/logos/email-message.svg +8 -0
- package/logos/email.svg +7 -0
- package/logos/file-convert.svg +9 -0
- package/logos/files.svg +6 -0
- package/logos/gotenberg.svg +340 -0
- package/logos/image.svg +8 -0
- package/logos/imessage.svg +7 -0
- package/logos/katana.svg +13 -0
- package/logos/mastra.svg +7 -0
- package/logos/messaging.svg +7 -0
- package/logos/pack-logos.json +48 -0
- package/logos/pdf.svg +10 -0
- package/logos/pinecone.svg +25 -0
- package/logos/presentation.svg +8 -0
- package/logos/qdrant.svg +4 -0
- package/logos/queue.svg +11 -0
- package/logos/rag.svg +18 -0
- package/logos/resend.svg +5 -0
- package/logos/scheduler.svg +7 -0
- package/logos/skills.svg +10 -0
- package/logos/slack.svg +14 -0
- package/logos/supabase.svg +4 -0
- package/logos/tasks.svg +10 -0
- package/logos/teams.svg +6 -0
- package/logos/telegram.svg +10 -0
- package/logos/textract.svg +5 -0
- package/logos/vector-store.svg +8 -0
- package/logos/web-fetch.svg +8 -0
- package/logos/woocommerce.svg +4 -0
- package/package.json +373 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { n as defineModule, r as defineTool } from "../../define-CvpJ_pNP.js";
|
|
2
|
+
import { n as extensionFromMediaType, r as mediaTypeFromPath, t as allExtensionsFromMediaType } from "../../content-type-CORxaxcv.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/modules/content-type/module.ts
|
|
5
|
+
const getTypeInput = z.object({ path: z.string().min(1).describe("File path, filename, or extension (with or without leading dot), for example report.pdf or pdf") });
|
|
6
|
+
const getTypeOutput = z.object({ media_type: z.string().nullable().describe("Content type (MIME), or null when unrecognized") });
|
|
7
|
+
const getExtensionInput = z.object({ media_type: z.string().min(1).describe("Content type; optional charset is ignored, for example text/html; charset=utf-8") });
|
|
8
|
+
const getExtensionOutput = z.object({ extension: z.string().nullable().describe("Preferred file extension without a leading dot, or null") });
|
|
9
|
+
const getAllExtensionsOutput = z.object({ extensions: z.array(z.string()).describe("All known extensions for the type (may be empty)") });
|
|
10
|
+
const contentTypeGetTool = defineTool({
|
|
11
|
+
id: "content-type-get",
|
|
12
|
+
name: "getContentType",
|
|
13
|
+
description: "Look up the media type for a file path, filename, or extension. Use when another tool requires a media type and only the name or extension is known. Returns null for an unknown extension.",
|
|
14
|
+
inputSchema: getTypeInput,
|
|
15
|
+
outputSchema: getTypeOutput,
|
|
16
|
+
sideEffect: "none",
|
|
17
|
+
runtime: "both",
|
|
18
|
+
execute: async (input) => {
|
|
19
|
+
const mediaType = mediaTypeFromPath(input.path);
|
|
20
|
+
return getTypeOutput.parse({ media_type: mediaType ?? null });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const contentTypeExtensionTool = defineTool({
|
|
24
|
+
id: "content-type-extension",
|
|
25
|
+
name: "getContentTypeExtension",
|
|
26
|
+
description: "Look up the preferred file extension for a media type. Use when naming an output whose media type is known. Charset parameters are ignored; returns null when unknown.",
|
|
27
|
+
inputSchema: getExtensionInput,
|
|
28
|
+
outputSchema: getExtensionOutput,
|
|
29
|
+
sideEffect: "none",
|
|
30
|
+
runtime: "both",
|
|
31
|
+
execute: async (input) => {
|
|
32
|
+
const extension = extensionFromMediaType(input.media_type);
|
|
33
|
+
return getExtensionOutput.parse({ extension: extension ?? null });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const contentTypeExtensionsTool = defineTool({
|
|
37
|
+
id: "content-type-extensions",
|
|
38
|
+
name: "getContentTypeExtensions",
|
|
39
|
+
description: "List all known file extensions for a content type (for example image/jpeg → jpeg, jpg, jpe). Empty when unknown.",
|
|
40
|
+
inputSchema: getExtensionInput,
|
|
41
|
+
outputSchema: getAllExtensionsOutput,
|
|
42
|
+
sideEffect: "none",
|
|
43
|
+
runtime: "both",
|
|
44
|
+
execute: async (input) => {
|
|
45
|
+
return getAllExtensionsOutput.parse({ extensions: [...allExtensionsFromMediaType(input.media_type)] });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const contentTypeModule = defineModule({
|
|
49
|
+
id: "content-type",
|
|
50
|
+
title: "Content Type",
|
|
51
|
+
description: "Look up media types from extensions and extensions from media types. This does not inspect file bytes.",
|
|
52
|
+
runtime: "both",
|
|
53
|
+
auth: { type: "none" },
|
|
54
|
+
categories: ["utility", "content"],
|
|
55
|
+
classification: "standard",
|
|
56
|
+
tags: ["mime", "pure"],
|
|
57
|
+
tools: [
|
|
58
|
+
contentTypeGetTool,
|
|
59
|
+
contentTypeExtensionTool,
|
|
60
|
+
contentTypeExtensionsTool
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
//#endregion
|
|
64
|
+
export { contentTypeExtensionTool, contentTypeExtensionsTool, contentTypeGetTool, contentTypeModule };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/modules/content-type/module.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { defineModule, defineTool } from '../../core/define'\nimport { allExtensionsFromMediaType, extensionFromMediaType, mediaTypeFromPath } from '../../shared/content-type'\n\nconst getTypeInput = z.object({\n\tpath: z\n\t\t.string()\n\t\t.min(1)\n\t\t.describe('File path, filename, or extension (with or without leading dot), for example report.pdf or pdf')\n})\n\nconst getTypeOutput = z.object({\n\tmedia_type: z.string().nullable().describe('Content type (MIME), or null when unrecognized')\n})\n\nconst getExtensionInput = z.object({\n\tmedia_type: z\n\t\t.string()\n\t\t.min(1)\n\t\t.describe('Content type; optional charset is ignored, for example text/html; charset=utf-8')\n})\n\nconst getExtensionOutput = z.object({\n\textension: z.string().nullable().describe('Preferred file extension without a leading dot, or null')\n})\n\nconst getAllExtensionsOutput = z.object({\n\textensions: z.array(z.string()).describe('All known extensions for the type (may be empty)')\n})\n\nexport const contentTypeGetTool = defineTool({\n\tid: 'content-type-get',\n\tname: 'getContentType',\n\tdescription:\n\t\t'Look up the media type for a file path, filename, or extension. Use when another tool requires a media type and only the name or extension is known. Returns null for an unknown extension.',\n\tinputSchema: getTypeInput,\n\toutputSchema: getTypeOutput,\n\tsideEffect: 'none',\n\truntime: 'both',\n\texecute: async (input) => {\n\t\tconst mediaType = mediaTypeFromPath(input.path)\n\t\treturn getTypeOutput.parse({ media_type: mediaType ?? null })\n\t}\n})\n\nexport const contentTypeExtensionTool = defineTool({\n\tid: 'content-type-extension',\n\tname: 'getContentTypeExtension',\n\tdescription:\n\t\t'Look up the preferred file extension for a media type. Use when naming an output whose media type is known. Charset parameters are ignored; returns null when unknown.',\n\tinputSchema: getExtensionInput,\n\toutputSchema: getExtensionOutput,\n\tsideEffect: 'none',\n\truntime: 'both',\n\texecute: async (input) => {\n\t\tconst extension = extensionFromMediaType(input.media_type)\n\t\treturn getExtensionOutput.parse({ extension: extension ?? null })\n\t}\n})\n\nexport const contentTypeExtensionsTool = defineTool({\n\tid: 'content-type-extensions',\n\tname: 'getContentTypeExtensions',\n\tdescription:\n\t\t'List all known file extensions for a content type (for example image/jpeg → jpeg, jpg, jpe). Empty when unknown.',\n\tinputSchema: getExtensionInput,\n\toutputSchema: getAllExtensionsOutput,\n\tsideEffect: 'none',\n\truntime: 'both',\n\texecute: async (input) => {\n\t\treturn getAllExtensionsOutput.parse({\n\t\t\textensions: [...allExtensionsFromMediaType(input.media_type)]\n\t\t})\n\t}\n})\n\nexport const contentTypeModule = defineModule({\n\tid: 'content-type',\n\ttitle: 'Content Type',\n\tdescription: 'Look up media types from extensions and extensions from media types. This does not inspect file bytes.',\n\truntime: 'both',\n\tauth: { type: 'none' },\n\tcategories: ['utility', 'content'],\n\tclassification: 'standard',\n\ttags: ['mime', 'pure'],\n\ttools: [contentTypeGetTool, contentTypeExtensionTool, contentTypeExtensionsTool]\n})\n"],"mappings":";;;;AAKA,MAAM,eAAe,EAAE,OAAO,EAC7B,MAAM,EACJ,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,SAAS,gGAAgG,EAC5G,CAAC;AAED,MAAM,gBAAgB,EAAE,OAAO,EAC9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rB,YAAY,CAAC,WAAW,SAAS;CACjC,gBAAgB;CAChB,MAAM,CAAC,QAAQ,MAAM;CACrB,OAAO;EAAC;EAAoB;EAA0B;CAAyB;AAChF,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { a as ModuleDefinition, s as ToolDefinition } from "../../types-Ccb0DXY9.js";
|
|
2
|
+
import "../../index-CZX5OeOF.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/modules/crypto/contracts.d.ts
|
|
5
|
+
declare const MAX_CRYPTO_INPUT_CHARS = 1400000;
|
|
6
|
+
declare const cryptoAuthSchema: z.ZodObject<{
|
|
7
|
+
hmac_keys: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
declare const cryptoAlgorithmSchema: z.ZodEnum<{
|
|
10
|
+
"SHA-256": "SHA-256";
|
|
11
|
+
"SHA-384": "SHA-384";
|
|
12
|
+
"SHA-512": "SHA-512";
|
|
13
|
+
}>;
|
|
14
|
+
declare const cryptoHashInputSchema: z.ZodObject<{
|
|
15
|
+
body: z.ZodString;
|
|
16
|
+
encoding: z.ZodEnum<{
|
|
17
|
+
base64: "base64";
|
|
18
|
+
utf8: "utf8";
|
|
19
|
+
}>;
|
|
20
|
+
algorithm: z.ZodEnum<{
|
|
21
|
+
"SHA-256": "SHA-256";
|
|
22
|
+
"SHA-384": "SHA-384";
|
|
23
|
+
"SHA-512": "SHA-512";
|
|
24
|
+
}>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
declare const cryptoHashOutputSchema: z.ZodObject<{
|
|
27
|
+
digest_base64: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
declare const cryptoHmacSignInputSchema: z.ZodObject<{
|
|
30
|
+
body: z.ZodString;
|
|
31
|
+
encoding: z.ZodEnum<{
|
|
32
|
+
base64: "base64";
|
|
33
|
+
utf8: "utf8";
|
|
34
|
+
}>;
|
|
35
|
+
key_id: z.ZodString;
|
|
36
|
+
algorithm: z.ZodEnum<{
|
|
37
|
+
"SHA-256": "SHA-256";
|
|
38
|
+
"SHA-384": "SHA-384";
|
|
39
|
+
"SHA-512": "SHA-512";
|
|
40
|
+
}>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
declare const cryptoHmacSignOutputSchema: z.ZodObject<{
|
|
43
|
+
signature_base64: z.ZodString;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
declare const cryptoHmacVerifyInputSchema: z.ZodObject<{
|
|
46
|
+
body: z.ZodString;
|
|
47
|
+
encoding: z.ZodEnum<{
|
|
48
|
+
base64: "base64";
|
|
49
|
+
utf8: "utf8";
|
|
50
|
+
}>;
|
|
51
|
+
key_id: z.ZodString;
|
|
52
|
+
algorithm: z.ZodEnum<{
|
|
53
|
+
"SHA-256": "SHA-256";
|
|
54
|
+
"SHA-384": "SHA-384";
|
|
55
|
+
"SHA-512": "SHA-512";
|
|
56
|
+
}>;
|
|
57
|
+
signature_base64: z.ZodString;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
declare const cryptoHmacVerifyOutputSchema: z.ZodObject<{
|
|
60
|
+
valid: z.ZodBoolean;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
declare const cryptoRandomBytesInputSchema: z.ZodObject<{
|
|
63
|
+
byte_length: z.ZodInt;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
declare const cryptoRandomBytesOutputSchema: z.ZodObject<{
|
|
66
|
+
body_base64: z.ZodString;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
type CryptoAuth = z.infer<typeof cryptoAuthSchema>;
|
|
69
|
+
type CryptoAlgorithm = z.infer<typeof cryptoAlgorithmSchema>;
|
|
70
|
+
type CryptoHashInput = z.infer<typeof cryptoHashInputSchema>;
|
|
71
|
+
type CryptoHmacSignInput = z.infer<typeof cryptoHmacSignInputSchema>;
|
|
72
|
+
type CryptoHmacVerifyInput = z.infer<typeof cryptoHmacVerifyInputSchema>;
|
|
73
|
+
type CryptoRandomBytesInput = z.infer<typeof cryptoRandomBytesInputSchema>;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/modules/crypto/domain.d.ts
|
|
76
|
+
declare function hashData(input: CryptoHashInput): Promise<string>;
|
|
77
|
+
declare function signHmac(auth: CryptoAuth, input: CryptoHmacSignInput): Promise<string>;
|
|
78
|
+
declare function verifyHmac(auth: CryptoAuth, input: CryptoHmacVerifyInput): Promise<boolean>;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/modules/crypto/module.d.ts
|
|
81
|
+
declare const cryptoHashTool: ToolDefinition<{
|
|
82
|
+
body: string;
|
|
83
|
+
encoding: "base64" | "utf8";
|
|
84
|
+
algorithm: "SHA-256" | "SHA-384" | "SHA-512";
|
|
85
|
+
}, {
|
|
86
|
+
digest_base64: string;
|
|
87
|
+
}>;
|
|
88
|
+
declare const cryptoHmacSignTool: ToolDefinition<{
|
|
89
|
+
body: string;
|
|
90
|
+
encoding: "base64" | "utf8";
|
|
91
|
+
key_id: string;
|
|
92
|
+
algorithm: "SHA-256" | "SHA-384" | "SHA-512";
|
|
93
|
+
}, {
|
|
94
|
+
signature_base64: string;
|
|
95
|
+
}>;
|
|
96
|
+
declare const cryptoHmacVerifyTool: ToolDefinition<{
|
|
97
|
+
body: string;
|
|
98
|
+
encoding: "base64" | "utf8";
|
|
99
|
+
key_id: string;
|
|
100
|
+
algorithm: "SHA-256" | "SHA-384" | "SHA-512";
|
|
101
|
+
signature_base64: string;
|
|
102
|
+
}, {
|
|
103
|
+
valid: boolean;
|
|
104
|
+
}>;
|
|
105
|
+
declare const cryptoRandomBytesTool: ToolDefinition<{
|
|
106
|
+
byte_length: number;
|
|
107
|
+
}, {
|
|
108
|
+
body_base64: string;
|
|
109
|
+
}>;
|
|
110
|
+
declare const cryptoModule: ModuleDefinition<{
|
|
111
|
+
hmac_keys: Record<string, string>;
|
|
112
|
+
}>;
|
|
113
|
+
//#endregion
|
|
114
|
+
export { type CryptoAlgorithm, type CryptoAuth, type CryptoHashInput, type CryptoHmacSignInput, type CryptoHmacVerifyInput, type CryptoRandomBytesInput, MAX_CRYPTO_INPUT_CHARS, cryptoAlgorithmSchema, cryptoAuthSchema, cryptoHashInputSchema, cryptoHashOutputSchema, cryptoHashTool, cryptoHmacSignInputSchema, cryptoHmacSignOutputSchema, cryptoHmacSignTool, cryptoHmacVerifyInputSchema, cryptoHmacVerifyOutputSchema, cryptoHmacVerifyTool, cryptoModule, cryptoRandomBytesInputSchema, cryptoRandomBytesOutputSchema, cryptoRandomBytesTool, hashData, signHmac, verifyHmac };
|
|
115
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/modules/crypto/contracts.ts","../../../src/modules/crypto/domain.ts","../../../src/modules/crypto/module.ts"],"mappings":";;;;cAEa;cAEA,kBAAgB,EAAA;;GAE3B,EAAA,KAAA;cAEW,uBAAqB,EAAA;;;;;cAOrB,uBAAqB,EAAA;;;;;;;;;;;GAEhC,EAAA,KAAA;cAEW,wBAAsB,EAAA;;GAEjC,EAAA,KAAA;cAEW,2BAAyB,EAAA;;;;;;;;;;;;GAGpC,EAAA,KAAA;cAEW,4BAA0B,EAAA;;GAErC,EAAA,KAAA;cAEW,6BAA2B,EAAA;;;;;;;;;;;;;GAEtC,EAAA,KAAA;cAEW,8BAA4B,EAAA;;GAEvC,EAAA,KAAA;cAEW,8BAA4B,EAAA;;GAEvC,EAAA,KAAA;cAEW,+BAA6B,EAAA;;GAExC,EAAA,KAAA;KAEU,aAAa,EAAE,aAAa;KAC5B,kBAAkB,EAAE,aAAa;KACjC,kBAAkB,EAAE,aAAa;KACjC,sBAAsB,EAAE,aAAa;KACrC,wBAAwB,EAAE,aAAa;KACvC,yBAAyB,EAAE,aAAa;;;iBCjB9B,SAAS,OAAO,kBAAkB;iBAKlC,SAAS,MAAM,YAAY,OAAO,sBAAsB;iBAMxD,WAAW,MAAM,YAAY,OAAO,wBAAwB;;;cC/BrE,gBAAA;;;;;;;cAWA,oBAAA;;;;;;;;cAcA,sBAAA;;;;;;;;;cAcA,uBAAA;;;;;cAcA,cAAA;aAAA"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { t as ToolError } from "../../errors-DoSpNHvs.js";
|
|
2
|
+
import { n as defineModule, r as defineTool } from "../../define-CvpJ_pNP.js";
|
|
3
|
+
import { n as requireAuth } from "../../provider-CgDAlg6K.js";
|
|
4
|
+
import { a as toArrayBuffer, n as bytesToBase64, o as utf8ToBytes, t as base64ToBytes } from "../../bytes-BxpimpQx.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/modules/crypto/contracts.ts
|
|
7
|
+
const MAX_CRYPTO_INPUT_CHARS = 14e5;
|
|
8
|
+
const cryptoAuthSchema = z.object({ hmac_keys: z.record(z.string().min(1), z.string().min(1)).describe("Base64 HMAC keys indexed by host-defined id") });
|
|
9
|
+
const cryptoAlgorithmSchema = z.enum([
|
|
10
|
+
"SHA-256",
|
|
11
|
+
"SHA-384",
|
|
12
|
+
"SHA-512"
|
|
13
|
+
]);
|
|
14
|
+
const encodedBodySchema = z.object({
|
|
15
|
+
body: z.string().max(MAX_CRYPTO_INPUT_CHARS).describe("Data encoded as specified by encoding"),
|
|
16
|
+
encoding: z.enum(["utf8", "base64"]).describe("How body is encoded")
|
|
17
|
+
});
|
|
18
|
+
const cryptoHashInputSchema = encodedBodySchema.extend({ algorithm: cryptoAlgorithmSchema.describe("SHA-2 digest algorithm") });
|
|
19
|
+
const cryptoHashOutputSchema = z.object({ digest_base64: z.string().describe("Digest encoded as base64") });
|
|
20
|
+
const cryptoHmacSignInputSchema = encodedBodySchema.extend({
|
|
21
|
+
key_id: z.string().min(1).describe("Identifier of a bound signing key"),
|
|
22
|
+
algorithm: cryptoAlgorithmSchema.describe("SHA-2 HMAC algorithm")
|
|
23
|
+
});
|
|
24
|
+
const cryptoHmacSignOutputSchema = z.object({ signature_base64: z.string().describe("HMAC signature encoded as base64") });
|
|
25
|
+
const cryptoHmacVerifyInputSchema = cryptoHmacSignInputSchema.extend({ signature_base64: z.string().min(1).describe("Base64 HMAC signature to verify") });
|
|
26
|
+
const cryptoHmacVerifyOutputSchema = z.object({ valid: z.boolean() });
|
|
27
|
+
const cryptoRandomBytesInputSchema = z.object({ byte_length: z.int().min(1).max(4096).describe("Number of random bytes to generate") });
|
|
28
|
+
const cryptoRandomBytesOutputSchema = z.object({ body_base64: z.string().describe("Random bytes encoded as base64") });
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/modules/crypto/domain.ts
|
|
31
|
+
function bodyBytes(input) {
|
|
32
|
+
return input.encoding === "base64" ? base64ToBytes(input.body) : utf8ToBytes(input.body);
|
|
33
|
+
}
|
|
34
|
+
function keyBytes(auth, keyId) {
|
|
35
|
+
const value = auth.hmac_keys[keyId];
|
|
36
|
+
if (!value) throw new ToolError("HMAC key id is not bound", {
|
|
37
|
+
code: "not_found",
|
|
38
|
+
details: { key_id: keyId }
|
|
39
|
+
});
|
|
40
|
+
return base64ToBytes(value);
|
|
41
|
+
}
|
|
42
|
+
async function importHmacKey(auth, keyId, algorithm) {
|
|
43
|
+
try {
|
|
44
|
+
return await crypto.subtle.importKey("raw", toArrayBuffer(keyBytes(auth, keyId)), {
|
|
45
|
+
name: "HMAC",
|
|
46
|
+
hash: algorithm
|
|
47
|
+
}, false, ["sign", "verify"]);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw new ToolError("Failed to load HMAC key", {
|
|
50
|
+
code: "bad_auth",
|
|
51
|
+
cause: error
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function hashData(input) {
|
|
56
|
+
const digest = await crypto.subtle.digest(input.algorithm, toArrayBuffer(bodyBytes(input)));
|
|
57
|
+
return bytesToBase64(new Uint8Array(digest));
|
|
58
|
+
}
|
|
59
|
+
async function signHmac(auth, input) {
|
|
60
|
+
const key = await importHmacKey(auth, input.key_id, input.algorithm);
|
|
61
|
+
const signature = await crypto.subtle.sign("HMAC", key, toArrayBuffer(bodyBytes(input)));
|
|
62
|
+
return bytesToBase64(new Uint8Array(signature));
|
|
63
|
+
}
|
|
64
|
+
async function verifyHmac(auth, input) {
|
|
65
|
+
const key = await importHmacKey(auth, input.key_id, input.algorithm);
|
|
66
|
+
try {
|
|
67
|
+
return await crypto.subtle.verify("HMAC", key, toArrayBuffer(base64ToBytes(input.signature_base64)), toArrayBuffer(bodyBytes(input)));
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/modules/crypto/module.ts
|
|
74
|
+
const cryptoHashTool = defineTool({
|
|
75
|
+
id: "crypto-hash",
|
|
76
|
+
name: "hashData",
|
|
77
|
+
description: "Compute a SHA-256, SHA-384, or SHA-512 digest for UTF-8 or base64 input.",
|
|
78
|
+
inputSchema: cryptoHashInputSchema,
|
|
79
|
+
outputSchema: cryptoHashOutputSchema,
|
|
80
|
+
sideEffect: "none",
|
|
81
|
+
runtime: "both",
|
|
82
|
+
execute: async (input) => cryptoHashOutputSchema.parse({ digest_base64: await hashData(input) })
|
|
83
|
+
});
|
|
84
|
+
const cryptoHmacSignTool = defineTool({
|
|
85
|
+
id: "crypto-hmac-sign",
|
|
86
|
+
name: "signHmac",
|
|
87
|
+
description: "Create an HMAC signature with a bound key id and the selected SHA-2 algorithm.",
|
|
88
|
+
inputSchema: cryptoHmacSignInputSchema,
|
|
89
|
+
outputSchema: cryptoHmacSignOutputSchema,
|
|
90
|
+
sideEffect: "none",
|
|
91
|
+
runtime: "both",
|
|
92
|
+
execute: async (input, ctx) => cryptoHmacSignOutputSchema.parse({ signature_base64: await signHmac(requireAuth(ctx, cryptoAuthSchema), input) })
|
|
93
|
+
});
|
|
94
|
+
const cryptoHmacVerifyTool = defineTool({
|
|
95
|
+
id: "crypto-hmac-verify",
|
|
96
|
+
name: "verifyHmac",
|
|
97
|
+
description: "Verify a base64 HMAC signature with a bound key id and the selected SHA-2 algorithm.",
|
|
98
|
+
inputSchema: cryptoHmacVerifyInputSchema,
|
|
99
|
+
outputSchema: cryptoHmacVerifyOutputSchema,
|
|
100
|
+
sideEffect: "none",
|
|
101
|
+
runtime: "both",
|
|
102
|
+
execute: async (input, ctx) => cryptoHmacVerifyOutputSchema.parse({ valid: await verifyHmac(requireAuth(ctx, cryptoAuthSchema), input) })
|
|
103
|
+
});
|
|
104
|
+
const cryptoRandomBytesTool = defineTool({
|
|
105
|
+
id: "crypto-random-bytes",
|
|
106
|
+
name: "generateRandomBytes",
|
|
107
|
+
description: "Generate up to 4096 cryptographically secure random bytes and return them as base64.",
|
|
108
|
+
inputSchema: cryptoRandomBytesInputSchema,
|
|
109
|
+
outputSchema: cryptoRandomBytesOutputSchema,
|
|
110
|
+
sideEffect: "none",
|
|
111
|
+
runtime: "both",
|
|
112
|
+
execute: async (input) => {
|
|
113
|
+
const bytes = crypto.getRandomValues(new Uint8Array(input.byte_length));
|
|
114
|
+
return cryptoRandomBytesOutputSchema.parse({ body_base64: bytesToBase64(bytes) });
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
const cryptoModule = defineModule({
|
|
118
|
+
id: "crypto",
|
|
119
|
+
title: "Crypto",
|
|
120
|
+
description: "Hash data, sign and verify HMAC values, and generate secure random bytes.",
|
|
121
|
+
runtime: "both",
|
|
122
|
+
auth: {
|
|
123
|
+
type: "custom",
|
|
124
|
+
schema: cryptoAuthSchema
|
|
125
|
+
},
|
|
126
|
+
categories: ["security", "utility"],
|
|
127
|
+
classification: "standard",
|
|
128
|
+
tags: ["digest", "hmac"],
|
|
129
|
+
tools: [
|
|
130
|
+
cryptoHashTool,
|
|
131
|
+
cryptoHmacSignTool,
|
|
132
|
+
cryptoHmacVerifyTool,
|
|
133
|
+
cryptoRandomBytesTool
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
//#endregion
|
|
137
|
+
export { MAX_CRYPTO_INPUT_CHARS, cryptoAlgorithmSchema, cryptoAuthSchema, cryptoHashInputSchema, cryptoHashOutputSchema, cryptoHashTool, cryptoHmacSignInputSchema, cryptoHmacSignOutputSchema, cryptoHmacSignTool, cryptoHmacVerifyInputSchema, cryptoHmacVerifyOutputSchema, cryptoHmacVerifyTool, cryptoModule, cryptoRandomBytesInputSchema, cryptoRandomBytesOutputSchema, cryptoRandomBytesTool, hashData, signHmac, verifyHmac };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/modules/crypto/contracts.ts","../../../src/modules/crypto/domain.ts","../../../src/modules/crypto/module.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const MAX_CRYPTO_INPUT_CHARS = 1_400_000\n\nexport const cryptoAuthSchema = z.object({\n\thmac_keys: z.record(z.string().min(1), z.string().min(1)).describe('Base64 HMAC keys indexed by host-defined id')\n})\n\nexport const cryptoAlgorithmSchema = z.enum(['SHA-256', 'SHA-384', 'SHA-512'])\n\nconst encodedBodySchema = z.object({\n\tbody: z.string().max(MAX_CRYPTO_INPUT_CHARS).describe('Data encoded as specified by encoding'),\n\tencoding: z.enum(['utf8', 'base64']).describe('How body is encoded')\n})\n\nexport const cryptoHashInputSchema = encodedBodySchema.extend({\n\talgorithm: cryptoAlgorithmSchema.describe('SHA-2 digest algorithm')\n})\n\nexport const cryptoHashOutputSchema = z.object({\n\tdigest_base64: z.string().describe('Digest encoded as base64')\n})\n\nexport const cryptoHmacSignInputSchema = encodedBodySchema.extend({\n\tkey_id: z.string().min(1).describe('Identifier of a bound signing key'),\n\talgorithm: cryptoAlgorithmSchema.describe('SHA-2 HMAC algorithm')\n})\n\nexport const cryptoHmacSignOutputSchema = z.object({\n\tsignature_base64: z.string().describe('HMAC signature encoded as base64')\n})\n\nexport const cryptoHmacVerifyInputSchema = cryptoHmacSignInputSchema.extend({\n\tsignature_base64: z.string().min(1).describe('Base64 HMAC signature to verify')\n})\n\nexport const cryptoHmacVerifyOutputSchema = z.object({\n\tvalid: z.boolean()\n})\n\nexport const cryptoRandomBytesInputSchema = z.object({\n\tbyte_length: z.int().min(1).max(4_096).describe('Number of random bytes to generate')\n})\n\nexport const cryptoRandomBytesOutputSchema = z.object({\n\tbody_base64: z.string().describe('Random bytes encoded as base64')\n})\n\nexport type CryptoAuth = z.infer<typeof cryptoAuthSchema>\nexport type CryptoAlgorithm = z.infer<typeof cryptoAlgorithmSchema>\nexport type CryptoHashInput = z.infer<typeof cryptoHashInputSchema>\nexport type CryptoHmacSignInput = z.infer<typeof cryptoHmacSignInputSchema>\nexport type CryptoHmacVerifyInput = z.infer<typeof cryptoHmacVerifyInputSchema>\nexport type CryptoRandomBytesInput = z.infer<typeof cryptoRandomBytesInputSchema>\n","import { ToolError } from '../../core/errors'\nimport { base64ToBytes, bytesToBase64, toArrayBuffer, utf8ToBytes } from '../../shared/bytes'\nimport type {\n\tCryptoAlgorithm,\n\tCryptoAuth,\n\tCryptoHashInput,\n\tCryptoHmacSignInput,\n\tCryptoHmacVerifyInput\n} from './contracts'\n\nfunction bodyBytes(input: { body: string; encoding: 'utf8' | 'base64' }): Uint8Array {\n\treturn input.encoding === 'base64' ? base64ToBytes(input.body) : utf8ToBytes(input.body)\n}\n\nfunction keyBytes(auth: CryptoAuth, keyId: string): Uint8Array {\n\tconst value = auth.hmac_keys[keyId]\n\tif (!value) {\n\t\tthrow new ToolError('HMAC key id is not bound', { code: 'not_found', details: { key_id: keyId } })\n\t}\n\treturn base64ToBytes(value)\n}\n\nasync function importHmacKey(auth: CryptoAuth, keyId: string, algorithm: CryptoAlgorithm): Promise<CryptoKey> {\n\ttry {\n\t\treturn await crypto.subtle.importKey(\n\t\t\t'raw',\n\t\t\ttoArrayBuffer(keyBytes(auth, keyId)),\n\t\t\t{ name: 'HMAC', hash: algorithm },\n\t\t\tfalse,\n\t\t\t['sign', 'verify']\n\t\t)\n\t} catch (error) {\n\t\tthrow new ToolError('Failed to load HMAC key', { code: 'bad_auth', cause: error })\n\t}\n}\n\nexport async function hashData(input: CryptoHashInput): Promise<string> {\n\tconst digest = await crypto.subtle.digest(input.algorithm, toArrayBuffer(bodyBytes(input)))\n\treturn bytesToBase64(new Uint8Array(digest))\n}\n\nexport async function signHmac(auth: CryptoAuth, input: CryptoHmacSignInput): Promise<string> {\n\tconst key = await importHmacKey(auth, input.key_id, input.algorithm)\n\tconst signature = await crypto.subtle.sign('HMAC', key, toArrayBuffer(bodyBytes(input)))\n\treturn bytesToBase64(new Uint8Array(signature))\n}\n\nexport async function verifyHmac(auth: CryptoAuth, input: CryptoHmacVerifyInput): Promise<boolean> {\n\tconst key = await importHmacKey(auth, input.key_id, input.algorithm)\n\ttry {\n\t\treturn await crypto.subtle.verify(\n\t\t\t'HMAC',\n\t\t\tkey,\n\t\t\ttoArrayBuffer(base64ToBytes(input.signature_base64)),\n\t\t\ttoArrayBuffer(bodyBytes(input))\n\t\t)\n\t} catch {\n\t\treturn false\n\t}\n}\n","import { requireAuth } from '../../core/provider'\nimport { defineModule, defineTool } from '../../core/define'\nimport { bytesToBase64 } from '../../shared/bytes'\nimport {\n\tcryptoAuthSchema,\n\tcryptoHashInputSchema,\n\tcryptoHashOutputSchema,\n\tcryptoHmacSignInputSchema,\n\tcryptoHmacSignOutputSchema,\n\tcryptoHmacVerifyInputSchema,\n\tcryptoHmacVerifyOutputSchema,\n\tcryptoRandomBytesInputSchema,\n\tcryptoRandomBytesOutputSchema\n} from './contracts'\nimport { hashData, signHmac, verifyHmac } from './domain'\n\nexport const cryptoHashTool = defineTool({\n\tid: 'crypto-hash',\n\tname: 'hashData',\n\tdescription: 'Compute a SHA-256, SHA-384, or SHA-512 digest for UTF-8 or base64 input.',\n\tinputSchema: cryptoHashInputSchema,\n\toutputSchema: cryptoHashOutputSchema,\n\tsideEffect: 'none',\n\truntime: 'both',\n\texecute: async (input) => cryptoHashOutputSchema.parse({ digest_base64: await hashData(input) })\n})\n\nexport const cryptoHmacSignTool = defineTool({\n\tid: 'crypto-hmac-sign',\n\tname: 'signHmac',\n\tdescription: 'Create an HMAC signature with a bound key id and the selected SHA-2 algorithm.',\n\tinputSchema: cryptoHmacSignInputSchema,\n\toutputSchema: cryptoHmacSignOutputSchema,\n\tsideEffect: 'none',\n\truntime: 'both',\n\texecute: async (input, ctx) =>\n\t\tcryptoHmacSignOutputSchema.parse({\n\t\t\tsignature_base64: await signHmac(requireAuth(ctx, cryptoAuthSchema), input)\n\t\t})\n})\n\nexport const cryptoHmacVerifyTool = defineTool({\n\tid: 'crypto-hmac-verify',\n\tname: 'verifyHmac',\n\tdescription: 'Verify a base64 HMAC signature with a bound key id and the selected SHA-2 algorithm.',\n\tinputSchema: cryptoHmacVerifyInputSchema,\n\toutputSchema: cryptoHmacVerifyOutputSchema,\n\tsideEffect: 'none',\n\truntime: 'both',\n\texecute: async (input, ctx) =>\n\t\tcryptoHmacVerifyOutputSchema.parse({\n\t\t\tvalid: await verifyHmac(requireAuth(ctx, cryptoAuthSchema), input)\n\t\t})\n})\n\nexport const cryptoRandomBytesTool = defineTool({\n\tid: 'crypto-random-bytes',\n\tname: 'generateRandomBytes',\n\tdescription: 'Generate up to 4096 cryptographically secure random bytes and return them as base64.',\n\tinputSchema: cryptoRandomBytesInputSchema,\n\toutputSchema: cryptoRandomBytesOutputSchema,\n\tsideEffect: 'none',\n\truntime: 'both',\n\texecute: async (input) => {\n\t\tconst bytes = crypto.getRandomValues(new Uint8Array(input.byte_length))\n\t\treturn cryptoRandomBytesOutputSchema.parse({ body_base64: bytesToBase64(bytes) })\n\t}\n})\n\nexport const cryptoModule = defineModule({\n\tid: 'crypto',\n\ttitle: 'Crypto',\n\tdescription: 'Hash data, sign and verify HMAC values, and generate secure random bytes.',\n\truntime: 'both',\n\tauth: { type: 'custom', schema: cryptoAuthSchema },\n\tcategories: ['security', 'utility'],\n\tclassification: 'standard',\n\ttags: ['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