@layervai/qurl-mcp 0.4.0 → 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.
Files changed (173) hide show
  1. package/README.md +742 -46
  2. package/assets/fonts/NotoSansSC-Regular.ttf +0 -0
  3. package/assets/fonts/OFL.txt +93 -0
  4. package/assets/fonts/README.md +18 -0
  5. package/dist/auth/request-context.d.ts +13 -0
  6. package/dist/auth/request-context.d.ts.map +1 -0
  7. package/dist/auth/request-context.js +21 -0
  8. package/dist/auth/request-context.js.map +1 -0
  9. package/dist/auth/static-bearer.d.ts +12 -0
  10. package/dist/auth/static-bearer.d.ts.map +1 -0
  11. package/dist/auth/static-bearer.js +47 -0
  12. package/dist/auth/static-bearer.js.map +1 -0
  13. package/dist/client.d.ts +112 -23
  14. package/dist/client.d.ts.map +1 -1
  15. package/dist/client.js +173 -78
  16. package/dist/client.js.map +1 -1
  17. package/dist/config.d.ts +98 -0
  18. package/dist/config.d.ts.map +1 -0
  19. package/dist/config.js +543 -0
  20. package/dist/config.js.map +1 -0
  21. package/dist/credential-rate-limit-store.d.ts +38 -0
  22. package/dist/credential-rate-limit-store.d.ts.map +1 -0
  23. package/dist/credential-rate-limit-store.js +135 -0
  24. package/dist/credential-rate-limit-store.js.map +1 -0
  25. package/dist/email-addresses.d.ts +7 -0
  26. package/dist/email-addresses.d.ts.map +1 -0
  27. package/dist/email-addresses.js +36 -0
  28. package/dist/email-addresses.js.map +1 -0
  29. package/dist/email-types.d.ts +33 -0
  30. package/dist/email-types.d.ts.map +1 -0
  31. package/dist/email-types.js +28 -0
  32. package/dist/email-types.js.map +1 -0
  33. package/dist/emf-metrics.d.ts +25 -0
  34. package/dist/emf-metrics.d.ts.map +1 -0
  35. package/dist/emf-metrics.js +87 -0
  36. package/dist/emf-metrics.js.map +1 -0
  37. package/dist/http-config.d.ts +38 -0
  38. package/dist/http-config.d.ts.map +1 -0
  39. package/dist/http-config.js +243 -0
  40. package/dist/http-config.js.map +1 -0
  41. package/dist/http-routes.d.ts +5 -0
  42. package/dist/http-routes.d.ts.map +1 -0
  43. package/dist/http-routes.js +12 -0
  44. package/dist/http-routes.js.map +1 -0
  45. package/dist/http.d.ts +33 -0
  46. package/dist/http.d.ts.map +1 -0
  47. package/dist/http.js +1116 -0
  48. package/dist/http.js.map +1 -0
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +42 -25
  52. package/dist/index.js.map +1 -1
  53. package/dist/logging.d.ts +7 -0
  54. package/dist/logging.d.ts.map +1 -0
  55. package/dist/logging.js +110 -0
  56. package/dist/logging.js.map +1 -0
  57. package/dist/prompts/secure-a-service.d.ts +16 -4
  58. package/dist/prompts/secure-a-service.d.ts.map +1 -1
  59. package/dist/prompts/secure-a-service.js +7 -15
  60. package/dist/prompts/secure-a-service.js.map +1 -1
  61. package/dist/server.d.ts +18 -6
  62. package/dist/server.d.ts.map +1 -1
  63. package/dist/server.js +41 -8
  64. package/dist/server.js.map +1 -1
  65. package/dist/services/email.d.ts +17 -0
  66. package/dist/services/email.d.ts.map +1 -0
  67. package/dist/services/email.js +351 -0
  68. package/dist/services/email.js.map +1 -0
  69. package/dist/services/html.d.ts +5 -0
  70. package/dist/services/html.d.ts.map +1 -0
  71. package/dist/services/html.js +28 -0
  72. package/dist/services/html.js.map +1 -0
  73. package/dist/services/legal-pages.d.ts +12 -0
  74. package/dist/services/legal-pages.d.ts.map +1 -0
  75. package/dist/services/legal-pages.js +588 -0
  76. package/dist/services/legal-pages.js.map +1 -0
  77. package/dist/services/text-pdf.d.ts +16 -0
  78. package/dist/services/text-pdf.d.ts.map +1 -0
  79. package/dist/services/text-pdf.js +141 -0
  80. package/dist/services/text-pdf.js.map +1 -0
  81. package/dist/services/video-page.d.ts +4 -0
  82. package/dist/services/video-page.d.ts.map +1 -0
  83. package/dist/services/video-page.js +311 -0
  84. package/dist/services/video-page.js.map +1 -0
  85. package/dist/text.d.ts +4 -0
  86. package/dist/text.d.ts.map +1 -0
  87. package/dist/text.js +16 -0
  88. package/dist/text.js.map +1 -0
  89. package/dist/tools/_shared.d.ts +13 -3
  90. package/dist/tools/_shared.d.ts.map +1 -1
  91. package/dist/tools/_shared.js +31 -7
  92. package/dist/tools/_shared.js.map +1 -1
  93. package/dist/tools/batch-create.d.ts +36 -343
  94. package/dist/tools/batch-create.d.ts.map +1 -1
  95. package/dist/tools/batch-create.js +7 -4
  96. package/dist/tools/batch-create.js.map +1 -1
  97. package/dist/tools/create-qurl.d.ts +79 -237
  98. package/dist/tools/create-qurl.d.ts.map +1 -1
  99. package/dist/tools/create-qurl.js +77 -47
  100. package/dist/tools/create-qurl.js.map +1 -1
  101. package/dist/tools/delete-qurl.d.ts +5 -22
  102. package/dist/tools/delete-qurl.d.ts.map +1 -1
  103. package/dist/tools/delete-qurl.js +19 -13
  104. package/dist/tools/delete-qurl.js.map +1 -1
  105. package/dist/tools/email-delivery.d.ts +37 -0
  106. package/dist/tools/email-delivery.d.ts.map +1 -0
  107. package/dist/tools/email-delivery.js +115 -0
  108. package/dist/tools/email-delivery.js.map +1 -0
  109. package/dist/tools/extend-qurl.d.ts +36 -189
  110. package/dist/tools/extend-qurl.d.ts.map +1 -1
  111. package/dist/tools/extend-qurl.js +3 -3
  112. package/dist/tools/extend-qurl.js.map +1 -1
  113. package/dist/tools/get-qurl.d.ts +36 -185
  114. package/dist/tools/get-qurl.d.ts.map +1 -1
  115. package/dist/tools/get-qurl.js +8 -5
  116. package/dist/tools/get-qurl.js.map +1 -1
  117. package/dist/tools/list-qurl-sessions.d.ts +45 -0
  118. package/dist/tools/list-qurl-sessions.d.ts.map +1 -0
  119. package/dist/tools/list-qurl-sessions.js +33 -0
  120. package/dist/tools/list-qurl-sessions.js.map +1 -0
  121. package/dist/tools/list-qurls.d.ts +38 -319
  122. package/dist/tools/list-qurls.d.ts.map +1 -1
  123. package/dist/tools/list-qurls.js +45 -20
  124. package/dist/tools/list-qurls.js.map +1 -1
  125. package/dist/tools/mint-link.d.ts +72 -303
  126. package/dist/tools/mint-link.d.ts.map +1 -1
  127. package/dist/tools/mint-link.js +35 -21
  128. package/dist/tools/mint-link.js.map +1 -1
  129. package/dist/tools/output-schemas.d.ts +326 -1112
  130. package/dist/tools/output-schemas.d.ts.map +1 -1
  131. package/dist/tools/output-schemas.js +141 -40
  132. package/dist/tools/output-schemas.js.map +1 -1
  133. package/dist/tools/resolve-qurl.d.ts +6 -37
  134. package/dist/tools/resolve-qurl.d.ts.map +1 -1
  135. package/dist/tools/resolve-qurl.js +5 -5
  136. package/dist/tools/resolve-qurl.js.map +1 -1
  137. package/dist/tools/revoke-qurl-token.d.ts +41 -0
  138. package/dist/tools/revoke-qurl-token.d.ts.map +1 -0
  139. package/dist/tools/revoke-qurl-token.js +40 -0
  140. package/dist/tools/revoke-qurl-token.js.map +1 -0
  141. package/dist/tools/terminate-qurl-sessions.d.ts +41 -0
  142. package/dist/tools/terminate-qurl-sessions.d.ts.map +1 -0
  143. package/dist/tools/terminate-qurl-sessions.js +68 -0
  144. package/dist/tools/terminate-qurl-sessions.js.map +1 -0
  145. package/dist/tools/update-qurl-token.d.ts +142 -0
  146. package/dist/tools/update-qurl-token.d.ts.map +1 -0
  147. package/dist/tools/update-qurl-token.js +75 -0
  148. package/dist/tools/update-qurl-token.js.map +1 -0
  149. package/dist/tools/update-qurl.d.ts +43 -264
  150. package/dist/tools/update-qurl.d.ts.map +1 -1
  151. package/dist/tools/update-qurl.js +57 -8
  152. package/dist/tools/update-qurl.js.map +1 -1
  153. package/dist/tools/upload-file-data-qurl.d.ts +182 -0
  154. package/dist/tools/upload-file-data-qurl.d.ts.map +1 -0
  155. package/dist/tools/upload-file-data-qurl.js +200 -0
  156. package/dist/tools/upload-file-data-qurl.js.map +1 -0
  157. package/dist/tools/upload-file-qurl.d.ts +162 -0
  158. package/dist/tools/upload-file-qurl.d.ts.map +1 -0
  159. package/dist/tools/upload-file-qurl.js +167 -0
  160. package/dist/tools/upload-file-qurl.js.map +1 -0
  161. package/dist/tools/upload-file-shared.d.ts +36 -0
  162. package/dist/tools/upload-file-shared.d.ts.map +1 -0
  163. package/dist/tools/upload-file-shared.js +347 -0
  164. package/dist/tools/upload-file-shared.js.map +1 -0
  165. package/dist/tools/upload-mint-options.d.ts +22 -0
  166. package/dist/tools/upload-mint-options.d.ts.map +1 -0
  167. package/dist/tools/upload-mint-options.js +29 -0
  168. package/dist/tools/upload-mint-options.js.map +1 -0
  169. package/dist/tools/upload-text-qurl.d.ts +144 -0
  170. package/dist/tools/upload-text-qurl.d.ts.map +1 -0
  171. package/dist/tools/upload-text-qurl.js +102 -0
  172. package/dist/tools/upload-text-qurl.js.map +1 -0
  173. package/package.json +27 -8
