@layervai/qurl-mcp 0.4.1 → 0.6.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 +798 -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 +66 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +116 -7
- 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/prompts/audit-links.js +1 -1
- package/dist/prompts/audit-links.js.map +1 -1
- package/dist/server.d.ts +14 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +38 -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 +10 -1
- package/dist/tools/_shared.d.ts.map +1 -1
- package/dist/tools/_shared.js +25 -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/consumer-access.d.ts +235 -0
- package/dist/tools/consumer-access.d.ts.map +1 -0
- package/dist/tools/consumer-access.js +231 -0
- package/dist/tools/consumer-access.js.map +1 -0
- 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 +69 -32
- 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 +9 -13
- package/dist/tools/delete-qurl.js.map +1 -1
- package/dist/tools/duration.d.ts +13 -0
- package/dist/tools/duration.d.ts.map +1 -0
- package/dist/tools/duration.js +71 -0
- package/dist/tools/duration.js.map +1 -0
- package/dist/tools/email-delivery.d.ts +36 -0
- package/dist/tools/email-delivery.d.ts.map +1 -0
- package/dist/tools/email-delivery.js +114 -0
- package/dist/tools/email-delivery.js.map +1 -0
- package/dist/tools/extend-qurl.d.ts +20 -6
- package/dist/tools/extend-qurl.d.ts.map +1 -1
- package/dist/tools/extend-qurl.js +180 -19
- package/dist/tools/extend-qurl.js.map +1 -1
- package/dist/tools/get-qurl.d.ts +13 -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 +15 -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 +26 -14
- package/dist/tools/mint-link.js.map +1 -1
- package/dist/tools/output-schemas.d.ts +154 -45
- package/dist/tools/output-schemas.d.ts.map +1 -1
- package/dist/tools/output-schemas.js +106 -30
- 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/share-by-crid.d.ts +50 -0
- package/dist/tools/share-by-crid.d.ts.map +1 -0
- package/dist/tools/share-by-crid.js +114 -0
- package/dist/tools/share-by-crid.js.map +1 -0
- 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 +8 -9
- package/dist/tools/update-qurl-token.js.map +1 -1
- package/dist/tools/update-qurl.d.ts +13 -5
- package/dist/tools/update-qurl.d.ts.map +1 -1
- package/dist/tools/update-qurl.js +10 -11
- package/dist/tools/update-qurl.js.map +1 -1
- package/dist/tools/upload-file-data-qurl.d.ts +138 -0
- package/dist/tools/upload-file-data-qurl.d.ts.map +1 -0
- package/dist/tools/upload-file-data-qurl.js +207 -0
- package/dist/tools/upload-file-data-qurl.js.map +1 -0
- package/dist/tools/upload-file-qurl.d.ts +134 -0
- package/dist/tools/upload-file-qurl.d.ts.map +1 -0
- package/dist/tools/upload-file-qurl.js +174 -0
- package/dist/tools/upload-file-qurl.js.map +1 -0
- package/dist/tools/upload-file-shared.d.ts +53 -0
- package/dist/tools/upload-file-shared.d.ts.map +1 -0
- package/dist/tools/upload-file-shared.js +617 -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 +47 -0
- package/dist/tools/upload-mint-options.js.map +1 -0
- package/dist/tools/upload-text-qurl.d.ts +112 -0
- package/dist/tools/upload-text-qurl.d.ts.map +1 -0
- package/dist/tools/upload-text-qurl.js +106 -0
- package/dist/tools/upload-text-qurl.js.map +1 -0
- package/package.json +26 -8
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { IQURLClient } from "../client.js";
|
|
3
|
+
import { type ToolRuntimeOptions } from "./_shared.js";
|
|
4
|
+
export declare const MAX_ACCESS_POLICY_IP_ITEMS = 100;
|
|
5
|
+
export declare const MAX_ACCESS_POLICY_GEO_ITEMS = 50;
|
|
6
|
+
export declare const MAX_AI_AGENT_CATEGORY_ITEMS = 20;
|
|
7
|
+
export declare const MAX_ACCESS_POLICY_IP_CHARACTERS = 64;
|
|
8
|
+
export declare const MAX_ACCESS_POLICY_GEO_CHARACTERS = 8;
|
|
9
|
+
export declare const MAX_AI_AGENT_CATEGORY_CHARACTERS = 128;
|
|
10
|
+
export declare const MAX_RESOURCE_TYPE_CHARACTERS = 64;
|
|
3
11
|
export declare const aiAgentPolicySchema: z.ZodObject<{
|
|
4
12
|
block_all: z.ZodOptional<z.ZodBoolean>;
|
|
5
13
|
deny_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
14
|
allow_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
15
|
}, z.core.$strip>;
|
|
16
|
+
export declare const MAX_USER_AGENT_REGEX_CHARACTERS = 256;
|
|
8
17
|
export declare const accessPolicySchema: z.ZodObject<{
|
|
9
18
|
ip_allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
19
|
ip_denylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -40,8 +49,13 @@ export declare const createQurlSchema: z.ZodObject<{
|
|
|
40
49
|
allow_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
50
|
}, z.core.$strip>>;
|
|
42
51
|
}, z.core.$strip>>;
|
|
52
|
+
email_delivery: z.ZodOptional<z.ZodObject<{
|
|
53
|
+
to: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodEmail>>;
|
|
54
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
55
|
+
message: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
43
57
|
}, z.core.$strip>;
|
|
44
|
-
export declare function createQurlTool(client: IQURLClient): {
|
|
58
|
+
export declare function createQurlTool(client: IQURLClient, runtime: ToolRuntimeOptions): {
|
|
45
59
|
name: string;
|
|
46
60
|
title: string;
|
|
47
61
|
description: string;
|
|
@@ -67,17 +81,37 @@ export declare function createQurlTool(client: IQURLClient): {
|
|
|
67
81
|
allow_categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
82
|
}, z.core.$strip>>;
|
|
69
83
|
}, z.core.$strip>>;
|
|
84
|
+
email_delivery: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
to: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodEmail>>;
|
|
86
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
87
|
+
message: z.ZodOptional<z.ZodString>;
|
|
88
|
+
}, z.core.$strip>>;
|
|
70
89
|
}, z.core.$strip>;
|
|
71
90
|
outputSchema: z.ZodObject<{
|
|
72
91
|
qurl_id: z.ZodString;
|
|
73
92
|
resource_id: z.ZodString;
|
|
74
93
|
qurl_link: z.ZodString;
|
|
75
94
|
branded_domain: z.ZodOptional<z.ZodString>;
|
|
76
|
-
qurl_site: z.ZodString
|
|
77
|
-
expires_at: z.ZodString
|
|
95
|
+
qurl_site: z.ZodOptional<z.ZodString>;
|
|
96
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
78
97
|
label: z.ZodOptional<z.ZodString>;
|
|
79
98
|
type: z.ZodOptional<z.ZodString>;
|
|
80
|
-
|
|
99
|
+
email_delivery: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
attempted: z.ZodBoolean;
|
|
101
|
+
enabled: z.ZodBoolean;
|
|
102
|
+
recipients: z.ZodArray<z.ZodString>;
|
|
103
|
+
sent: z.ZodNumber;
|
|
104
|
+
failed: z.ZodNumber;
|
|
105
|
+
skipped_reason: z.ZodOptional<z.ZodString>;
|
|
106
|
+
results: z.ZodArray<z.ZodObject<{
|
|
107
|
+
email: z.ZodString;
|
|
108
|
+
success: z.ZodBoolean;
|
|
109
|
+
skipped: z.ZodBoolean;
|
|
110
|
+
error: z.ZodOptional<z.ZodString>;
|
|
111
|
+
message_id: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>>;
|
|
113
|
+
}, z.core.$strip>>;
|
|
114
|
+
}, z.core.$loose>;
|
|
81
115
|
annotations: {
|
|
82
116
|
title: string;
|
|
83
117
|
readOnlyHint: boolean;
|
|
@@ -107,6 +141,11 @@ export declare function createQurlTool(client: IQURLClient): {
|
|
|
107
141
|
allow_categories?: string[] | undefined;
|
|
108
142
|
} | undefined;
|
|
109
143
|
} | undefined;
|
|
144
|
+
email_delivery?: {
|
|
145
|
+
to: string[];
|
|
146
|
+
subject?: string | undefined;
|
|
147
|
+
message?: string | undefined;
|
|
148
|
+
} | undefined;
|
|
110
149
|
}) => Promise<{
|
|
111
150
|
content: Array<{
|
|
112
151
|
type: "text";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-qurl.d.ts","sourceRoot":"","sources":["../../src/tools/create-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"create-qurl.d.ts","sourceRoot":"","sources":["../../src/tools/create-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAStB,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAClD,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAClD,eAAO,MAAM,gCAAgC,MAAM,CAAC;AACpD,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAI/C,eAAO,MAAM,mBAAmB;;;;iBAkB9B,CAAC;AAEH,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAGnD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;iBAgC7B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkD3B,CAAC;AAEH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsD9E"}
|
|
@@ -1,44 +1,64 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { allowsServerApiKeyFallback, withMissingApiKeyHandler, } from "./_shared.js";
|
|
3
|
+
import { emailDeliveryInputSchema, maybeDeliverToolEmail, singleLineEmailDetail, toEmailAugmentedResult, } from "./email-delivery.js";
|
|
3
4
|
import { createQurlOutputSchema } from "./output-schemas.js";
|
|
5
|
+
export const MAX_ACCESS_POLICY_IP_ITEMS = 100;
|
|
6
|
+
export const MAX_ACCESS_POLICY_GEO_ITEMS = 50;
|
|
7
|
+
export const MAX_AI_AGENT_CATEGORY_ITEMS = 20;
|
|
8
|
+
export const MAX_ACCESS_POLICY_IP_CHARACTERS = 64;
|
|
9
|
+
export const MAX_ACCESS_POLICY_GEO_CHARACTERS = 8;
|
|
10
|
+
export const MAX_AI_AGENT_CATEGORY_CHARACTERS = 128;
|
|
11
|
+
export const MAX_RESOURCE_TYPE_CHARACTERS = 64;
|
|
12
|
+
const boundedPolicyList = (item, limit) => z.array(item).max(limit);
|
|
4
13
|
export const aiAgentPolicySchema = z.object({
|
|
5
14
|
block_all: z.boolean().optional().describe("Block all recognized AI agents"),
|
|
6
|
-
deny_categories: z
|
|
7
|
-
.array(z.string())
|
|
15
|
+
deny_categories: boundedPolicyList(z.string().min(1).max(MAX_AI_AGENT_CATEGORY_CHARACTERS), MAX_AI_AGENT_CATEGORY_ITEMS)
|
|
8
16
|
.optional()
|
|
9
|
-
.describe(
|
|
10
|
-
allow_categories: z
|
|
11
|
-
.array(z.string())
|
|
17
|
+
.describe(`AI agent categories to block (e.g., gptbot, commoncrawl; max ${MAX_AI_AGENT_CATEGORY_ITEMS} entries, ${MAX_AI_AGENT_CATEGORY_CHARACTERS} chars each)`),
|
|
18
|
+
allow_categories: boundedPolicyList(z.string().min(1).max(MAX_AI_AGENT_CATEGORY_CHARACTERS), MAX_AI_AGENT_CATEGORY_ITEMS)
|
|
12
19
|
.optional()
|
|
13
|
-
.describe(
|
|
20
|
+
.describe(`AI agent categories to permit (all others blocked; max ${MAX_AI_AGENT_CATEGORY_ITEMS} entries, ${MAX_AI_AGENT_CATEGORY_CHARACTERS} chars each)`),
|
|
14
21
|
});
|
|
22
|
+
export const MAX_USER_AGENT_REGEX_CHARACTERS = 256;
|
|
23
|
+
const userAgentRegexSchema = z.string().max(MAX_USER_AGENT_REGEX_CHARACTERS);
|
|
15
24
|
export const accessPolicySchema = z.object({
|
|
16
|
-
ip_allowlist:
|
|
17
|
-
ip_denylist: z.array(z.string()).optional().describe("Denied IP addresses or CIDR ranges"),
|
|
18
|
-
geo_allowlist: z
|
|
19
|
-
.array(z.string())
|
|
25
|
+
ip_allowlist: boundedPolicyList(z.string().min(1).max(MAX_ACCESS_POLICY_IP_CHARACTERS), MAX_ACCESS_POLICY_IP_ITEMS)
|
|
20
26
|
.optional()
|
|
21
|
-
.describe("Allowed
|
|
22
|
-
|
|
23
|
-
.array(z.string())
|
|
27
|
+
.describe("Allowed IP addresses or CIDR ranges (max 100 entries, 64 chars each)"),
|
|
28
|
+
ip_denylist: boundedPolicyList(z.string().min(1).max(MAX_ACCESS_POLICY_IP_CHARACTERS), MAX_ACCESS_POLICY_IP_ITEMS)
|
|
24
29
|
.optional()
|
|
25
|
-
.describe("Denied
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
.describe("Denied IP addresses or CIDR ranges (max 100 entries, 64 chars each)"),
|
|
31
|
+
geo_allowlist: boundedPolicyList(z.string().min(1).max(MAX_ACCESS_POLICY_GEO_CHARACTERS), MAX_ACCESS_POLICY_GEO_ITEMS)
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Allowed country codes (ISO 3166-1 alpha-2; max 50 entries, 8 chars each)"),
|
|
34
|
+
geo_denylist: boundedPolicyList(z.string().min(1).max(MAX_ACCESS_POLICY_GEO_CHARACTERS), MAX_ACCESS_POLICY_GEO_ITEMS)
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Denied country codes (ISO 3166-1 alpha-2; max 50 entries, 8 chars each)"),
|
|
37
|
+
user_agent_allow_regex: userAgentRegexSchema
|
|
38
|
+
.optional()
|
|
39
|
+
.describe(`Regex to allow matching user agents (max ${MAX_USER_AGENT_REGEX_CHARACTERS} chars)`),
|
|
40
|
+
user_agent_deny_regex: userAgentRegexSchema
|
|
41
|
+
.optional()
|
|
42
|
+
.describe(`Regex to deny matching user agents (max ${MAX_USER_AGENT_REGEX_CHARACTERS} chars)`),
|
|
28
43
|
ai_agent_policy: aiAgentPolicySchema.optional().describe("Structured AI agent access control"),
|
|
29
44
|
});
|
|
30
45
|
export const createQurlSchema = z.object({
|
|
31
46
|
type: z
|
|
32
47
|
.string()
|
|
48
|
+
.max(MAX_RESOURCE_TYPE_CHARACTERS)
|
|
33
49
|
.optional()
|
|
34
|
-
.describe(
|
|
50
|
+
.describe(`Resource type for integrations allowed to mint non-url qURLs (max ${MAX_RESOURCE_TYPE_CHARACTERS} chars). Defaults to url.`),
|
|
35
51
|
target_url: z.string().url().describe("The URL to protect with qURL"),
|
|
36
52
|
label: z
|
|
37
53
|
.string()
|
|
38
54
|
.max(500)
|
|
39
55
|
.optional()
|
|
40
56
|
.describe("Human-readable label identifying who this qURL is for (max 500 chars)"),
|
|
41
|
-
expires_in: z
|
|
57
|
+
expires_in: z
|
|
58
|
+
.string()
|
|
59
|
+
.min(1)
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('Duration string (e.g., "1h", "24h", "7d"; the API enforces 1m to 30d)'),
|
|
42
62
|
one_time_use: z.boolean().optional().describe("Whether the link can only be used once"),
|
|
43
63
|
max_sessions: z
|
|
44
64
|
.number()
|
|
@@ -59,22 +79,27 @@ export const createQurlSchema = z.object({
|
|
|
59
79
|
.optional()
|
|
60
80
|
.describe("Custom domain to assign to the auto-created resource (max 253 chars, must be registered/active/owned)."),
|
|
61
81
|
access_policy: accessPolicySchema.optional().describe("Access control policy for the qURL"),
|
|
82
|
+
email_delivery: emailDeliveryInputSchema
|
|
83
|
+
.optional()
|
|
84
|
+
.describe("Optional email notification settings for sending the generated qURL to one or more recipients."),
|
|
62
85
|
});
|
|
63
|
-
export function createQurlTool(client) {
|
|
86
|
+
export function createQurlTool(client, runtime) {
|
|
64
87
|
return {
|
|
65
88
|
name: "create_qurl",
|
|
66
89
|
title: "Create qURL",
|
|
67
90
|
description: "Create a qURL — a policy-bound, expiring access link that gates a target URL with optional IP/geo/UA/AI-agent filters and time or session limits. " +
|
|
68
91
|
"**When to use:** minting a fresh protected access link for share-once or time-limited access (e.g. send a customer a 24-hour download link, gate a doc behind an IP allowlist, distribute a one-time-use credential to a contractor). " +
|
|
69
|
-
"**
|
|
92
|
+
"**Do NOT use this for chat-uploaded images, PDFs, screenshots, or file attachments.** In HTTP MCP mode, those should go through `upload_file_data_qurl`; in stdio mode, use `upload_file_qurl`. " +
|
|
93
|
+
"**When NOT to use:** use `mint_link` when you already have a resource identifier and just need an additional access token under it — `create_qurl` identifies the resource by target URL and may return an existing same-type resource grouping. " +
|
|
70
94
|
"Use `batch_create_qurls` to create many in one round-trip. " +
|
|
71
95
|
"Use `update_qurl` to retag or extend an existing resource without minting a new one. " +
|
|
96
|
+
"If the user says 'give me the qURL of this image/file' and the content was uploaded in chat, this is the wrong tool. " +
|
|
72
97
|
"**Behavior:** not idempotent — calling twice produces two distinct qURL tokens, though both may share the same `resource_id` when the target URL groups to an existing same-type resource (this tool doesn't surface the underlying API's `Idempotency-Key` header). " +
|
|
73
98
|
"The returned `qurl_link` is shown ONCE in this response and is never recoverable through `get_qurl` or `list_qurls`; persist or share it immediately. " +
|
|
74
99
|
"A returned resource is in `active` status with the policy and per-token limits applied. " +
|
|
75
|
-
"
|
|
100
|
+
"Set `expires_in` explicitly for a predictable lifetime; otherwise the service uses its defaults. Read `expires_at` in the response. " +
|
|
76
101
|
"`max_sessions` is per minted qURL, not resource-wide; set `one_time_use: false` explicitly when you need `max_sessions: 0` to mean unlimited visitors. " +
|
|
77
|
-
"**Returns:** `{ qurl_id: string (q_…), resource_id: string
|
|
102
|
+
"**Returns:** `{ qurl_id: string (q_…), resource_id: string, qurl_link: string (shown once), branded_domain?: string, qurl_site: string, expires_at: string (RFC 3339), label?: string, type?: string }`. " +
|
|
78
103
|
"`qurl_id` is the only `q_…` display ID an agent gets in this response — keep it if you plan a follow-up against `get_qurl`/`update_qurl`/`mint_link` (which accept either prefix). " +
|
|
79
104
|
"Example: `create_qurl({ target_url: 'https://example.com/private', expires_in: '24h', one_time_use: true, access_policy: { geo_allowlist: ['US'] } })`.",
|
|
80
105
|
inputSchema: createQurlSchema,
|
|
@@ -87,16 +112,28 @@ export function createQurlTool(client) {
|
|
|
87
112
|
openWorldHint: true,
|
|
88
113
|
},
|
|
89
114
|
handler: withMissingApiKeyHandler(async (input) => {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
115
|
+
const { email_delivery, ...createInput } = input;
|
|
116
|
+
const result = await client.createQURL(createInput);
|
|
117
|
+
const emailResult = await maybeDeliverToolEmail({
|
|
118
|
+
allowServerApiKeyFallback: allowsServerApiKeyFallback(runtime),
|
|
119
|
+
delivery: email_delivery,
|
|
120
|
+
defaultSubject: "Your secure qURL link is ready",
|
|
121
|
+
detailLines: [
|
|
122
|
+
"A secure qURL link has been created for you.",
|
|
123
|
+
`Secure Link: ${singleLineEmailDetail(result.data.qurl_link)}`,
|
|
124
|
+
// The SDK type requires expires_at; keep the guard so upstream
|
|
125
|
+
// response drift cannot render "undefined" into a customer email.
|
|
126
|
+
...(result.data.expires_at
|
|
127
|
+
? [`Expires At: ${singleLineEmailDetail(result.data.expires_at)}`]
|
|
128
|
+
: []),
|
|
129
|
+
...(result.data.qurl_site
|
|
130
|
+
? [`qURL Site: ${singleLineEmailDetail(result.data.qurl_site)}`]
|
|
131
|
+
: []),
|
|
132
|
+
...(result.data.label ? [`Label: ${singleLineEmailDetail(result.data.label)}`] : []),
|
|
133
|
+
...(result.data.type ? [`Type: ${singleLineEmailDetail(result.data.type)}`] : []),
|
|
97
134
|
],
|
|
98
|
-
|
|
99
|
-
|
|
135
|
+
});
|
|
136
|
+
return toEmailAugmentedResult(result.data, emailResult);
|
|
100
137
|
}),
|
|
101
138
|
};
|
|
102
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-qurl.js","sourceRoot":"","sources":["../../src/tools/create-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,
|
|
1
|
+
{"version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CAAC,SAAS,CAAC,EAAE;oBAC9D,+DAA+D;oBAC/D,kEAAkE;oBAClE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU;wBACxB,CAAC,CAAC,CAAC,eAAe,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;wBAClE,CAAC,CAAC,EAAE,CAAC;oBACP,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;wBACvB,CAAC,CAAC,CAAC,cAAc,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;wBAChE,CAAC,CAAC,EAAE,CAAC;oBACP,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACpF,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBAClF;aACF,CAAC,CAAC;YACH,OAAO,sBAAsB,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC1D,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
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 deleteQurlSchema: z.ZodObject<{
|
|
4
5
|
resource_id: z.ZodString;
|
|
5
6
|
}, z.core.$strip>;
|
|
6
|
-
export declare function deleteQurlTool(client: IQURLClient): {
|
|
7
|
+
export declare function deleteQurlTool(client: IQURLClient, _runtime?: ToolRuntimeOptions): {
|
|
7
8
|
name: string;
|
|
8
9
|
title: string;
|
|
9
10
|
description: string;
|
|
@@ -15,7 +16,7 @@ export declare function deleteQurlTool(client: IQURLClient): {
|
|
|
15
16
|
revoked: z.ZodLiteral<true>;
|
|
16
17
|
was_already_revoked: z.ZodBoolean;
|
|
17
18
|
message: z.ZodString;
|
|
18
|
-
}, z.core.$
|
|
19
|
+
}, z.core.$loose>;
|
|
19
20
|
annotations: {
|
|
20
21
|
title: string;
|
|
21
22
|
readOnlyHint: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-qurl.d.ts","sourceRoot":"","sources":["../../src/tools/delete-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"delete-qurl.d.ts","sourceRoot":"","sources":["../../src/tools/delete-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAQtB,eAAO,MAAM,gBAAgB;;iBAE3B,CAAC;AAEH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,QAAQ,GAAE,kBAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEjD"}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { QURLAPIError } from "../client.js";
|
|
3
|
-
import { withMissingApiKeyHandler } from "./_shared.js";
|
|
3
|
+
import { resourceOnlyIdSchema, withMissingApiKeyHandler, } from "./_shared.js";
|
|
4
4
|
import { deleteQurlOutputSchema } from "./output-schemas.js";
|
|
5
|
+
// Upload links live on the connector's resource, so revoking this one leaves
|
|
6
|
+
// them serving (#281). Said in the result, which agents relay to the user.
|
|
7
|
+
const UPLOAD_LINKS_NOTE = "Links minted by the upload tools are served by the file connector and are not affected.";
|
|
5
8
|
export const deleteQurlSchema = z.object({
|
|
6
|
-
|
|
7
|
-
// get/update/extend/mint_link which also accept q_ prefixes. Reject
|
|
8
|
-
// non-r_ IDs at the schema boundary so agents get a clear error
|
|
9
|
-
// instead of a confusing API-side rejection.
|
|
10
|
-
resource_id: z
|
|
11
|
-
.string()
|
|
12
|
-
.regex(/^r_[a-z0-9_-]{11}$/, "delete_qurl only accepts resource IDs (r_ prefix). Use update_qurl or mint_link for q_ IDs.")
|
|
13
|
-
.describe("The resource ID (r_ prefix). delete_qurl does not accept q_ (qURL display) IDs."),
|
|
9
|
+
resource_id: resourceOnlyIdSchema("revoke (all tokens; q_ display IDs are not accepted)"),
|
|
14
10
|
});
|
|
15
|
-
export function deleteQurlTool(client) {
|
|
11
|
+
export function deleteQurlTool(client, _runtime = { mode: "stdio" }) {
|
|
16
12
|
return {
|
|
17
13
|
name: "delete_qurl",
|
|
18
14
|
title: "Delete qURL",
|
|
19
15
|
description: "Permanently revoke a qURL — the link and every access token under it stop working immediately. " +
|
|
20
16
|
"**This action is irreversible.** Use this when you want to cut off access entirely (compromised link, departed user, end-of-engagement). " +
|
|
21
|
-
"
|
|
22
|
-
"Use `
|
|
17
|
+
"It does not revoke links minted by the upload tools, which belong to the file connector; those cannot be revoked from this server. " +
|
|
18
|
+
"Use `update_qurl` instead when you only need to shorten the resource's expiration, retag, or rename, and `extend_qurl` to keep a link open longer — those preserve the existing access tokens. " +
|
|
23
19
|
"**Idempotent:** the API returns 404 for re-deletes, never-existed IDs, and resources owned by another API key (ownership-mismatch is collapsed into 404 server-side to avoid existence disclosure); this tool swallows all three. " +
|
|
24
20
|
"Branch on `was_already_revoked` to distinguish the no-op case from a successful revoke on this call. " +
|
|
25
21
|
"When the ID came from user input and ownership matters, call `get_qurl` first — a 200 confirms ownership; a thrown 404 is equally ambiguous on that endpoint too. " +
|
|
@@ -72,7 +68,7 @@ export function deleteQurlTool(client) {
|
|
|
72
68
|
resource_id: input.resource_id,
|
|
73
69
|
revoked: true,
|
|
74
70
|
was_already_revoked: wasAlreadyRevoked,
|
|
75
|
-
message: `qURL ${input.resource_id} is revoked
|
|
71
|
+
message: `qURL ${input.resource_id} is revoked. ${UPLOAD_LINKS_NOTE}`,
|
|
76
72
|
};
|
|
77
73
|
return {
|
|
78
74
|
content: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-qurl.js","sourceRoot":"","sources":["../../src/tools/delete-qurl.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":"delete-qurl.js","sourceRoot":"","sources":["../../src/tools/delete-qurl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,6EAA6E;AAC7E,2EAA2E;AAC3E,MAAM,iBAAiB,GACrB,yFAAyF,CAAC;AAE5F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,WAAW,EAAE,oBAAoB,CAAC,sDAAsD,CAAC;CAC1F,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,WAA+B,EAAE,IAAI,EAAE,OAAO,EAAE;IAEhD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,aAAa;QACpB,WAAW,EACT,iGAAiG;YACjG,2IAA2I;YAC3I,qIAAqI;YACrI,iMAAiM;YACjM,oOAAoO;YACpO,uGAAuG;YACvG,oKA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BACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,OAAO,CAAC,OAAO;qBACtB;iBACF;gBACD,iBAAiB,EAAE,OAAO;aAC3B,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Milliseconds in a duration string, or undefined when the grammar rejects it.
|
|
4
|
+
* Fractions are Go-duration only ("1.5h"); whole days/weeks are integers
|
|
5
|
+
* ("1.5d" is rejected), matching ParseDuration's strconv.Atoi branch.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseDurationMs(value: string): number | undefined;
|
|
8
|
+
export declare const durationSchema: (minMs: number, maxMs: number, range: string, allowEmpty?: boolean) => z.ZodString;
|
|
9
|
+
export declare const MIN_EXPIRY_MS = 60000;
|
|
10
|
+
export declare const MAX_EXPIRY_MS: number;
|
|
11
|
+
export declare const MIN_SESSION_MS = 1000;
|
|
12
|
+
export declare const MAX_SESSION_MS = 86400000;
|
|
13
|
+
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/tools/duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASjE;AAYD,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,oBAAkB,gBAgBzF,CAAC;AAMN,eAAO,MAAM,aAAa,QAAS,CAAC;AAGpC,eAAO,MAAM,aAAa,QAAkB,CAAC;AAK7C,eAAO,MAAM,cAAc,OAAQ,CAAC;AACpC,eAAO,MAAM,cAAc,WAAa,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Accepts a safe subset of qurl-service's duration grammar (no sign, leading
|
|
3
|
+
// dot, or U+03BC mu): whole days/weeks ("7d", "1w") or a
|
|
4
|
+
// Go duration ("30m", "1h30m", "1.5h"). Each repetition must end in a unit,
|
|
5
|
+
// so matching is linear; durationSchema's .max(32) bounds the input as well.
|
|
6
|
+
const DURATION_PATTERN = /^(?:\d+[dw]|(?:\d+(?:\.\d+)?(?:ns|us|µs|ms|s|m|h))+)$/;
|
|
7
|
+
// Nanoseconds per unit, so sub-millisecond units sum exactly before one division.
|
|
8
|
+
const GO_DURATION_UNIT_NS = {
|
|
9
|
+
ns: 1,
|
|
10
|
+
us: 1e3,
|
|
11
|
+
µs: 1e3,
|
|
12
|
+
ms: 1e6,
|
|
13
|
+
s: 1e9,
|
|
14
|
+
m: 6e10,
|
|
15
|
+
h: 3.6e12,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Milliseconds in a duration string, or undefined when the grammar rejects it.
|
|
19
|
+
* Fractions are Go-duration only ("1.5h"); whole days/weeks are integers
|
|
20
|
+
* ("1.5d" is rejected), matching ParseDuration's strconv.Atoi branch.
|
|
21
|
+
*/
|
|
22
|
+
export function parseDurationMs(value) {
|
|
23
|
+
if (!DURATION_PATTERN.test(value))
|
|
24
|
+
return undefined;
|
|
25
|
+
const whole = /^(\d+)([dw])$/.exec(value);
|
|
26
|
+
if (whole)
|
|
27
|
+
return Number(whole[1]) * (whole[2] === "d" ? 86_400_000 : 604_800_000);
|
|
28
|
+
let totalNs = 0;
|
|
29
|
+
for (const [, amount, unit] of value.matchAll(/(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/g)) {
|
|
30
|
+
totalNs += Number(amount) * GO_DURATION_UNIT_NS[unit];
|
|
31
|
+
}
|
|
32
|
+
return totalNs / 1e6;
|
|
33
|
+
}
|
|
34
|
+
// Bounds mirror qurl-service so an out-of-range value fails before any side
|
|
35
|
+
// effect (for uploads, before the file is stored). Keep in sync with
|
|
36
|
+
// internal/api/validation/constants.go (MinExpirationDuration,
|
|
37
|
+
// MaxSessionDuration) and internal/domain/qurl.go (MaxCustomerExpiryDuration);
|
|
38
|
+
// the grammar mirrors internal/domain/duration.go (ParseDuration).
|
|
39
|
+
// Grammar and range fail with different messages so a caller retrying knows
|
|
40
|
+
// whether to fix the syntax or the size. create_qurl and mint_link still defer
|
|
41
|
+
// their durations to the API; tracked with the drift guard in #282.
|
|
42
|
+
// allowEmpty lets "" through as its own value (a z.union would collapse both
|
|
43
|
+
// messages into a generic "Invalid input").
|
|
44
|
+
export const durationSchema = (minMs, maxMs, range, allowEmpty = false) => z
|
|
45
|
+
.string()
|
|
46
|
+
// Same message as a syntax error, and abort so it is the only one.
|
|
47
|
+
.max(32, { error: "Use a duration like '30m', '24h', or '7d'", abort: true })
|
|
48
|
+
.refine((value) => (allowEmpty && value === "") || parseDurationMs(value) !== undefined, {
|
|
49
|
+
message: "Use a duration like '30m', '24h', or '7d'",
|
|
50
|
+
abort: true,
|
|
51
|
+
})
|
|
52
|
+
.refine((value) => {
|
|
53
|
+
if (allowEmpty && value === "")
|
|
54
|
+
return true;
|
|
55
|
+
const ms = parseDurationMs(value) ?? 0;
|
|
56
|
+
return ms >= minMs && ms <= maxMs;
|
|
57
|
+
}, { message: `Duration must be ${range}`, abort: true });
|
|
58
|
+
// validation.MinExpirationDuration and domain.MaxCustomerExpiryDuration; qurl-service
|
|
59
|
+
// applies the same pair to expires_in and extend_by (ValidateDuration). Upload
|
|
60
|
+
// links take them too: the connector forwards the requested expiry to
|
|
61
|
+
// qurl-service's mint, which enforces the same ceiling.
|
|
62
|
+
export const MIN_EXPIRY_MS = 60_000;
|
|
63
|
+
// Global, not per plan: qurl-service's MaxCustomerExpiryDuration is 30d on
|
|
64
|
+
// every customer plan (get_quota's max_expiry_seconds reports the same value).
|
|
65
|
+
export const MAX_EXPIRY_MS = 30 * 86_400_000;
|
|
66
|
+
// MAX_SESSION_MS mirrors validation.MaxSessionDuration (24h). MIN_SESSION_MS is
|
|
67
|
+
// an MCP-local floor with no service counterpart: a sub-second session expires
|
|
68
|
+
// on arrival.
|
|
69
|
+
export const MIN_SESSION_MS = 1_000;
|
|
70
|
+
export const MAX_SESSION_MS = 86_400_000;
|
|
71
|
+
//# sourceMappingURL=duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/tools/duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6EAA6E;AAC7E,yDAAyD;AACzD,4EAA4E;AAC5E,6EAA6E;AAC7E,MAAM,gBAAgB,GAAG,uDAAuD,CAAC;AACjF,kFAAkF;AAClF,MAAM,mBAAmB,GAAG;IAC1B,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,MAAM;CACD,CAAC;AAEX;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACpD,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,KAAK;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACnF,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,qCAAqC,CAAC,EAAE,CAAC;QACrF,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC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,gFAAgF;AAChF,+EAA+E;AAC/E,cAAc;AACd,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AACpC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { EmailDeliveryResult } from "../email-types.js";
|
|
3
|
+
export declare const emailDeliveryInputSchema: z.ZodObject<{
|
|
4
|
+
to: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodEmail>>;
|
|
5
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
6
|
+
message: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type EmailDeliveryInput = z.infer<typeof emailDeliveryInputSchema>;
|
|
9
|
+
export interface ToolEmailInput {
|
|
10
|
+
allowServerApiKeyFallback: boolean;
|
|
11
|
+
delivery?: EmailDeliveryInput;
|
|
12
|
+
defaultSubject: string;
|
|
13
|
+
detailLines: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface UploadEmailDetails {
|
|
16
|
+
intro: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
contentType: string;
|
|
19
|
+
qurlLink: string;
|
|
20
|
+
expiresAt?: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
extraLines?: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare function singleLineEmailDetail(value: string): string;
|
|
25
|
+
export declare function uploadEmailDetailLines(details: UploadEmailDetails): string[];
|
|
26
|
+
export declare function toEmailAugmentedResult<T extends object & {
|
|
27
|
+
length?: never;
|
|
28
|
+
}>(base: T, emailResult: EmailDeliveryResult | undefined): {
|
|
29
|
+
content: {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
}[];
|
|
33
|
+
structuredContent: Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
export declare function maybeDeliverToolEmail(input: ToolEmailInput): Promise<EmailDeliveryResult | undefined>;
|
|
36
|
+
//# sourceMappingURL=email-delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-delivery.d.ts","sourceRoot":"","sources":["../../src/tools/email-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAM7D,eAAO,MAAM,wBAAwB;;;;iBAuBnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,MAAM,WAAW,cAAc;IAC7B,yBAAyB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAU5E;AAID,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,EAC1E,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,mBAAmB,GAAG,SAAS;;;;;;EAO7C;AAiCD,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CA2C1C"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { normalizedEmailAddressSchema, uniqueRecipients } from "../email-addresses.js";
|
|
3
|
+
import { EmailDeliverySetupError, MAX_EMAIL_SUBJECT_CHARACTERS, MAX_EMAIL_TEXT_CHARACTERS, } from "../email-types.js";
|
|
4
|
+
import { formatErrorForLog } from "../logging.js";
|
|
5
|
+
import { sendEmailMessage } from "../services/email.js";
|
|
6
|
+
import { flattenControlCharacters } from "../text.js";
|
|
7
|
+
import { toStructuredContent } from "./_shared.js";
|
|
8
|
+
export const emailDeliveryInputSchema = z.object({
|
|
9
|
+
to: z
|
|
10
|
+
.array(normalizedEmailAddressSchema)
|
|
11
|
+
.min(1)
|
|
12
|
+
.max(100)
|
|
13
|
+
.describe("One or more recipient email addresses. The server's SMTP recipient policy may enforce a lower limit."),
|
|
14
|
+
subject: z
|
|
15
|
+
.string()
|
|
16
|
+
.max(MAX_EMAIL_SUBJECT_CHARACTERS)
|
|
17
|
+
.refine((subject) => !/[\r\n]/.test(subject), "Subject must be a single line.")
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Optional single-line email subject. Defaults to a tool-specific subject when omitted."),
|
|
20
|
+
message: z
|
|
21
|
+
.string()
|
|
22
|
+
.max(5000)
|
|
23
|
+
.optional()
|
|
24
|
+
.describe(`Optional plain-text message to prepend above generated qURL details. The final assembled email is limited to ${MAX_EMAIL_TEXT_CHARACTERS.toLocaleString("en-US")} characters.`),
|
|
25
|
+
});
|
|
26
|
+
export function singleLineEmailDetail(value) {
|
|
27
|
+
return flattenControlCharacters(value);
|
|
28
|
+
}
|
|
29
|
+
export function uploadEmailDetailLines(details) {
|
|
30
|
+
return [
|
|
31
|
+
details.intro,
|
|
32
|
+
`File Name: ${singleLineEmailDetail(details.fileName)}`,
|
|
33
|
+
`Content Type: ${singleLineEmailDetail(details.contentType)}`,
|
|
34
|
+
`Secure Link: ${singleLineEmailDetail(details.qurlLink)}`,
|
|
35
|
+
...(details.expiresAt ? [`Expires At: ${singleLineEmailDetail(details.expiresAt)}`] : []),
|
|
36
|
+
...(details.label ? [`Label: ${singleLineEmailDetail(details.label)}`] : []),
|
|
37
|
+
...(details.extraLines ?? []),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
// Match toStructuredContent's plain-object boundary; `length?: never` keeps
|
|
41
|
+
// arrays from being silently spread into numeric object keys.
|
|
42
|
+
export function toEmailAugmentedResult(base, emailResult) {
|
|
43
|
+
const payload = emailResult ? { ...base, email_delivery: emailResult } : base;
|
|
44
|
+
return {
|
|
45
|
+
content: [{ type: "text", text: JSON.stringify(payload) }],
|
|
46
|
+
structuredContent: toStructuredContent(payload),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function getSanitizedDeliveryFailureReason(error) {
|
|
50
|
+
if (error instanceof EmailDeliverySetupError) {
|
|
51
|
+
switch (error.kind) {
|
|
52
|
+
case "authorization":
|
|
53
|
+
return "Email delivery authorization context was unavailable.";
|
|
54
|
+
case "smtp":
|
|
55
|
+
return "Email delivery was not attempted because SMTP configuration or connection failed.";
|
|
56
|
+
case "input":
|
|
57
|
+
return "Email delivery was not attempted because recipient or message validation failed.";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return "Email delivery was not attempted because delivery setup failed.";
|
|
61
|
+
}
|
|
62
|
+
function skippedDeliveryResult(recipients, skippedReason) {
|
|
63
|
+
return {
|
|
64
|
+
attempted: false,
|
|
65
|
+
enabled: true,
|
|
66
|
+
recipients,
|
|
67
|
+
sent: 0,
|
|
68
|
+
failed: recipients.length,
|
|
69
|
+
results: recipients.map((email) => ({
|
|
70
|
+
email,
|
|
71
|
+
success: false,
|
|
72
|
+
skipped: true,
|
|
73
|
+
error: skippedReason,
|
|
74
|
+
})),
|
|
75
|
+
skipped_reason: skippedReason,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export async function maybeDeliverToolEmail(input) {
|
|
79
|
+
if (!input.delivery)
|
|
80
|
+
return undefined;
|
|
81
|
+
const subject = flattenControlCharacters(input.delivery.subject?.trim() || input.defaultSubject.trim());
|
|
82
|
+
// Preserve formatting in the caller-authored message because it is sent only
|
|
83
|
+
// as the plain-text body. Generated detail fields are flattened separately
|
|
84
|
+
// so an untrusted value cannot visually create another structured detail row.
|
|
85
|
+
const sections = [
|
|
86
|
+
input.delivery.message?.trim(),
|
|
87
|
+
input.detailLines.join("\n"),
|
|
88
|
+
"Sent by qURL.",
|
|
89
|
+
].filter((section) => typeof section === "string" && section.length > 0);
|
|
90
|
+
const text = sections.join("\n\n");
|
|
91
|
+
const recipients = uniqueRecipients(input.delivery.to);
|
|
92
|
+
// Fail with a structured skipped result here for tool callers. The service
|
|
93
|
+
// repeats this boundary check because it is also exported for direct use.
|
|
94
|
+
// Match Zod's UTF-16-unit maxLength semantics for caller-provided sections.
|
|
95
|
+
if (text.length > MAX_EMAIL_TEXT_CHARACTERS) {
|
|
96
|
+
return skippedDeliveryResult(recipients, `Email delivery was not attempted because the assembled message exceeds ${MAX_EMAIL_TEXT_CHARACTERS.toLocaleString("en-US")} characters.`);
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
return await sendEmailMessage({
|
|
100
|
+
to: recipients,
|
|
101
|
+
subject,
|
|
102
|
+
text,
|
|
103
|
+
}, { allowServerApiKeyFallback: input.allowServerApiKeyFallback });
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
// Link creation has already succeeded when this helper runs. Never turn a
|
|
107
|
+
// delivery failure into a failed tool call because qurl_link is one-shot
|
|
108
|
+
// output that cannot be recovered later.
|
|
109
|
+
console.error(`Email delivery failed after qURL creation (${formatErrorForLog(error)})`);
|
|
110
|
+
const skippedReason = getSanitizedDeliveryFailureReason(error);
|
|
111
|
+
return skippedDeliveryResult(recipients, skippedReason);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=email-delivery.js.map
|
|
@@ -0,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