@layervai/qurl-mcp 0.4.1 → 0.5.0
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/README.md +742 -50
- package/assets/fonts/NotoSansSC-Regular.ttf +0 -0
- package/assets/fonts/OFL.txt +93 -0
- package/assets/fonts/README.md +18 -0
- package/dist/auth/request-context.d.ts +13 -0
- package/dist/auth/request-context.d.ts.map +1 -0
- package/dist/auth/request-context.js +21 -0
- package/dist/auth/request-context.js.map +1 -0
- package/dist/auth/static-bearer.d.ts +12 -0
- package/dist/auth/static-bearer.d.ts.map +1 -0
- package/dist/auth/static-bearer.js +47 -0
- package/dist/auth/static-bearer.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -4
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +98 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +543 -0
- package/dist/config.js.map +1 -0
- package/dist/credential-rate-limit-store.d.ts +38 -0
- package/dist/credential-rate-limit-store.d.ts.map +1 -0
- package/dist/credential-rate-limit-store.js +135 -0
- package/dist/credential-rate-limit-store.js.map +1 -0
- package/dist/email-addresses.d.ts +7 -0
- package/dist/email-addresses.d.ts.map +1 -0
- package/dist/email-addresses.js +36 -0
- package/dist/email-addresses.js.map +1 -0
- package/dist/email-types.d.ts +33 -0
- package/dist/email-types.d.ts.map +1 -0
- package/dist/email-types.js +28 -0
- package/dist/email-types.js.map +1 -0
- package/dist/emf-metrics.d.ts +25 -0
- package/dist/emf-metrics.d.ts.map +1 -0
- package/dist/emf-metrics.js +87 -0
- package/dist/emf-metrics.js.map +1 -0
- package/dist/http-config.d.ts +38 -0
- package/dist/http-config.d.ts.map +1 -0
- package/dist/http-config.js +243 -0
- package/dist/http-config.js.map +1 -0
- package/dist/http-routes.d.ts +5 -0
- package/dist/http-routes.d.ts.map +1 -0
- package/dist/http-routes.js +12 -0
- package/dist/http-routes.js.map +1 -0
- package/dist/http.d.ts +33 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +1116 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -26
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts +7 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +110 -0
- package/dist/logging.js.map +1 -0
- package/dist/server.d.ts +12 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +33 -8
- package/dist/server.js.map +1 -1
- package/dist/services/email.d.ts +17 -0
- package/dist/services/email.d.ts.map +1 -0
- package/dist/services/email.js +351 -0
- package/dist/services/email.js.map +1 -0
- package/dist/services/html.d.ts +5 -0
- package/dist/services/html.d.ts.map +1 -0
- package/dist/services/html.js +28 -0
- package/dist/services/html.js.map +1 -0
- package/dist/services/legal-pages.d.ts +12 -0
- package/dist/services/legal-pages.d.ts.map +1 -0
- package/dist/services/legal-pages.js +588 -0
- package/dist/services/legal-pages.js.map +1 -0
- package/dist/services/text-pdf.d.ts +16 -0
- package/dist/services/text-pdf.d.ts.map +1 -0
- package/dist/services/text-pdf.js +141 -0
- package/dist/services/text-pdf.js.map +1 -0
- package/dist/services/video-page.d.ts +4 -0
- package/dist/services/video-page.d.ts.map +1 -0
- package/dist/services/video-page.js +311 -0
- package/dist/services/video-page.js.map +1 -0
- package/dist/text.d.ts +4 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +16 -0
- package/dist/text.js.map +1 -0
- package/dist/tools/_shared.d.ts +9 -1
- package/dist/tools/_shared.d.ts.map +1 -1
- package/dist/tools/_shared.js +20 -8
- package/dist/tools/_shared.js.map +1 -1
- package/dist/tools/batch-create.d.ts +12 -11
- package/dist/tools/batch-create.d.ts.map +1 -1
- package/dist/tools/batch-create.js +6 -4
- package/dist/tools/batch-create.js.map +1 -1
- package/dist/tools/create-qurl.d.ts +43 -4
- package/dist/tools/create-qurl.d.ts.map +1 -1
- package/dist/tools/create-qurl.js +63 -30
- package/dist/tools/create-qurl.js.map +1 -1
- package/dist/tools/delete-qurl.d.ts +3 -2
- package/dist/tools/delete-qurl.d.ts.map +1 -1
- package/dist/tools/delete-qurl.js +3 -10
- package/dist/tools/delete-qurl.js.map +1 -1
- package/dist/tools/email-delivery.d.ts +37 -0
- package/dist/tools/email-delivery.d.ts.map +1 -0
- package/dist/tools/email-delivery.js +115 -0
- package/dist/tools/email-delivery.js.map +1 -0
- package/dist/tools/extend-qurl.d.ts +6 -5
- package/dist/tools/extend-qurl.d.ts.map +1 -1
- package/dist/tools/extend-qurl.js +3 -3
- package/dist/tools/extend-qurl.js.map +1 -1
- package/dist/tools/get-qurl.d.ts +6 -5
- package/dist/tools/get-qurl.d.ts.map +1 -1
- package/dist/tools/get-qurl.js +5 -3
- package/dist/tools/get-qurl.js.map +1 -1
- package/dist/tools/list-qurl-sessions.d.ts +5 -4
- package/dist/tools/list-qurl-sessions.d.ts.map +1 -1
- package/dist/tools/list-qurl-sessions.js +2 -2
- package/dist/tools/list-qurl-sessions.js.map +1 -1
- package/dist/tools/list-qurls.d.ts +8 -7
- package/dist/tools/list-qurls.d.ts.map +1 -1
- package/dist/tools/list-qurls.js +9 -7
- package/dist/tools/list-qurls.js.map +1 -1
- package/dist/tools/mint-link.d.ts +39 -3
- package/dist/tools/mint-link.d.ts.map +1 -1
- package/dist/tools/mint-link.js +24 -13
- package/dist/tools/mint-link.js.map +1 -1
- package/dist/tools/output-schemas.d.ts +102 -45
- package/dist/tools/output-schemas.d.ts.map +1 -1
- package/dist/tools/output-schemas.js +54 -29
- package/dist/tools/output-schemas.js.map +1 -1
- package/dist/tools/resolve-qurl.d.ts +4 -3
- package/dist/tools/resolve-qurl.d.ts.map +1 -1
- package/dist/tools/resolve-qurl.js +3 -3
- package/dist/tools/resolve-qurl.js.map +1 -1
- package/dist/tools/revoke-qurl-token.d.ts +3 -2
- package/dist/tools/revoke-qurl-token.d.ts.map +1 -1
- package/dist/tools/revoke-qurl-token.js +2 -2
- package/dist/tools/revoke-qurl-token.js.map +1 -1
- package/dist/tools/terminate-qurl-sessions.d.ts +3 -2
- package/dist/tools/terminate-qurl-sessions.d.ts.map +1 -1
- package/dist/tools/terminate-qurl-sessions.js +7 -3
- package/dist/tools/terminate-qurl-sessions.js.map +1 -1
- package/dist/tools/update-qurl-token.d.ts +5 -4
- package/dist/tools/update-qurl-token.d.ts.map +1 -1
- package/dist/tools/update-qurl-token.js +2 -2
- package/dist/tools/update-qurl-token.js.map +1 -1
- package/dist/tools/update-qurl.d.ts +6 -5
- package/dist/tools/update-qurl.d.ts.map +1 -1
- package/dist/tools/update-qurl.js +4 -4
- package/dist/tools/update-qurl.js.map +1 -1
- package/dist/tools/upload-file-data-qurl.d.ts +182 -0
- package/dist/tools/upload-file-data-qurl.d.ts.map +1 -0
- package/dist/tools/upload-file-data-qurl.js +200 -0
- package/dist/tools/upload-file-data-qurl.js.map +1 -0
- package/dist/tools/upload-file-qurl.d.ts +162 -0
- package/dist/tools/upload-file-qurl.d.ts.map +1 -0
- package/dist/tools/upload-file-qurl.js +167 -0
- package/dist/tools/upload-file-qurl.js.map +1 -0
- package/dist/tools/upload-file-shared.d.ts +36 -0
- package/dist/tools/upload-file-shared.d.ts.map +1 -0
- package/dist/tools/upload-file-shared.js +347 -0
- package/dist/tools/upload-file-shared.js.map +1 -0
- package/dist/tools/upload-mint-options.d.ts +22 -0
- package/dist/tools/upload-mint-options.d.ts.map +1 -0
- package/dist/tools/upload-mint-options.js +29 -0
- package/dist/tools/upload-mint-options.js.map +1 -0
- package/dist/tools/upload-text-qurl.d.ts +144 -0
- package/dist/tools/upload-text-qurl.d.ts.map +1 -0
- package/dist/tools/upload-text-qurl.js +102 -0
- package/dist/tools/upload-text-qurl.js.map +1 -0
- package/package.json +25 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revoke-qurl-token.js","sourceRoot":"","sources":["../../src/tools/revoke-qurl-token.ts"],"names":[],"m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AO,EAAE,KAAK,CAAC,OAAO;gBACtB,OAAO,EAAE,IAAa;gBACtB,OAAO,EAAE,cAAc,KAAK,CAAC,OAAO,cAAc;aACnD,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnE,iBAAiB,EAAE,mBAAmB,CAAC,OAAO,CAAC;aAChD,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type IQURLClient } from "../client.js";
|
|
3
|
+
import { type ToolRuntimeOptions } from "./_shared.js";
|
|
3
4
|
export declare const terminateQurlSessionsSchema: z.ZodObject<{
|
|
4
5
|
resource_id: z.ZodString;
|
|
5
6
|
session_id: z.ZodOptional<z.ZodString>;
|
|
6
7
|
}, z.core.$strip>;
|
|
7
|
-
export declare function terminateQurlSessionsTool(client: IQURLClient): {
|
|
8
|
+
export declare function terminateQurlSessionsTool(client: IQURLClient, _runtime?: ToolRuntimeOptions): {
|
|
8
9
|
name: string;
|
|
9
10
|
title: string;
|
|
10
11
|
description: string;
|
|
@@ -17,7 +18,7 @@ export declare function terminateQurlSessionsTool(client: IQURLClient): {
|
|
|
17
18
|
session_id: z.ZodOptional<z.ZodString>;
|
|
18
19
|
terminated: z.ZodNumber;
|
|
19
20
|
message: z.ZodString;
|
|
20
|
-
}, z.core.$
|
|
21
|
+
}, z.core.$loose>;
|
|
21
22
|
annotations: {
|
|
22
23
|
title: string;
|
|
23
24
|
readOnlyHint: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminate-qurl-sessions.d.ts","sourceRoot":"","sources":["../../src/tools/terminate-qurl-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"terminate-qurl-sessions.d.ts","sourceRoot":"","sources":["../../src/tools/terminate-qurl-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,2BAA2B;;;iBAStC,CAAC;AAEH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,WAAW,EACnB,QAAQ,GAAE,kBAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgEjD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { QURLAPIError } from "../client.js";
|
|
3
|
-
import { resourceOnlyIdSchema, toStructuredContent, withMissingApiKeyHandler } from "./_shared.js";
|
|
3
|
+
import { resourceOnlyIdSchema, toStructuredContent, withMissingApiKeyHandler, } from "./_shared.js";
|
|
4
4
|
import { terminateQurlSessionsOutputSchema } from "./output-schemas.js";
|
|
5
5
|
export const terminateQurlSessionsSchema = z.object({
|
|
6
6
|
resource_id: resourceOnlyIdSchema("terminate sessions for"),
|
|
@@ -10,7 +10,7 @@ export const terminateQurlSessionsSchema = z.object({
|
|
|
10
10
|
.optional()
|
|
11
11
|
.describe("Specific session ID to terminate. Omit to terminate all active sessions for the resource."),
|
|
12
12
|
});
|
|
13
|
-
export function terminateQurlSessionsTool(client) {
|
|
13
|
+
export function terminateQurlSessionsTool(client, _runtime = { mode: "stdio" }) {
|
|
14
14
|
return {
|
|
15
15
|
name: "terminate_qurl_sessions",
|
|
16
16
|
title: "Terminate qURL Sessions",
|
|
@@ -35,7 +35,9 @@ export function terminateQurlSessionsTool(client) {
|
|
|
35
35
|
resource_id: input.resource_id,
|
|
36
36
|
session_id: input.session_id,
|
|
37
37
|
// The API returns 204 for a single session delete, so the tool
|
|
38
|
-
// synthesizes the count from the successful operation.
|
|
38
|
+
// synthesizes the count from the successful operation. This means
|
|
39
|
+
// `terminated: 1` confirms accepted idempotent deletion semantics;
|
|
40
|
+
// it cannot prove that the session still existed at request time.
|
|
39
41
|
terminated: 1,
|
|
40
42
|
message: `qURL session ${input.session_id} is terminated.`,
|
|
41
43
|
};
|
|
@@ -45,6 +47,8 @@ export function terminateQurlSessionsTool(client) {
|
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
const result = await client.terminateAllResourceSessions(input.resource_id);
|
|
50
|
+
// The typed client contract requires this count; retain a runtime guard
|
|
51
|
+
// because the SDK response is untrusted at the wire boundary.
|
|
48
52
|
const terminated = result.data?.terminated;
|
|
49
53
|
if (typeof terminated !== "number") {
|
|
50
54
|
throw new QURLAPIError(502, "invalid_response", "qURL API returned an invalid session termination response.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminate-qurl-sessions.js","sourceRoot":"","sources":["../../src/tools/terminate-qurl-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"terminate-qurl-sessions.js","sourceRoot":"","sources":["../../src/tools/terminate-qurl-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GAEzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,WAAW,EAAE,oBAAoB,CAAC,wBAAwB,CAAC;IAC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,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAC5E,wEAAwE;YACxE,8DAA8D;YAC9D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC;YAC3C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBACnC,MAAM,IAAI,YAAY,CACpB,GAAG,EACH,kBAAkB,EAClB,4DAA4D,CAC7D,CAAC;YACJ,CAAC;YAED,MAAM,OAAO,GAAG;gBACd,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,UAAU;gBACV,OAAO,EAAE,cAAc,UAAU,mBAAmB;aACrD,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnE,iBAAiB,EAAE,mBAAmB,CAAC,OAAO,CAAC;aAChD,CAAC;QACJ,CAAC,CACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { IQURLClient } from "../client.js";
|
|
3
|
+
import { type ToolRuntimeOptions } from "./_shared.js";
|
|
3
4
|
export declare const updateQurlTokenBaseSchema: z.ZodObject<{
|
|
4
5
|
resource_id: z.ZodString;
|
|
5
6
|
qurl_id: z.ZodString;
|
|
@@ -44,7 +45,7 @@ export declare const updateQurlTokenSchema: z.ZodObject<{
|
|
|
44
45
|
max_sessions: z.ZodOptional<z.ZodNumber>;
|
|
45
46
|
session_duration: z.ZodOptional<z.ZodString>;
|
|
46
47
|
}, z.core.$strip>;
|
|
47
|
-
export declare function updateQurlTokenTool(client: IQURLClient): {
|
|
48
|
+
export declare function updateQurlTokenTool(client: IQURLClient, _runtime?: ToolRuntimeOptions): {
|
|
48
49
|
name: string;
|
|
49
50
|
title: string;
|
|
50
51
|
description: string;
|
|
@@ -96,11 +97,11 @@ export declare function updateQurlTokenTool(client: IQURLClient): {
|
|
|
96
97
|
block_all: z.ZodOptional<z.ZodBoolean>;
|
|
97
98
|
deny_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
98
99
|
allow_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
-
}, z.core.$
|
|
100
|
-
}, z.core.$
|
|
100
|
+
}, z.core.$loose>>;
|
|
101
|
+
}, z.core.$loose>>;
|
|
101
102
|
created_at: z.ZodOptional<z.ZodString>;
|
|
102
103
|
expires_at: z.ZodOptional<z.ZodString>;
|
|
103
|
-
}, z.core.$
|
|
104
|
+
}, z.core.$loose>;
|
|
104
105
|
annotations: {
|
|
105
106
|
title: string;
|
|
106
107
|
readOnlyHint: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-qurl-token.d.ts","sourceRoot":"","sources":["../../src/tools/update-qurl-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"update-qurl-token.d.ts","sourceRoot":"","sources":["../../src/tools/update-qurl-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;iBA8BpC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;iBAgB/B,CAAC;AAEJ,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,QAAQ,GAAE,kBAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BjD"}
|
|
@@ -12,7 +12,7 @@ export const updateQurlTokenBaseSchema = z.object({
|
|
|
12
12
|
.describe('Duration to extend this token by (e.g., "24h", "7d"). Mutually exclusive with expires_at.'),
|
|
13
13
|
expires_at: z
|
|
14
14
|
.string()
|
|
15
|
-
.datetime()
|
|
15
|
+
.datetime({ offset: true })
|
|
16
16
|
.optional()
|
|
17
17
|
.describe("Absolute token expiration timestamp (RFC 3339). Mutually exclusive with extend_by."),
|
|
18
18
|
label: z.string().max(500).optional().describe("Human-readable label for this token"),
|
|
@@ -41,7 +41,7 @@ export const updateQurlTokenSchema = updateQurlTokenBaseSchema
|
|
|
41
41
|
data.session_duration !== undefined, {
|
|
42
42
|
message: "At least one update field (extend_by, expires_at, label, access_policy, max_sessions, or session_duration) is required",
|
|
43
43
|
});
|
|
44
|
-
export function updateQurlTokenTool(client) {
|
|
44
|
+
export function updateQurlTokenTool(client, _runtime = { mode: "stdio" }) {
|
|
45
45
|
return {
|
|
46
46
|
name: "update_qurl_token",
|
|
47
47
|
title: "Update qURL Token",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-qurl-token.js","sourceRoot":"","sources":["../../src/tools/update-qurl-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"update-qurl-token.js","sourceRoot":"","sources":["../../src/tools/update-qurl-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,mBAAm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AAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvE,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC;aACpD,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { IQURLClient } from "../client.js";
|
|
3
|
+
import { type ToolRuntimeOptions } from "./_shared.js";
|
|
3
4
|
export declare const updateQurlBaseSchema: z.ZodObject<{
|
|
4
5
|
resource_id: z.ZodString;
|
|
5
6
|
extend_by: z.ZodOptional<z.ZodString>;
|
|
@@ -18,7 +19,7 @@ export declare const updateQurlSchema: z.ZodObject<{
|
|
|
18
19
|
custom_domain: z.ZodOptional<z.ZodString>;
|
|
19
20
|
preserve_host: z.ZodOptional<z.ZodBoolean>;
|
|
20
21
|
}, z.core.$strip>;
|
|
21
|
-
export declare function updateQurlTool(client: IQURLClient): {
|
|
22
|
+
export declare function updateQurlTool(client: IQURLClient, _runtime?: ToolRuntimeOptions): {
|
|
22
23
|
name: string;
|
|
23
24
|
title: string;
|
|
24
25
|
description: string;
|
|
@@ -75,12 +76,12 @@ export declare function updateQurlTool(client: IQURLClient): {
|
|
|
75
76
|
block_all: z.ZodOptional<z.ZodBoolean>;
|
|
76
77
|
deny_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
78
|
allow_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
|
-
}, z.core.$
|
|
79
|
-
}, z.core.$
|
|
79
|
+
}, z.core.$loose>>;
|
|
80
|
+
}, z.core.$loose>>;
|
|
80
81
|
created_at: z.ZodOptional<z.ZodString>;
|
|
81
82
|
expires_at: z.ZodOptional<z.ZodString>;
|
|
82
|
-
}, z.core.$
|
|
83
|
-
}, z.core.$
|
|
83
|
+
}, z.core.$loose>>>;
|
|
84
|
+
}, z.core.$loose>;
|
|
84
85
|
annotations: {
|
|
85
86
|
title: string;
|
|
86
87
|
readOnlyHint: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-qurl.d.ts","sourceRoot":"","sources":["../../src/tools/update-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAwC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"update-qurl.d.ts","sourceRoot":"","sources":["../../src/tools/update-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAwC,MAAM,cAAc,CAAC;AACtF,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAetB,eAAO,MAAM,oBAAoB;;;;;;;;iBAqC/B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;iBA6B1B,CAAC;AAEJ,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,QAAQ,GAAE,kBAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CjD"}
|
|
@@ -18,7 +18,7 @@ export const updateQurlBaseSchema = z.object({
|
|
|
18
18
|
.describe('Duration to extend by (e.g., "24h", "7d"). Mutually exclusive with expires_at.'),
|
|
19
19
|
expires_at: z
|
|
20
20
|
.string()
|
|
21
|
-
.datetime()
|
|
21
|
+
.datetime({ offset: true })
|
|
22
22
|
.optional()
|
|
23
23
|
.describe("Absolute expiration timestamp (RFC 3339). Mutually exclusive with extend_by."),
|
|
24
24
|
tags: z
|
|
@@ -51,7 +51,7 @@ export const updateQurlSchema = updateQurlBaseSchema
|
|
|
51
51
|
message: "custom_domain and preserve_host use the resource endpoint and cannot be combined with extend_by or expires_at in one update",
|
|
52
52
|
})
|
|
53
53
|
.refine((data) => !(hasResourceEndpointUpdate(data) && data.resource_id.startsWith("q_")), {
|
|
54
|
-
message: "custom_domain and preserve_host updates require
|
|
54
|
+
message: "custom_domain and preserve_host updates require a resource identifier (public key, CRID, or legacy r_ ID)",
|
|
55
55
|
})
|
|
56
56
|
.refine(
|
|
57
57
|
// Use `!== undefined` rather than truthy checks so the API's "clear"
|
|
@@ -67,12 +67,12 @@ export const updateQurlSchema = updateQurlBaseSchema
|
|
|
67
67
|
data.preserve_host !== undefined, {
|
|
68
68
|
message: "At least one update field (extend_by, expires_at, tags, description, custom_domain, or preserve_host) is required",
|
|
69
69
|
});
|
|
70
|
-
export function updateQurlTool(client) {
|
|
70
|
+
export function updateQurlTool(client, _runtime = { mode: "stdio" }) {
|
|
71
71
|
return {
|
|
72
72
|
name: "update_qurl",
|
|
73
73
|
title: "Update qURL",
|
|
74
74
|
description: "Update a qURL's expiration, tags, description, custom domain, or proxy host-header behavior. The richer alternative to `extend_qurl` — use `update_qurl` whenever you need anything beyond a relative time push. " +
|
|
75
|
-
"Accepts
|
|
75
|
+
"Accepts resource public keys, CRIDs, legacy `r_` IDs, and `q_` display IDs for expiration, tags, and description updates (q_ is auto-resolved); custom domain and preserve_host updates require a resource identifier (public key, CRID, or legacy `r_` ID) because the qURL API now serves them from `PATCH /v1/resources/{id}`. " +
|
|
76
76
|
"**Constraints:** `extend_by` and `expires_at` are mutually exclusive; `custom_domain`/`preserve_host` cannot be combined with expiration changes in one call; at least one update field (`extend_by`, `expires_at`, `tags`, `description`, `custom_domain`, `preserve_host`) must be set. " +
|
|
77
77
|
'**Clearing fields:** pass `description: ""`, `tags: []`, or `custom_domain: ""` to clear those fields explicitly. ' +
|
|
78
78
|
"Use `extend_qurl` when the only change is a relative time push. " +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-qurl.js","sourceRoot":"","sources":["../../src/tools/update-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,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C9E,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { IQURLClient } from "../client.js";
|
|
3
|
+
import { type ToolRuntimeOptions } from "./_shared.js";
|
|
4
|
+
export declare function maxBase64CharactersForBytes(maxBytes: number): number;
|
|
5
|
+
export declare const MAX_UPLOAD_FILE_BASE64_CHARACTERS: number;
|
|
6
|
+
export declare function createUploadFileDataQurlSchema(maxBase64Characters?: number): z.ZodObject<{
|
|
7
|
+
file_base64: z.ZodString;
|
|
8
|
+
file_name: z.ZodString;
|
|
9
|
+
content_type: z.ZodEnum<{
|
|
10
|
+
"application/pdf": "application/pdf";
|
|
11
|
+
"image/gif": "image/gif";
|
|
12
|
+
"image/jpeg": "image/jpeg";
|
|
13
|
+
"image/png": "image/png";
|
|
14
|
+
"image/webp": "image/webp";
|
|
15
|
+
}>;
|
|
16
|
+
email_delivery: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
to: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodEmail>>;
|
|
18
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
19
|
+
message: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
label: z.ZodOptional<z.ZodString>;
|
|
22
|
+
expires_in: z.ZodOptional<z.ZodString>;
|
|
23
|
+
one_time_use: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
max_sessions: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
session_duration: z.ZodOptional<z.ZodString>;
|
|
26
|
+
access_policy: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
ip_allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
ip_denylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
geo_allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
+
geo_denylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
31
|
+
user_agent_allow_regex: z.ZodOptional<z.ZodString>;
|
|
32
|
+
user_agent_deny_regex: z.ZodOptional<z.ZodString>;
|
|
33
|
+
ai_agent_policy: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
block_all: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
deny_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
allow_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const uploadFileDataQurlSchema: z.ZodObject<{
|
|
41
|
+
file_base64: z.ZodString;
|
|
42
|
+
file_name: z.ZodString;
|
|
43
|
+
content_type: z.ZodEnum<{
|
|
44
|
+
"application/pdf": "application/pdf";
|
|
45
|
+
"image/gif": "image/gif";
|
|
46
|
+
"image/jpeg": "image/jpeg";
|
|
47
|
+
"image/png": "image/png";
|
|
48
|
+
"image/webp": "image/webp";
|
|
49
|
+
}>;
|
|
50
|
+
email_delivery: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
to: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodEmail>>;
|
|
52
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
53
|
+
message: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
label: z.ZodOptional<z.ZodString>;
|
|
56
|
+
expires_in: z.ZodOptional<z.ZodString>;
|
|
57
|
+
one_time_use: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
max_sessions: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
session_duration: z.ZodOptional<z.ZodString>;
|
|
60
|
+
access_policy: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
ip_allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
+
ip_denylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
geo_allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
geo_denylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
user_agent_allow_regex: z.ZodOptional<z.ZodString>;
|
|
66
|
+
user_agent_deny_regex: z.ZodOptional<z.ZodString>;
|
|
67
|
+
ai_agent_policy: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
block_all: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
deny_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
allow_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
}, z.core.$strip>>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export declare function uploadFileDataQurlTool(client: IQURLClient, runtime: ToolRuntimeOptions): {
|
|
75
|
+
name: string;
|
|
76
|
+
title: string;
|
|
77
|
+
description: string;
|
|
78
|
+
inputSchema: z.ZodObject<{
|
|
79
|
+
file_base64: z.ZodString;
|
|
80
|
+
file_name: z.ZodString;
|
|
81
|
+
content_type: z.ZodEnum<{
|
|
82
|
+
"application/pdf": "application/pdf";
|
|
83
|
+
"image/gif": "image/gif";
|
|
84
|
+
"image/jpeg": "image/jpeg";
|
|
85
|
+
"image/png": "image/png";
|
|
86
|
+
"image/webp": "image/webp";
|
|
87
|
+
}>;
|
|
88
|
+
email_delivery: z.ZodOptional<z.ZodObject<{
|
|
89
|
+
to: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodEmail>>;
|
|
90
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
91
|
+
message: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
label: z.ZodOptional<z.ZodString>;
|
|
94
|
+
expires_in: z.ZodOptional<z.ZodString>;
|
|
95
|
+
one_time_use: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
max_sessions: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
session_duration: z.ZodOptional<z.ZodString>;
|
|
98
|
+
access_policy: z.ZodOptional<z.ZodObject<{
|
|
99
|
+
ip_allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
100
|
+
ip_denylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
101
|
+
geo_allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
102
|
+
geo_denylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
103
|
+
user_agent_allow_regex: z.ZodOptional<z.ZodString>;
|
|
104
|
+
user_agent_deny_regex: z.ZodOptional<z.ZodString>;
|
|
105
|
+
ai_agent_policy: z.ZodOptional<z.ZodObject<{
|
|
106
|
+
block_all: z.ZodOptional<z.ZodBoolean>;
|
|
107
|
+
deny_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
108
|
+
allow_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
109
|
+
}, z.core.$strip>>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
outputSchema: z.ZodObject<{
|
|
113
|
+
resource_id: z.ZodString;
|
|
114
|
+
qurl_id: z.ZodString;
|
|
115
|
+
qurl_link: z.ZodString;
|
|
116
|
+
qurl_site: z.ZodOptional<z.ZodString>;
|
|
117
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
118
|
+
file_name: z.ZodString;
|
|
119
|
+
content_type: z.ZodString;
|
|
120
|
+
size_bytes: z.ZodNumber;
|
|
121
|
+
branded_domain: z.ZodOptional<z.ZodString>;
|
|
122
|
+
type: z.ZodOptional<z.ZodString>;
|
|
123
|
+
email_delivery: z.ZodOptional<z.ZodObject<{
|
|
124
|
+
attempted: z.ZodBoolean;
|
|
125
|
+
enabled: z.ZodBoolean;
|
|
126
|
+
recipients: z.ZodArray<z.ZodString>;
|
|
127
|
+
sent: z.ZodNumber;
|
|
128
|
+
failed: z.ZodNumber;
|
|
129
|
+
skipped_reason: z.ZodOptional<z.ZodString>;
|
|
130
|
+
results: z.ZodArray<z.ZodObject<{
|
|
131
|
+
email: z.ZodString;
|
|
132
|
+
success: z.ZodBoolean;
|
|
133
|
+
skipped: z.ZodBoolean;
|
|
134
|
+
error: z.ZodOptional<z.ZodString>;
|
|
135
|
+
message_id: z.ZodOptional<z.ZodString>;
|
|
136
|
+
}, z.core.$strip>>;
|
|
137
|
+
}, z.core.$strip>>;
|
|
138
|
+
}, z.core.$loose>;
|
|
139
|
+
annotations: {
|
|
140
|
+
title: string;
|
|
141
|
+
readOnlyHint: boolean;
|
|
142
|
+
destructiveHint: boolean;
|
|
143
|
+
idempotentHint: boolean;
|
|
144
|
+
openWorldHint: boolean;
|
|
145
|
+
};
|
|
146
|
+
handler: (input: {
|
|
147
|
+
file_base64: string;
|
|
148
|
+
file_name: string;
|
|
149
|
+
content_type: "application/pdf" | "image/gif" | "image/jpeg" | "image/png" | "image/webp";
|
|
150
|
+
email_delivery?: {
|
|
151
|
+
to: string[];
|
|
152
|
+
subject?: string | undefined;
|
|
153
|
+
message?: string | undefined;
|
|
154
|
+
} | undefined;
|
|
155
|
+
label?: string | undefined;
|
|
156
|
+
expires_in?: string | undefined;
|
|
157
|
+
one_time_use?: boolean | undefined;
|
|
158
|
+
max_sessions?: number | undefined;
|
|
159
|
+
session_duration?: string | undefined;
|
|
160
|
+
access_policy?: {
|
|
161
|
+
ip_allowlist?: string[] | undefined;
|
|
162
|
+
ip_denylist?: string[] | undefined;
|
|
163
|
+
geo_allowlist?: string[] | undefined;
|
|
164
|
+
geo_denylist?: string[] | undefined;
|
|
165
|
+
user_agent_allow_regex?: string | undefined;
|
|
166
|
+
user_agent_deny_regex?: string | undefined;
|
|
167
|
+
ai_agent_policy?: {
|
|
168
|
+
block_all?: boolean | undefined;
|
|
169
|
+
deny_categories?: string[] | undefined;
|
|
170
|
+
allow_categories?: string[] | undefined;
|
|
171
|
+
} | undefined;
|
|
172
|
+
} | undefined;
|
|
173
|
+
}) => Promise<{
|
|
174
|
+
content: Array<{
|
|
175
|
+
type: "text";
|
|
176
|
+
text: string;
|
|
177
|
+
}>;
|
|
178
|
+
structuredContent?: Record<string, unknown>;
|
|
179
|
+
isError?: boolean;
|
|
180
|
+
}>;
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=upload-file-data-qurl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-file-data-qurl.d.ts","sourceRoot":"","sources":["../../src/tools/upload-file-data-qurl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AA6BtB,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,eAAO,MAAM,iCAAiC,QAE7C,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,mBAAmB,SAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA8BxD;AAED,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAmC,CAAC;AA2HzE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8EtF"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { MAX_UPLOAD_FILE_DATA_BYTES } from "../config.js";
|
|
4
|
+
import { allowsServerApiKeyFallback, withMissingApiKeyHandler, } from "./_shared.js";
|
|
5
|
+
import { emailDeliveryInputSchema, maybeDeliverToolEmail, toEmailAugmentedResult, uploadEmailDetailLines, } from "./email-delivery.js";
|
|
6
|
+
import { getConnectorConfig, getMaxUploadFileBytes, mintUploadedFile, normalizeFileName, supportedMimeTypes, uploadToConnector, validateFileNameContentType, validateFileSignature, } from "./upload-file-shared.js";
|
|
7
|
+
import { uploadFileQurlOutputSchema } from "./output-schemas.js";
|
|
8
|
+
import { uploadMintOptionsShape } from "./upload-mint-options.js";
|
|
9
|
+
// Uploads pass three deliberate bounds: a runtime-derived raw-string schema
|
|
10
|
+
// ceiling, the HTTP JSON-body limit before tool dispatch, and
|
|
11
|
+
// getMaxUploadFileBytes on the normalized decoded payload. The exported schema
|
|
12
|
+
// uses the protocol-wide 100 MB hard maximum for direct consumers; registered
|
|
13
|
+
// tools advertise the operator's configured decoded-byte limit. HTTP only opens
|
|
14
|
+
// a parser ceiling above the 10 MB default for a session already validated by a
|
|
15
|
+
// successful downstream qURL API call (see createHttpRuntime).
|
|
16
|
+
const MAX_DATA_URL_PREFIX_CHARACTERS = 1024;
|
|
17
|
+
export function maxBase64CharactersForBytes(maxBytes) {
|
|
18
|
+
return Math.ceil((maxBytes * 4) / 3) + MAX_DATA_URL_PREFIX_CHARACTERS;
|
|
19
|
+
}
|
|
20
|
+
export const MAX_UPLOAD_FILE_BASE64_CHARACTERS = maxBase64CharactersForBytes(MAX_UPLOAD_FILE_DATA_BYTES);
|
|
21
|
+
export function createUploadFileDataQurlSchema(maxBase64Characters = MAX_UPLOAD_FILE_BASE64_CHARACTERS) {
|
|
22
|
+
return z
|
|
23
|
+
.object({
|
|
24
|
+
file_base64: z
|
|
25
|
+
.string()
|
|
26
|
+
.min(1)
|
|
27
|
+
.max(maxBase64Characters)
|
|
28
|
+
.describe("Base64-encoded PDF or raster image content. Raw base64 and data URLs are both accepted. For compressible images, compress them first and then convert them to base64 before calling this tool."),
|
|
29
|
+
file_name: z
|
|
30
|
+
.string()
|
|
31
|
+
.min(1)
|
|
32
|
+
.max(255)
|
|
33
|
+
.describe("Filename to register with the connector. `.jpg` and `.jpeg` files should use `image/jpeg`."),
|
|
34
|
+
content_type: z
|
|
35
|
+
.enum(supportedMimeTypes)
|
|
36
|
+
.describe("MIME type for the uploaded file. Supported: application/pdf, image/png, image/jpeg, image/webp, image/gif."),
|
|
37
|
+
email_delivery: emailDeliveryInputSchema
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("Optional email notification settings for sending the uploaded file's qURL to one or more recipients."),
|
|
40
|
+
})
|
|
41
|
+
.extend(uploadMintOptionsShape);
|
|
42
|
+
}
|
|
43
|
+
export const uploadFileDataQurlSchema = createUploadFileDataQurlSchema();
|
|
44
|
+
/**
|
|
45
|
+
* Normalize and validate base64 input for file upload.
|
|
46
|
+
*
|
|
47
|
+
* Accepts multiple input formats:
|
|
48
|
+
* - Raw base64: "SGVsbG8gV29ybGQ="
|
|
49
|
+
* - Data URL: "data:image/png;base64,iVBORw0KGgo..."
|
|
50
|
+
* - Base64 with whitespace (e.g., line breaks from copy-paste)
|
|
51
|
+
* - URL-safe base64 (uses - and _ instead of + and /)
|
|
52
|
+
*
|
|
53
|
+
* @param input - Raw base64 string or data URL
|
|
54
|
+
* @returns Normalized standard base64 and the data URL media type, when present
|
|
55
|
+
* @throws Error if input is empty or contains invalid base64 characters
|
|
56
|
+
*/
|
|
57
|
+
function normalizeBase64Input(input) {
|
|
58
|
+
const trimmed = input.trim();
|
|
59
|
+
if (!trimmed) {
|
|
60
|
+
throw new Error("file_base64 must not be empty");
|
|
61
|
+
}
|
|
62
|
+
// Step 1: Parse and strip the data URL prefix if present (e.g.,
|
|
63
|
+
// "data:image/png;base64,"). Return its media type so callers do not need
|
|
64
|
+
// to parse the same prefix again. Bound the regex probe independently of
|
|
65
|
+
// the payload ceiling so even a very large hostile string cannot make
|
|
66
|
+
// prefix parsing scale with the file body.
|
|
67
|
+
const dataUrlPrefixProbe = trimmed.slice(0, MAX_DATA_URL_PREFIX_CHARACTERS);
|
|
68
|
+
const dataUrl = /^data:([^;,]*)(?:;[a-z0-9!#$&^_.+-]+=[^;,\s]*)*;base64,/i.exec(dataUrlPrefixProbe);
|
|
69
|
+
if (!dataUrl && trimmed.toLowerCase().startsWith("data:")) {
|
|
70
|
+
throw new Error("Only base64-encoded data URLs are supported.");
|
|
71
|
+
}
|
|
72
|
+
const withoutDataUrl = dataUrl ? trimmed.slice(dataUrl[0].length) : trimmed;
|
|
73
|
+
// Step 2: Remove whitespace (base64 from copy-paste often has line breaks)
|
|
74
|
+
const withoutWhitespace = withoutDataUrl.replace(/\s+/g, "");
|
|
75
|
+
if (!withoutWhitespace) {
|
|
76
|
+
throw new Error("file_base64 must not be empty");
|
|
77
|
+
}
|
|
78
|
+
// Step 3: Accept either the standard or URL-safe alphabet, but reject a
|
|
79
|
+
// mixed alphabet because no conforming encoder emits that representation.
|
|
80
|
+
const usesStandardAlphabet = /^[A-Za-z0-9+/]*={0,2}$/.test(withoutWhitespace);
|
|
81
|
+
const usesUrlSafeAlphabet = !usesStandardAlphabet && /^[A-Za-z0-9_-]*={0,2}$/.test(withoutWhitespace);
|
|
82
|
+
if (!usesStandardAlphabet && !usesUrlSafeAlphabet) {
|
|
83
|
+
throw new Error("file_base64 must be valid base64-encoded content");
|
|
84
|
+
}
|
|
85
|
+
// Step 4: Convert URL-safe base64 to standard base64. URL-safe uses '-'
|
|
86
|
+
// instead of '+' and '_' instead of '/'.
|
|
87
|
+
const normalized = usesStandardAlphabet
|
|
88
|
+
? withoutWhitespace
|
|
89
|
+
: withoutWhitespace.replace(/-/g, "+").replace(/_/g, "/");
|
|
90
|
+
// Step 5: Validate and fix padding
|
|
91
|
+
// Base64 length must be divisible by 4. Valid lengths mod 4 are: 0, 2, 3
|
|
92
|
+
// Length mod 4 = 1 is always invalid (would represent 6 bits, not enough for a byte)
|
|
93
|
+
const paddingNeeded = normalized.length % 4;
|
|
94
|
+
if (paddingNeeded === 1) {
|
|
95
|
+
throw new Error("file_base64 must be valid base64-encoded content");
|
|
96
|
+
}
|
|
97
|
+
const dataUrlContentType = dataUrl?.[1] ? dataUrl[1].toLowerCase() : undefined;
|
|
98
|
+
// Already properly padded
|
|
99
|
+
if (paddingNeeded === 0) {
|
|
100
|
+
return { base64: normalized, dataUrlContentType };
|
|
101
|
+
}
|
|
102
|
+
// Add missing padding (mod 4 = 2 needs "==", mod 4 = 3 needs "=")
|
|
103
|
+
return {
|
|
104
|
+
base64: normalized.padEnd(normalized.length + (4 - paddingNeeded), "="),
|
|
105
|
+
dataUrlContentType,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function decodeBase64File(input, maxBytes, contentType) {
|
|
109
|
+
const tooLargeMessage = "Decoded file exceeds the allowed upload size. Reduce the file size and try again.";
|
|
110
|
+
const encodedCharacterLimit = Math.ceil((maxBytes * 4) / 3);
|
|
111
|
+
// Allow normal MIME line wrapping plus a bounded data-URL prefix, but reject
|
|
112
|
+
// runtime-oversized strings before trim/replace normalization copies them.
|
|
113
|
+
const rawCharacterLimit = encodedCharacterLimit + Math.ceil(encodedCharacterLimit / 4) + MAX_DATA_URL_PREFIX_CHARACTERS;
|
|
114
|
+
if (input.length > rawCharacterLimit) {
|
|
115
|
+
throw new Error(tooLargeMessage);
|
|
116
|
+
}
|
|
117
|
+
const normalized = normalizeBase64Input(input);
|
|
118
|
+
if (normalized.dataUrlContentType && normalized.dataUrlContentType !== contentType) {
|
|
119
|
+
throw new Error("Data URL media type does not match content_type.");
|
|
120
|
+
}
|
|
121
|
+
const paddingBytes = normalized.base64.endsWith("==")
|
|
122
|
+
? 2
|
|
123
|
+
: normalized.base64.endsWith("=")
|
|
124
|
+
? 1
|
|
125
|
+
: 0;
|
|
126
|
+
const decodedByteLength = (normalized.base64.length / 4) * 3 - paddingBytes;
|
|
127
|
+
if (decodedByteLength > maxBytes) {
|
|
128
|
+
throw new Error(tooLargeMessage);
|
|
129
|
+
}
|
|
130
|
+
const fileData = Buffer.from(normalized.base64, "base64");
|
|
131
|
+
if (fileData.byteLength === 0) {
|
|
132
|
+
throw new Error("file_base64 decoded to an empty file");
|
|
133
|
+
}
|
|
134
|
+
// Keep an actual-byte check after the pre-allocation estimate so decoder or
|
|
135
|
+
// normalization behavior cannot silently weaken the configured limit.
|
|
136
|
+
if (fileData.byteLength > maxBytes) {
|
|
137
|
+
throw new Error(tooLargeMessage);
|
|
138
|
+
}
|
|
139
|
+
validateFileSignature(fileData, contentType);
|
|
140
|
+
return fileData;
|
|
141
|
+
}
|
|
142
|
+
export function uploadFileDataQurlTool(client, runtime) {
|
|
143
|
+
const inputSchema = createUploadFileDataQurlSchema(runtime.maxUploadFileDataBytes === undefined
|
|
144
|
+
? MAX_UPLOAD_FILE_BASE64_CHARACTERS
|
|
145
|
+
: maxBase64CharactersForBytes(runtime.maxUploadFileDataBytes));
|
|
146
|
+
return {
|
|
147
|
+
name: "upload_file_data_qurl",
|
|
148
|
+
title: "Upload File Data qURL",
|
|
149
|
+
description: "Upload base64-encoded PDF or raster image content to a qURL connector, then mint an access link for it. " +
|
|
150
|
+
"This is the correct tool for a single in-chat image, PDF, or file attachment in either MCP transport, especially when the user wants 'the qURL of this image/file' or wants the generated link emailed. " +
|
|
151
|
+
"Use this when you have the file data available but cannot provide a server-local file path. " +
|
|
152
|
+
"Use `upload_file_qurl` when the file already exists on the MCP server host, use `create_qurl` when you already have a URL, and use `mint_link` when the file has already been uploaded and you only need another token. " +
|
|
153
|
+
"For compressible images, compress them before converting to base64 so the request is smaller and more reliable. " +
|
|
154
|
+
"When the server upload limit is configured above 10 MB, a fresh HTTP session must complete a smaller qURL API call before its first larger upload. " +
|
|
155
|
+
"The tool decodes `file_base64`, uploads the file to `${QURL_CONNECTOR_URL}/api/upload`, then mints a qURL from the returned `resource_id`. " +
|
|
156
|
+
"Supported MIME types are application/pdf, image/png, image/jpeg, image/webp, and image/gif. " +
|
|
157
|
+
"If `one_time_use` is omitted, the tool defaults it to `true` for safer file distribution. " +
|
|
158
|
+
"Requires `QURL_CONNECTOR_URL`; stdio reads `QURL_API_KEY` from server config, while HTTP uses the caller's bearer credential. " +
|
|
159
|
+
"**Returns:** `{ resource_id: string, qurl_id: string, qurl_link: string, qurl_site?: string, expires_at?: string, file_name: string, content_type: string, size_bytes: number, branded_domain?: string, type?: string, email_delivery?: object }`.",
|
|
160
|
+
inputSchema,
|
|
161
|
+
outputSchema: uploadFileQurlOutputSchema,
|
|
162
|
+
annotations: {
|
|
163
|
+
title: "Upload File Data qURL",
|
|
164
|
+
readOnlyHint: false,
|
|
165
|
+
destructiveHint: false,
|
|
166
|
+
idempotentHint: false,
|
|
167
|
+
openWorldHint: true,
|
|
168
|
+
},
|
|
169
|
+
handler: withMissingApiKeyHandler(async (input) => {
|
|
170
|
+
const allowServerApiKeyFallback = allowsServerApiKeyFallback(runtime);
|
|
171
|
+
// Preflight connector config before decoding payloads so auth/config errors fail fast.
|
|
172
|
+
const connectorConfig = getConnectorConfig(allowServerApiKeyFallback);
|
|
173
|
+
const fileName = normalizeFileName(input.file_name);
|
|
174
|
+
validateFileNameContentType(fileName, input.content_type);
|
|
175
|
+
const fileData = decodeBase64File(input.file_base64, getMaxUploadFileBytes(), input.content_type);
|
|
176
|
+
const upload = await uploadToConnector(fileData, fileName, input.content_type, connectorConfig);
|
|
177
|
+
const result = await mintUploadedFile(client, upload.resource_id, {
|
|
178
|
+
name: fileName,
|
|
179
|
+
contentType: input.content_type,
|
|
180
|
+
sizeBytes: fileData.byteLength,
|
|
181
|
+
}, input);
|
|
182
|
+
const emailResult = await maybeDeliverToolEmail({
|
|
183
|
+
allowServerApiKeyFallback,
|
|
184
|
+
delivery: input.email_delivery,
|
|
185
|
+
defaultSubject: "Your secure file access link is ready",
|
|
186
|
+
detailLines: uploadEmailDetailLines({
|
|
187
|
+
intro: "A secure qURL file link has been created for you.",
|
|
188
|
+
fileName,
|
|
189
|
+
contentType: input.content_type,
|
|
190
|
+
qurlLink: result.qurl_link,
|
|
191
|
+
expiresAt: result.expires_at,
|
|
192
|
+
qurlSite: result.qurl_site,
|
|
193
|
+
label: input.label,
|
|
194
|
+
}),
|
|
195
|
+
});
|
|
196
|
+
return toEmailAugmentedResult(result, emailResult);
|
|
197
|
+
}),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=upload-file-data-qurl.js.map
|