@@ -0,0 +1,141 @@
1
+ import PDFDocument from "pdfkit";
2
+ import { Buffer } from "node:buffer";
3
+ import { createWriteStream, existsSync } from "node:fs";
4
+ import { mkdtemp, rm, stat } from "node:fs/promises";
5
+ import { basename, extname, join } from "node:path";
6
+ import { tmpdir } from "node:os";
7
+ import { fileURLToPath } from "node:url";
8
+ import { isControlCodePoint } from "../text.js";
9
+ const bundledFontPath = fileURLToPath(new URL("../../assets/fonts/NotoSansSC-Regular.ttf", import.meta.url));
10
+ export const MAX_TEXT_PDF_CONTENT_CHARACTERS = 100_000;
11
+ export const MAX_TEXT_PDF_CONTENT_BYTES = 256 * 1024;
12
+ export function sanitizePdfText(input, fallback) {
13
+ let sanitized = "";
14
+ let replacingControlCharacters = false;
15
+ for (const character of input) {
16
+ const codePoint = character.codePointAt(0) ?? 0;
17
+ const isControlCharacter = isControlCodePoint(codePoint);
18
+ if (isControlCharacter) {
19
+ if (!replacingControlCharacters)
20
+ sanitized += " ";
21
+ }
22
+ else {
23
+ sanitized += character;
24
+ }
25
+ replacingControlCharacters = isControlCharacter;
26
+ }
27
+ return sanitized.trim() || fallback;
28
+ }
29
+ export function ensurePdfFileName(input) {
30
+ const baseName = basename(sanitizePdfText(input ?? "content", "content")) || "content";
31
+ const sourceExtension = extname(baseName);
32
+ // extname(".pdf") is empty because it treats the value as a dotfile. Keep
33
+ // that one explicit fallback, then use a single original-string slice.
34
+ const extensionLength = sourceExtension.length || (baseName.toLowerCase().endsWith(".pdf") ? 4 : 0);
35
+ const withoutExt = extensionLength ? baseName.slice(0, -extensionLength) : baseName;
36
+ const normalizedStem = withoutExt.replace(/^\.+|\.+$/g, "");
37
+ const safeStem = normalizedStem || "content";
38
+ return `${safeStem}.pdf`;
39
+ }
40
+ export function resolveFontPath(candidatePath = bundledFontPath) {
41
+ if (existsSync(candidatePath))
42
+ return candidatePath;
43
+ console.warn("[text-pdf] bundled Noto Sans SC font is missing; falling back to Helvetica with limited CJK coverage");
44
+ return undefined;
45
+ }
46
+ let cachedBundledFontPath;
47
+ let hasResolvedBundledFontPath = false;
48
+ function getBundledFontPath() {
49
+ if (!hasResolvedBundledFontPath) {
50
+ // Resolve lazily so a missing-asset warning passes through the installed
51
+ // console timestamp/redaction boundary instead of running during ESM
52
+ // evaluation. Published assets are immutable, so cache the decision.
53
+ cachedBundledFontPath = resolveFontPath();
54
+ hasResolvedBundledFontPath = true;
55
+ }
56
+ return cachedBundledFontPath;
57
+ }
58
+ export async function createTextPdfTempFile(input) {
59
+ // Match Zod's UTF-16-unit maxLength behavior, then independently cap UTF-8
60
+ // bytes at this exported service boundary. The latter keeps every caller,
61
+ // including future non-HTTP callers, within the renderer's memory budget.
62
+ if (input.content.length > MAX_TEXT_PDF_CONTENT_CHARACTERS) {
63
+ throw new Error(`PDF content must not exceed ${MAX_TEXT_PDF_CONTENT_CHARACTERS.toLocaleString("en-US")} characters.`);
64
+ }
65
+ if (Buffer.byteLength(input.content, "utf8") > MAX_TEXT_PDF_CONTENT_BYTES) {
66
+ throw new Error(`PDF content must not exceed ${MAX_TEXT_PDF_CONTENT_BYTES / 1024} KiB.`);
67
+ }
68
+ const tempDir = await mkdtemp(join(tmpdir(), "qurl-text-pdf-"));
69
+ const fileName = ensurePdfFileName(input.fileName);
70
+ const filePath = join(tempDir, fileName);
71
+ const fontPath = getBundledFontPath();
72
+ try {
73
+ await new Promise((resolve, reject) => {
74
+ const doc = new PDFDocument({
75
+ autoFirstPage: true,
76
+ margin: 56,
77
+ size: "A4",
78
+ });
79
+ const stream = createWriteStream(filePath);
80
+ let settled = false;
81
+ const succeed = () => {
82
+ if (settled)
83
+ return;
84
+ settled = true;
85
+ resolve();
86
+ };
87
+ const fail = (error) => {
88
+ if (settled)
89
+ return;
90
+ settled = true;
91
+ stream.removeAllListeners("finish");
92
+ if (stream.closed) {
93
+ doc.removeAllListeners();
94
+ if (!doc.destroyed)
95
+ doc.destroy();
96
+ reject(error);
97
+ return;
98
+ }
99
+ stream.once("close", () => reject(error));
100
+ if (!stream.destroyed)
101
+ stream.destroy();
102
+ doc.removeAllListeners();
103
+ if (!doc.destroyed)
104
+ doc.destroy();
105
+ };
106
+ stream.once("finish", succeed);
107
+ stream.once("error", fail);
108
+ doc.once("error", fail);
109
+ try {
110
+ doc.pipe(stream);
111
+ doc.info.Title = sanitizePdfText(input.title ?? fileName, fileName);
112
+ if (fontPath) {
113
+ doc.font(fontPath);
114
+ }
115
+ doc.fontSize(12);
116
+ doc.text(input.content, {
117
+ align: "left",
118
+ lineGap: 4,
119
+ });
120
+ doc.end();
121
+ }
122
+ catch (error) {
123
+ fail(error);
124
+ }
125
+ });
126
+ const fileStat = await stat(filePath);
127
+ return {
128
+ cleanup: async () => {
129
+ await rm(tempDir, { recursive: true, force: true });
130
+ },
131
+ fileName,
132
+ filePath,
133
+ sizeBytes: fileStat.size,
134
+ };
135
+ }
136
+ catch (error) {
137
+ await rm(tempDir, { recursive: true, force: true });
138
+ throw error;
139
+ }
140
+ }
141
+ //# sourceMappingURL=text-pdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-pdf.js","sourceRoot":"","sources":["../../src/services/text-pdf.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,MAAM,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AAC,GAAG,EAAE,CAAC;YACZ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,KAAK,CAAC,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEtC,OAAO;YACL,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACtD,CAAC;YACD,QAAQ;YACR,QAAQ;YACR,SAAS,EAAE,QAAQ,CAAC,IAAI;SACzB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { PublicVideoConfig } from "../config.js";
2
+ export declare function getPublicVideoFileRoute(pagePath: string): string;
3
+ export declare function renderPublicVideoPageHtml(config: PublicVideoConfig, baseUrl: string): string;
4
+ //# sourceMappingURL=video-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video-page.d.ts","sourceRoot":"","sources":["../../src/services/video-page.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAgT5F"}
@@ -0,0 +1,311 @@
1
+ import { basename } from "node:path";
2
+ import { escapeHtml, escapeHttpUrlAttribute, REFERENCE_SITE_URL } from "./html.js";
3
+ export function getPublicVideoFileRoute(pagePath) {
4
+ // pagePath has already passed normalizePublicPath at configuration load.
5
+ return `${pagePath}/file`;
6
+ }
7
+ export function renderPublicVideoPageHtml(config, baseUrl) {
8
+ const canonicalUrl = new URL(config.pagePath, baseUrl).toString();
9
+ const videoUrl = new URL(getPublicVideoFileRoute(config.pagePath), baseUrl).toString();
10
+ const fileName = basename(config.filePath);
11
+ return `<!DOCTYPE html>
12
+ <html lang="en">
13
+ <head>
14
+ <meta charset="utf-8" />
15
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
16
+ <title>${escapeHtml(config.title)} | LayerV</title>
17
+ <meta name="description" content="${escapeHtml(config.title)} video playback page served by qURL." />
18
+ <link rel="canonical" href="${escapeHttpUrlAttribute(canonicalUrl)}" />
19
+ <style>
20
+ :root {
21
+ color-scheme: dark;
22
+ --bg: #0a0d09;
23
+ --panel: rgba(20, 24, 18, 0.88);
24
+ --panel-strong: rgba(14, 18, 12, 0.96);
25
+ --border: rgba(194, 255, 66, 0.14);
26
+ --text: #f5f7f1;
27
+ --muted: #b8c0b2;
28
+ --accent: #b9ff2c;
29
+ --accent-soft: rgba(185, 255, 44, 0.12);
30
+ --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
31
+ }
32
+
33
+ * {
34
+ box-sizing: border-box;
35
+ }
36
+
37
+ body {
38
+ margin: 0;
39
+ min-height: 100vh;
40
+ font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
41
+ color: var(--text);
42
+ background:
43
+ linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
44
+ linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
45
+ radial-gradient(circle at top left, rgba(185,255,44,0.12), transparent 24%),
46
+ linear-gradient(180deg, #0d100c 0%, #070906 100%);
47
+ background-size: 48px 48px, 48px 48px, auto, auto;
48
+ }
49
+
50
+ a {
51
+ color: var(--accent);
52
+ text-decoration: none;
53
+ }
54
+
55
+ a:hover {
56
+ text-decoration: underline;
57
+ }
58
+
59
+ .shell {
60
+ width: min(1180px, calc(100% - 32px));
61
+ margin: 0 auto;
62
+ }
63
+
64
+ .topbar {
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: space-between;
68
+ gap: 16px;
69
+ padding: 22px 0 18px;
70
+ }
71
+
72
+ .brand {
73
+ display: inline-flex;
74
+ align-items: center;
75
+ gap: 12px;
76
+ color: var(--text);
77
+ font-size: 0.96rem;
78
+ letter-spacing: 0.04em;
79
+ }
80
+
81
+ .brand-mark {
82
+ width: 40px;
83
+ height: 2px;
84
+ border-radius: 999px;
85
+ background: linear-gradient(90deg, transparent, var(--accent));
86
+ box-shadow: 0 0 18px rgba(185, 255, 44, 0.5);
87
+ }
88
+
89
+ .home-link {
90
+ display: inline-flex;
91
+ align-items: center;
92
+ justify-content: center;
93
+ min-height: 48px;
94
+ padding: 0 18px;
95
+ border-radius: 14px;
96
+ background: var(--accent);
97
+ color: #11140d;
98
+ font-weight: 700;
99
+ box-shadow: 0 14px 40px rgba(185, 255, 44, 0.24);
100
+ }
101
+
102
+ .hero {
103
+ padding: 36px 0 24px;
104
+ }
105
+
106
+ .eyebrow {
107
+ margin: 0 0 16px;
108
+ color: var(--accent);
109
+ font-size: 0.92rem;
110
+ font-weight: 700;
111
+ letter-spacing: 0.18em;
112
+ text-transform: uppercase;
113
+ }
114
+
115
+ .hero-grid {
116
+ display: grid;
117
+ grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
118
+ gap: 28px;
119
+ align-items: start;
120
+ }
121
+
122
+ .hero h1 {
123
+ margin: 0;
124
+ font-size: clamp(2.8rem, 6vw, 5.25rem);
125
+ line-height: 0.95;
126
+ font-weight: 300;
127
+ letter-spacing: -0.04em;
128
+ max-width: 10ch;
129
+ }
130
+
131
+ .hero-copy {
132
+ margin-top: 20px;
133
+ max-width: 680px;
134
+ color: var(--muted);
135
+ font-size: 1.08rem;
136
+ line-height: 1.8;
137
+ }
138
+
139
+ .summary-card {
140
+ padding: 22px 22px 20px;
141
+ border: 1px solid var(--border);
142
+ border-radius: 24px;
143
+ background: var(--panel);
144
+ box-shadow: var(--shadow);
145
+ }
146
+
147
+ .summary-card h2 {
148
+ margin: 0 0 14px;
149
+ font-size: 1rem;
150
+ color: var(--accent);
151
+ }
152
+
153
+ .summary-card p {
154
+ margin: 0;
155
+ color: var(--muted);
156
+ line-height: 1.75;
157
+ }
158
+
159
+ .video-card {
160
+ margin: 22px 0 72px;
161
+ padding: 28px;
162
+ border-radius: 28px;
163
+ border: 1px solid var(--border);
164
+ background: linear-gradient(180deg, var(--panel) 0%, var(--panel-strong) 100%);
165
+ box-shadow: var(--shadow);
166
+ }
167
+
168
+ .video-toolbar {
169
+ display: flex;
170
+ align-items: center;
171
+ gap: 10px;
172
+ margin-bottom: 22px;
173
+ padding-bottom: 16px;
174
+ border-bottom: 1px solid rgba(255,255,255,0.08);
175
+ }
176
+
177
+ .dot {
178
+ width: 10px;
179
+ height: 10px;
180
+ border-radius: 999px;
181
+ }
182
+
183
+ .dot.red { background: #ff5f57; }
184
+ .dot.yellow { background: #febc2e; }
185
+ .dot.green { background: #28c840; }
186
+
187
+ .doc-label {
188
+ margin-left: 8px;
189
+ color: var(--muted);
190
+ font-size: 0.92rem;
191
+ letter-spacing: 0.08em;
192
+ text-transform: lowercase;
193
+ }
194
+
195
+ .video-frame {
196
+ overflow: hidden;
197
+ border-radius: 24px;
198
+ border: 1px solid rgba(255,255,255,0.08);
199
+ background:
200
+ radial-gradient(circle at top, rgba(185,255,44,0.08), transparent 38%),
201
+ #040604;
202
+ }
203
+
204
+ .video-frame video {
205
+ display: block;
206
+ width: 100%;
207
+ max-height: 78vh;
208
+ background: #020302;
209
+ }
210
+
211
+ .video-meta {
212
+ display: flex;
213
+ align-items: center;
214
+ justify-content: space-between;
215
+ gap: 16px;
216
+ margin-top: 16px;
217
+ color: var(--muted);
218
+ font-size: 0.96rem;
219
+ }
220
+
221
+ .footer {
222
+ display: flex;
223
+ align-items: center;
224
+ justify-content: space-between;
225
+ gap: 16px;
226
+ padding: 0 0 36px;
227
+ color: var(--muted);
228
+ font-size: 0.95rem;
229
+ }
230
+
231
+ @media (max-width: 860px) {
232
+ .shell {
233
+ width: min(100% - 24px, 100%);
234
+ }
235
+
236
+ .topbar,
237
+ .footer,
238
+ .hero-grid,
239
+ .video-meta {
240
+ grid-template-columns: 1fr;
241
+ flex-direction: column;
242
+ align-items: flex-start;
243
+ }
244
+
245
+ .video-card {
246
+ padding: 20px;
247
+ border-radius: 22px;
248
+ }
249
+
250
+ .home-link {
251
+ width: 100%;
252
+ }
253
+ }
254
+ </style>
255
+ </head>
256
+ <body>
257
+ <div class="shell">
258
+ <header class="topbar">
259
+ <a class="brand" href="${escapeHttpUrlAttribute(REFERENCE_SITE_URL)}" aria-label="LayerV Home">
260
+ <span class="brand-mark" aria-hidden="true"></span>
261
+ <span>LayerV Media</span>
262
+ </a>
263
+ <a class="home-link" href="${escapeHttpUrlAttribute(REFERENCE_SITE_URL)}">Back to layerv.ai</a>
264
+ </header>
265
+
266
+ <section class="hero">
267
+ <p class="eyebrow">Public Video Playback</p>
268
+ <div class="hero-grid">
269
+ <div>
270
+ <h1>${escapeHtml(config.title)}</h1>
271
+ <p class="hero-copy">
272
+ This public video page is served by the qURL service and provides a clean browser playback experience for the configured MP4 asset.
273
+ </p>
274
+ </div>
275
+ <aside class="summary-card">
276
+ <h2>Playback Ready</h2>
277
+ <p>
278
+ The page streams the configured video file directly from the qURL HTTP service and supports native browser controls.
279
+ </p>
280
+ </aside>
281
+ </div>
282
+ </section>
283
+
284
+ <section class="video-card">
285
+ <div class="video-toolbar" aria-hidden="true">
286
+ <span class="dot red"></span>
287
+ <span class="dot yellow"></span>
288
+ <span class="dot green"></span>
289
+ <span class="doc-label">${escapeHtml(fileName)}</span>
290
+ </div>
291
+ <div class="video-frame">
292
+ <video controls playsinline preload="metadata">
293
+ <source src="${escapeHttpUrlAttribute(videoUrl)}" type="video/mp4" />
294
+ Your browser does not support the MP4 video element.
295
+ </video>
296
+ </div>
297
+ <div class="video-meta">
298
+ <span>Route: ${escapeHtml(config.pagePath)}</span>
299
+ <a href="${escapeHttpUrlAttribute(videoUrl)}">Open raw video stream</a>
300
+ </div>
301
+ </section>
302
+
303
+ <footer class="footer">
304
+ <span>LayerV public media page</span>
305
+ <a href="${escapeHttpUrlAttribute(REFERENCE_SITE_URL)}">${escapeHtml(REFERENCE_SITE_URL)}</a>
306
+ </footer>
307
+ </div>
308
+ </body>
309
+ </html>`;
310
+ }
311
+ //# sourceMappingURL=video-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video-page.js","sourceRoot":"","sources":["../../src/services/video-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEnF,MAAM,UAAU,uBAAuB,CAAC,QAAgB;IACtD,yEAAyE;IACzE,OAAO,GAAG,QAAQ,OAAO,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAyB,EAAE,OAAe;IAClF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvF,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE3C,OAAO;;;;;aAKI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC;wCACG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC;kCAC9B,sBAAsB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAiPrC,sBAAsB,CAAC,kBAAkB,CAAC;;;;qCAItC,sBAAsB,CAAC,kBAAkB,CAAC;;;;;;;kBAO7D,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;oCAmBN,UAAU,CAAC,QAAQ,CAAC;;;;2BAI7B,sBAAsB,CAAC,QAAQ,CAAC;;;;;yBAKlC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;qBAC/B,sBAAsB,CAAC,QAAQ,CAAC;;;;;;mBAMlC,sBAAsB,CAAC,kBAAkB,CAAC,KAAK,UAAU,CAAC,kBAAkB,CAAC;;;;QAIxF,CAAC;AACT,CAAC"}
package/dist/text.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function isControlCodePoint(codePoint: number): boolean;
2
+ /** Replace header/metadata control characters with spaces without changing printable text. */
3
+ export declare function flattenControlCharacters(value: string): string;
4
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAO7D;AAED,8FAA8F;AAC9F,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9D"}
package/dist/text.js ADDED
@@ -0,0 +1,16 @@
1
+ // Shared by PDF metadata/filename rewriting and upload filename rejection so
2
+ // both surfaces classify C0/C1 control characters consistently. Rendered PDF
3
+ // body text intentionally preserves meaningful newlines and tabs.
4
+ export function isControlCodePoint(codePoint) {
5
+ return (codePoint <= 31 ||
6
+ (codePoint >= 127 && codePoint <= 159) ||
7
+ codePoint === 0x2028 ||
8
+ codePoint === 0x2029);
9
+ }
10
+ /** Replace header/metadata control characters with spaces without changing printable text. */
11
+ export function flattenControlCharacters(value) {
12
+ return [...value]
13
+ .map((character) => (isControlCodePoint(character.codePointAt(0) ?? 0) ? " " : character))
14
+ .join("");
15
+ }
16
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,kEAAkE;AAClE,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,OAAO,CACL,SAAS,IAAI,EAAE;QACf,CAAC,SAAS,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC;QACtC,SAAS,KAAK,MAAM;QACpB,SAAS,KAAK,MAAM,CACrB,CAAC;AACJ,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,OAAO,CAAC,GAAG,KAAK,CAAC;SACd,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;SACzF,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
@@ -1,4 +1,11 @@
1
1
  import { z, type ZodError } from "zod";
2
+ export declare const RESOURCE_ID_PATTERN: RegExp;
3
+ export type ToolRuntimeOptions = {
4
+ mode: "stdio" | "http";
5
+ /** Decoded attachment limit used to build transport-visible upload schemas. */
6
+ maxUploadFileDataBytes?: number;
7
+ };
8
+ export declare function allowsServerApiKeyFallback(runtime: ToolRuntimeOptions): boolean;
2
9
  /**
3
10
  * Tool result shape that handlers return. Kept structural so we don't
4
11
  * take a hard dep on the MCP SDK's internal types. `structuredContent`
@@ -42,6 +49,7 @@ export declare function toStructuredContent<T extends object & {
42
49
  * errors, so a missing-key misconfig becomes immediately actionable in
43
50
  * the host UI rather than buried in a generic error toast.
44
51
  *
52
+ * Upload mint failures also return actionable recovery content with the resource ID.
45
53
  * Other API errors continue to throw — they're real failures that callers
46
54
  * should treat as exceptional, and the JSON-RPC error path carries the
47
55
  * statusCode/code metadata the host needs to surface them properly.
@@ -65,14 +73,16 @@ export declare function zodErrorToToolResult(error: ZodError): {
65
73
  /**
66
74
  * Zod schema for a tool's resource_id parameter.
67
75
  *
68
- * The API accepts both a resource ID (r_ prefix) and a qURL display ID
76
+ * The API accepts both a resource identifier (public key, CRID, or legacy r_ ID) and a qURL display ID
69
77
  * (q_ prefix) on get/update/extend/mint_link, and resolves a q_ ID to its
70
- * parent resource automatically. DELETE is the one exception — it only
71
- * accepts r_ IDs and defines its own schema.
78
+ * parent resource automatically. Resource-scoped endpoints use the
79
+ * narrower `resourceOnlyIdSchema` / `qurlDisplayIdSchema` helpers below.
72
80
  *
73
81
  * Rejects empty strings so a malformed call can't hit `/v1/qurls/` with
74
82
  * an empty path segment.
75
83
  */
76
84
  export declare function resourceIdSchema(verb: string): z.ZodString;
85
+ export declare function resourceOnlyIdSchema(verb: string): z.ZodString;
86
+ export declare function qurlDisplayIdSchema(verb: string): z.ZodString;
77
87
  export {};
78
88
  //# sourceMappingURL=_shared.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../src/tools/_shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAGvC;;;;;GAKG;AACH,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,OAA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AE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG;IAK5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAYF,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,EACvE,KAAK,EAAE,CAAC,GACP,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,GACvC,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAiBnC;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ;;;;;;EAUnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,eAW5C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,eAKhD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,eAK/C"}
@@ -1,7 +1,17 @@
1
1
  import { z } from "zod";
2
2
  import { QURLAPIError } from "../client.js";
3
+ // Public API resource IDs are bounded base64url public keys or base32 CRIDs.
4
+ // Public keys encode 80–160 DER bytes: 107–214 base64url chars, excluding length % 4 === 1.
5
+ // CRIDs are the API-registered 47- or 60-character base32 forms.
6
+ // Keep legacy IDs usable during rollout. The service validates key/checksum contents.
7
+ export const RESOURCE_ID_PATTERN = /^(r_[a-z0-9_-]{11}|(?:[A-Za-z0-9_-]{4}){27,53}|(?:[A-Za-z0-9_-]{4}){27,53}[A-Za-z0-9_-]{2}|(?:[A-Za-z0-9_-]{4}){26,52}[A-Za-z0-9_-]{3}|[a-z2-7]{47}|[a-z2-7]{60})$/;
8
+ const QURL_DISPLAY_ID_PATTERN = /^q_[0-9a-f]{11}$/;
9
+ export function allowsServerApiKeyFallback(runtime) {
10
+ return runtime.mode === "stdio";
11
+ }
3
12
  // SDK's `structuredContent` is `Record<string, unknown>`; payloads are
4
- // typed against API response shapes. Single seam for the cast.
13
+ // typed against API response shapes. Each registered tool's zod output schema
14
+ // is the runtime validation guard, and this is the single seam for the cast.
5
15
  // `T extends object` rules out primitives and `null` at compile time;
6
16
  // `{ length?: never }` rules out arrays. The constraint does *not*
7
17
  // reject `Map`/`Set`/`Date`/class instances with non-public state — in
@@ -20,6 +30,7 @@ export function toStructuredContent(value) {
20
30
  * errors, so a missing-key misconfig becomes immediately actionable in
21
31
  * the host UI rather than buried in a generic error toast.
22
32
  *
33
+ * Upload mint failures also return actionable recovery content with the resource ID.
23
34
  * Other API errors continue to throw — they're real failures that callers
24
35
  * should treat as exceptional, and the JSON-RPC error path carries the
25
36
  * statusCode/code metadata the host needs to surface them properly.
@@ -30,7 +41,8 @@ export function withMissingApiKeyHandler(inner) {
30
41
  return await inner(input);
31
42
  }
32
43
  catch (err) {
33
- if (err instanceof QURLAPIError && err.code === "missing_api_key") {
44
+ if (err instanceof QURLAPIError &&
45
+ (err.code === "missing_api_key" || err.code === "upload_mint_failed")) {
34
46
  return {
35
47
  isError: true,
36
48
  content: [{ type: "text", text: err.message }],
@@ -62,10 +74,10 @@ export function zodErrorToToolResult(error) {
62
74
  /**
63
75
  * Zod schema for a tool's resource_id parameter.
64
76
  *
65
- * The API accepts both a resource ID (r_ prefix) and a qURL display ID
77
+ * The API accepts both a resource identifier (public key, CRID, or legacy r_ ID) and a qURL display ID
66
78
  * (q_ prefix) on get/update/extend/mint_link, and resolves a q_ ID to its
67
- * parent resource automatically. DELETE is the one exception — it only
68
- * accepts r_ IDs and defines its own schema.
79
+ * parent resource automatically. Resource-scoped endpoints use the
80
+ * narrower `resourceOnlyIdSchema` / `qurlDisplayIdSchema` helpers below.
69
81
  *
70
82
  * Rejects empty strings so a malformed call can't hit `/v1/qurls/` with
71
83
  * an empty path segment.
@@ -73,8 +85,20 @@ export function zodErrorToToolResult(error) {
73
85
  export function resourceIdSchema(verb) {
74
86
  return z
75
87
  .string()
76
- .min(1)
77
- .describe(`The resource ID (r_ prefix) or qURL display ID (q_ prefix) to ${verb}. ` +
88
+ .regex(new RegExp(`(?:${RESOURCE_ID_PATTERN.source})|(?:${QURL_DISPLAY_ID_PATTERN.source})`), "Expected a resource public key, CRID, legacy r_ ID, or q_ display ID")
89
+ .describe(`The resource public key, CRID, legacy r_ ID, or qURL display ID (q_ prefix) to ${verb}. ` +
78
90
  "If a q_ ID is passed, the API resolves it to the parent resource automatically.");
79
91
  }
92
+ export function resourceOnlyIdSchema(verb) {
93
+ return z
94
+ .string()
95
+ .regex(RESOURCE_ID_PATTERN, "Expected a resource public key, CRID, or legacy r_ ID")
96
+ .describe(`The resource public key, CRID, or legacy r_ ID to ${verb}.`);
97
+ }
98
+ export function qurlDisplayIdSchema(verb) {
99
+ return z
100
+ .string()
101
+ .regex(QURL_DISPLAY_ID_PATTERN, "Expected a q_ qURL display ID")
102
+ .describe(`The qURL display ID (q_ prefix) to ${verb}.`);
103
+ }
80
104
  //# sourceMappingURL=_shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../src/tools/_shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAiB,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,YAAY,E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