mcp-scraper 0.45.0 → 0.47.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 +6 -2
- package/dist/bin/api-server.cjs +1098 -198
- package/dist/bin/api-server.cjs.map +1 -1
- package/dist/bin/api-server.js +3 -3
- package/dist/bin/mcp-scraper-cli.cjs +1 -1
- package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
- package/dist/bin/mcp-scraper-cli.js +1 -1
- package/dist/bin/mcp-scraper-install.cjs +3 -2
- package/dist/bin/mcp-scraper-install.cjs.map +1 -1
- package/dist/bin/mcp-scraper-install.js +2 -2
- package/dist/bin/mcp-stdio-server.cjs +251 -34
- package/dist/bin/mcp-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-stdio-server.js +5 -5
- package/dist/bin/paa-harvest.cjs.map +1 -1
- package/dist/bin/paa-harvest.js +3 -3
- package/dist/{chunk-5X7CJEK3.js → chunk-5S6LYQQO.js} +2 -2
- package/dist/chunk-5S6LYQQO.js.map +1 -0
- package/dist/{chunk-OVD4E4AP.js → chunk-GV5EGE5M.js} +2 -2
- package/dist/chunk-H4NWAF5B.js +7 -0
- package/dist/chunk-H4NWAF5B.js.map +1 -0
- package/dist/{chunk-T5AFM4G5.js → chunk-IWYYZXBR.js} +2 -2
- package/dist/{chunk-RJMOOII7.js → chunk-JH7A4HA7.js} +2 -2
- package/dist/{chunk-JFOT5JEL.js → chunk-MW3ET532.js} +2 -2
- package/dist/{chunk-GRODXRUY.js → chunk-QSUGPYGQ.js} +3 -2
- package/dist/chunk-QSUGPYGQ.js.map +1 -0
- package/dist/{chunk-WT2UHDSE.js → chunk-TV6KPZ6J.js} +2 -2
- package/dist/{chunk-FQIICRR4.js → chunk-XCGQBGDA.js} +296 -38
- package/dist/chunk-XCGQBGDA.js.map +1 -0
- package/dist/{db-4ABEYNDM.js → db-W3RPRILW.js} +2 -2
- package/dist/{extract-bundle-DYMQRQWG.js → extract-bundle-DXWWQER6.js} +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{location-data-repository-HDNCU4Z4.js → location-data-repository-2FJVMTZ2.js} +3 -3
- package/dist/{server-7B75SDNG.js → server-OHMZJRSB.js} +778 -141
- package/dist/server-OHMZJRSB.js.map +1 -0
- package/dist/{site-extract-repository-G723PZIL.js → site-extract-repository-UULQAGO4.js} +3 -3
- package/dist/{worker-4LZGRHDA.js → worker-3QX7LG62.js} +5 -5
- package/package.json +2 -2
- package/dist/chunk-5X7CJEK3.js.map +0 -1
- package/dist/chunk-CEZ3NFBP.js +0 -7
- package/dist/chunk-CEZ3NFBP.js.map +0 -1
- package/dist/chunk-FQIICRR4.js.map +0 -1
- package/dist/chunk-GRODXRUY.js.map +0 -1
- package/dist/server-7B75SDNG.js.map +0 -1
- /package/dist/{chunk-OVD4E4AP.js.map → chunk-GV5EGE5M.js.map} +0 -0
- /package/dist/{chunk-T5AFM4G5.js.map → chunk-IWYYZXBR.js.map} +0 -0
- /package/dist/{chunk-RJMOOII7.js.map → chunk-JH7A4HA7.js.map} +0 -0
- /package/dist/{chunk-JFOT5JEL.js.map → chunk-MW3ET532.js.map} +0 -0
- /package/dist/{chunk-WT2UHDSE.js.map → chunk-TV6KPZ6J.js.map} +0 -0
- /package/dist/{db-4ABEYNDM.js.map → db-W3RPRILW.js.map} +0 -0
- /package/dist/{extract-bundle-DYMQRQWG.js.map → extract-bundle-DXWWQER6.js.map} +0 -0
- /package/dist/{location-data-repository-HDNCU4Z4.js.map → location-data-repository-2FJVMTZ2.js.map} +0 -0
- /package/dist/{site-extract-repository-G723PZIL.js.map → site-extract-repository-UULQAGO4.js.map} +0 -0
- /package/dist/{worker-4LZGRHDA.js.map → worker-3QX7LG62.js.map} +0 -0
package/dist/bin/api-server.cjs
CHANGED
|
@@ -2623,38 +2623,38 @@ function renderCard(card) {
|
|
|
2623
2623
|
</div>
|
|
2624
2624
|
</div>`;
|
|
2625
2625
|
}
|
|
2626
|
-
function renderSection(
|
|
2627
|
-
const calloutHtml =
|
|
2626
|
+
function renderSection(section2, tocTitle) {
|
|
2627
|
+
const calloutHtml = section2.callout ? `
|
|
2628
2628
|
<div class="callout">
|
|
2629
|
-
<p class="callout-eyebrow">${
|
|
2630
|
-
<h3 class="callout-heading">${
|
|
2631
|
-
<p class="callout-body">${
|
|
2629
|
+
<p class="callout-eyebrow">${section2.callout.eyebrow}</p>
|
|
2630
|
+
<h3 class="callout-heading">${section2.callout.heading}</h3>
|
|
2631
|
+
<p class="callout-body">${section2.callout.body}</p>
|
|
2632
2632
|
</div>` : "";
|
|
2633
|
-
const cardsHtml =
|
|
2634
|
-
const interactiveHtml =
|
|
2635
|
-
<div class="section-interactive">${
|
|
2636
|
-
return `<section class="post-section" id="${
|
|
2633
|
+
const cardsHtml = section2.cards.map(renderCard).join("\n ");
|
|
2634
|
+
const interactiveHtml = section2.interactiveHtml ? `
|
|
2635
|
+
<div class="section-interactive">${section2.interactiveHtml}</div>` : "";
|
|
2636
|
+
return `<section class="post-section" id="${section2.id}" aria-label="${tocTitle}">
|
|
2637
2637
|
<div class="section-header">
|
|
2638
|
-
<span class="section-num">${
|
|
2639
|
-
<h2 class="section-title">${
|
|
2640
|
-
<p class="section-deck">${
|
|
2638
|
+
<span class="section-num">${section2.num}</span>
|
|
2639
|
+
<h2 class="section-title">${section2.title}${section2.titleItalic ? ` <em>${section2.titleItalic}</em>` : ""}</h2>
|
|
2640
|
+
<p class="section-deck">${section2.deck}</p>
|
|
2641
2641
|
</div>${calloutHtml}
|
|
2642
2642
|
<div class="card-stack">
|
|
2643
2643
|
${cardsHtml}
|
|
2644
2644
|
</div>${interactiveHtml}
|
|
2645
2645
|
</section>`;
|
|
2646
2646
|
}
|
|
2647
|
-
function tocItem(
|
|
2648
|
-
const label = `${
|
|
2649
|
-
const subItems =
|
|
2647
|
+
function tocItem(section2) {
|
|
2648
|
+
const label = `${section2.title}${section2.titleItalic ? " " + section2.titleItalic : ""}`;
|
|
2649
|
+
const subItems = section2.cards.map((card) => `<li>
|
|
2650
2650
|
<a href="#${card.id}" class="toc-sub-link" data-toc="${card.id}">
|
|
2651
2651
|
<span class="toc-sub-num">${card.num}</span>
|
|
2652
2652
|
<span class="toc-sub-label">${card.question}</span>
|
|
2653
2653
|
</a>
|
|
2654
2654
|
</li>`).join("\n ");
|
|
2655
2655
|
return `<li>
|
|
2656
|
-
<a href="#${
|
|
2657
|
-
<span class="toc-num">${
|
|
2656
|
+
<a href="#${section2.id}" class="toc-link" data-toc="${section2.id}">
|
|
2657
|
+
<span class="toc-num">${section2.num}</span>
|
|
2658
2658
|
<span class="toc-label">${label}</span>
|
|
2659
2659
|
</a>
|
|
2660
2660
|
<ul class="toc-sub-list">
|
|
@@ -4548,7 +4548,7 @@ async function migrate(options = {}) {
|
|
|
4548
4548
|
artifact_id TEXT NOT NULL,
|
|
4549
4549
|
title TEXT NOT NULL,
|
|
4550
4550
|
summary TEXT NOT NULL,
|
|
4551
|
-
renderer_key TEXT NOT NULL CHECK (renderer_key
|
|
4551
|
+
renderer_key TEXT NOT NULL CHECK (renderer_key IN ('editorial_reading_room_v1','personal_authority_v1')),
|
|
4552
4552
|
token_hash TEXT NOT NULL UNIQUE,
|
|
4553
4553
|
expires_at TEXT NOT NULL,
|
|
4554
4554
|
revoked_at TEXT,
|
|
@@ -29055,8 +29055,8 @@ var init_YouTubeExtractor = __esm({
|
|
|
29055
29055
|
const sections = slr?.contents ?? [];
|
|
29056
29056
|
const videos = [];
|
|
29057
29057
|
const channels = [];
|
|
29058
|
-
for (const
|
|
29059
|
-
const contents =
|
|
29058
|
+
for (const section2 of sections) {
|
|
29059
|
+
const contents = section2.itemSectionRenderer?.contents ?? [];
|
|
29060
29060
|
for (const item of contents) {
|
|
29061
29061
|
const rec = item;
|
|
29062
29062
|
if (rec.videoRenderer) {
|
|
@@ -33664,7 +33664,7 @@ async function extractAISurfacesFromDocument(config) {
|
|
|
33664
33664
|
}
|
|
33665
33665
|
return null;
|
|
33666
33666
|
}
|
|
33667
|
-
function
|
|
33667
|
+
function cleanText2(target) {
|
|
33668
33668
|
if (!target) return null;
|
|
33669
33669
|
const clone = target.cloneNode(true);
|
|
33670
33670
|
clone.querySelectorAll([
|
|
@@ -33791,14 +33791,14 @@ async function extractAISurfacesFromDocument(config) {
|
|
|
33791
33791
|
const contentSubtree = aioRoot.querySelector(selectors.aio.contentSubtree);
|
|
33792
33792
|
const showMore = aioRoot.querySelector(selectors.aio.showMoreButton);
|
|
33793
33793
|
aioFullyExpanded = controller?.getAttribute("data-trnct") === "false" || showMore?.getAttribute("aria-expanded") === "true" || !showMore;
|
|
33794
|
-
aioText =
|
|
33794
|
+
aioText = cleanText2(contentSubtree ?? controller ?? aioRoot);
|
|
33795
33795
|
aioSections = (aioText ?? "").split("\n").map((line) => line.trim()).filter((line) => /^\d+\.\s+.+/.test(line));
|
|
33796
33796
|
aioCitations = extractCitations(aioRoot);
|
|
33797
33797
|
}
|
|
33798
33798
|
const aimRoot = document.querySelector(selectors.aim.root);
|
|
33799
33799
|
const aimRootDetected = surface === "aim" && !!aimRoot;
|
|
33800
33800
|
const aimContainer = aimRoot?.closest(selectors.aim.wrapper) ?? aimRoot;
|
|
33801
|
-
const rawAimText = aimRootDetected ?
|
|
33801
|
+
const rawAimText = aimRootDetected ? cleanText2(aimContainer) : null;
|
|
33802
33802
|
const aimDetected = aimRootDetected && hasSubstantiveContent(rawAimText);
|
|
33803
33803
|
const aimText = aimDetected ? rawAimText : null;
|
|
33804
33804
|
const aimCitations = aimDetected ? extractCitations(aimContainer) : [];
|
|
@@ -33872,7 +33872,7 @@ var init_PAAExtractor = __esm({
|
|
|
33872
33872
|
async extractVisibleItems(page) {
|
|
33873
33873
|
const sels = PAASelectors;
|
|
33874
33874
|
const raw = await page.evaluate((selectors) => {
|
|
33875
|
-
function
|
|
33875
|
+
function cleanText2(el2) {
|
|
33876
33876
|
if (!el2) return "";
|
|
33877
33877
|
const parts = [];
|
|
33878
33878
|
for (const n of el2.childNodes) {
|
|
@@ -33882,7 +33882,7 @@ var init_PAAExtractor = __esm({
|
|
|
33882
33882
|
} else if (n.tagName === "STYLE" || n.tagName === "SCRIPT") {
|
|
33883
33883
|
continue;
|
|
33884
33884
|
} else {
|
|
33885
|
-
const text2 =
|
|
33885
|
+
const text2 = cleanText2(n);
|
|
33886
33886
|
if (text2) parts.push(text2);
|
|
33887
33887
|
}
|
|
33888
33888
|
}
|
|
@@ -33936,7 +33936,7 @@ var init_PAAExtractor = __esm({
|
|
|
33936
33936
|
}
|
|
33937
33937
|
return {
|
|
33938
33938
|
question: pair.getAttribute(selectors.itemDataQ) || pair.getAttribute(selectors.itemDataInitQ) || pair.querySelector(selectors.itemQuestionEl)?.innerText?.trim() || "",
|
|
33939
|
-
answer:
|
|
33939
|
+
answer: cleanText2(answerElement) || void 0,
|
|
33940
33940
|
sourceTitle,
|
|
33941
33941
|
sourceSite,
|
|
33942
33942
|
sourceCite
|
|
@@ -34302,9 +34302,9 @@ var init_PAAExtractor = __esm({
|
|
|
34302
34302
|
async extractWhatPeopleSaying(page) {
|
|
34303
34303
|
const sels = WhatPeopleSayingSelectors;
|
|
34304
34304
|
return page.evaluate((s) => {
|
|
34305
|
-
const
|
|
34306
|
-
if (!
|
|
34307
|
-
return Array.from(
|
|
34305
|
+
const section2 = Array.from(document.querySelectorAll(s.sectionTag)).find((el2) => el2.textContent?.includes(s.sectionHeadingText)) ?? document.querySelector(".yG4QQe.TBC9ub.NbhJ1c");
|
|
34306
|
+
if (!section2) return [];
|
|
34307
|
+
return Array.from(section2.querySelectorAll(s.card)).map((card) => {
|
|
34308
34308
|
const link = card.querySelector(s.cardLink);
|
|
34309
34309
|
const url = link?.href ?? "";
|
|
34310
34310
|
const titleH1 = card.querySelector(s.titleH1)?.textContent?.trim();
|
|
@@ -37938,7 +37938,7 @@ function renderTable(table) {
|
|
|
37938
37938
|
}
|
|
37939
37939
|
function renderWorkflowReport(input) {
|
|
37940
37940
|
const warnings = input.warnings?.length ? `<section class="warnings"><h2>Warnings</h2><ul>${input.warnings.map((w) => `<li>${escapeHtml(w)}</li>`).join("")}</ul></section>` : "";
|
|
37941
|
-
const sections = (input.sections ?? []).map((
|
|
37941
|
+
const sections = (input.sections ?? []).map((section2) => `<section><h2>${escapeHtml(section2.title)}</h2><p>${escapeHtml(section2.body)}</p></section>`).join("\n");
|
|
37942
37942
|
const tables = (input.tables ?? []).map(renderTable).join("\n");
|
|
37943
37943
|
return [
|
|
37944
37944
|
"<!doctype html>",
|
|
@@ -41371,7 +41371,7 @@ var PACKAGE_VERSION;
|
|
|
41371
41371
|
var init_version = __esm({
|
|
41372
41372
|
"src/version.ts"() {
|
|
41373
41373
|
"use strict";
|
|
41374
|
-
PACKAGE_VERSION = "0.
|
|
41374
|
+
PACKAGE_VERSION = "0.47.0";
|
|
41375
41375
|
}
|
|
41376
41376
|
});
|
|
41377
41377
|
|
|
@@ -41454,6 +41454,18 @@ seam is noted so you can chain them.
|
|
|
41454
41454
|
Use saved filters when a person wants their MCP to operate inside a reading room, trail, source scope,
|
|
41455
41455
|
category, tag bundle, media constraint, or other personalized subset of the shared Commons graph.
|
|
41456
41456
|
|
|
41457
|
+
## Transparent Commons user publications
|
|
41458
|
+
- A user-owned editorial publication is separate from the neutral public wiki. Start with
|
|
41459
|
+
**commons_prepare_publication** to normalize the requested subdomain, check availability, and read the live
|
|
41460
|
+
ownership contract. Then call **commons_validate_publication** with operation \`claim\` before
|
|
41461
|
+
**commons_claim_publication**.
|
|
41462
|
+
- Each account may claim one stable name at \`https://{name}.transparent-commons.cc\`. Claims require an
|
|
41463
|
+
idempotency key and never publish content by themselves.
|
|
41464
|
+
- To publish, use **editorial_reading_room_guide** when needed, research and author the complete source-grounded
|
|
41465
|
+
edition, validate it with **commons_validate_publication** operation \`publish\`, then call
|
|
41466
|
+
**commons_publish_editorial**. The publish result returns the permanent publication, archive, and edition URLs.
|
|
41467
|
+
- Use **commons_get_publication** to recover the caller's publication and current edition revisions. Existing
|
|
41468
|
+
edition edits require the returned baseRevision. Only the account that claimed the subdomain can publish to it.
|
|
41457
41469
|
|
|
41458
41470
|
## Google Maps
|
|
41459
41471
|
- Find multiple places/competitors/prospects -> **maps_search** (returns \`results[]\` with name,
|
|
@@ -41925,7 +41937,7 @@ async function buildMetaAdCreativeMediaResult(executor, input) {
|
|
|
41925
41937
|
publicPostCandidateUrl ? `**Public post candidate:** ${publicPostCandidateUrl} (unverified; dark/paused ads may not be public)` : "",
|
|
41926
41938
|
nextActions.length ? `
|
|
41927
41939
|
## Recommended next calls
|
|
41928
|
-
${nextActions.map((
|
|
41940
|
+
${nextActions.map((action2) => `- \`${String(action2["tool"] ?? "")}\`: ${String(action2["reason"] ?? "")}`).join("\n")}` : "",
|
|
41929
41941
|
warnings.length ? `
|
|
41930
41942
|
## Warnings
|
|
41931
41943
|
${warnings.map((warning) => `- ${warning}`).join("\n")}` : "",
|
|
@@ -41972,7 +41984,7 @@ var init_meta_ad_creative_media = __esm({
|
|
|
41972
41984
|
});
|
|
41973
41985
|
|
|
41974
41986
|
// src/scheduled-artifacts/contracts.ts
|
|
41975
|
-
var import_zod41, ScheduledArtifactSelectionSchema, ArtifactTemplateConfigSchema, EditorialReadingRoomV1InputSchema, CreateArtifactTemplateInputSchema, UpdateArtifactTemplateInputSchema, ArtifactTemplateVersionSchema, ArtifactTemplateSchema, ListArtifactTemplatesResponseSchema, ScheduledRunNoteOutputSchema, ScheduledRunArtifactOutputSchema, ScheduledRunResultSchema, ListScheduledRunsQuerySchema, ListScheduledRunsResponseSchema, GetScheduledRunResponseSchema, InternalScheduledArtifactRenderRequestSchema, CreateScheduledRunViewLinkInputSchema, PublicScheduledRunTokenSchema, ApiErrorResponseSchema,
|
|
41987
|
+
var import_zod41, ScheduledArtifactSelectionSchema, EditorialArtifactTemplateConfigSchema, PersonalAuthorityFeatureFlagsSchema, PersonalAuthorityTemplateConfigSchema, ArtifactTemplateConfigSchema, EditorialReadingRoomV1InputSchema, PersonalAuthorityActionSchema, PersonalAuthorityV1InputSchema, TemplateIdentityFields, CreateArtifactTemplateInputSchema, UpdateArtifactTemplateInputSchema, ArtifactTemplateVersionBase, ArtifactTemplateVersionSchema, ArtifactTemplateSchema, ListArtifactTemplatesResponseSchema, ScheduledRunNoteOutputSchema, ScheduledRunArtifactOutputSchema, ScheduledRunResultSchema, ListScheduledRunsQuerySchema, ListScheduledRunsResponseSchema, GetScheduledRunResponseSchema, InternalScheduledArtifactRenderRequestBase, InternalScheduledArtifactRenderRequestSchema, CreateScheduledRunViewLinkInputSchema, PublicScheduledRunTokenSchema, ApiErrorResponseSchema, EDITORIAL_READING_ROOM_TEMPLATE_PRESET, PERSONAL_AUTHORITY_TEMPLATE_PRESET;
|
|
41976
41988
|
var init_contracts = __esm({
|
|
41977
41989
|
"src/scheduled-artifacts/contracts.ts"() {
|
|
41978
41990
|
"use strict";
|
|
@@ -41985,13 +41997,33 @@ var init_contracts = __esm({
|
|
|
41985
41997
|
templateVersionId: import_zod41.z.string().uuid()
|
|
41986
41998
|
}).strict()
|
|
41987
41999
|
]);
|
|
41988
|
-
|
|
42000
|
+
EditorialArtifactTemplateConfigSchema = import_zod41.z.object({
|
|
41989
42001
|
theme: import_zod41.z.enum(["paper", "ink", "warm"]),
|
|
41990
42002
|
density: import_zod41.z.enum(["comfortable", "compact"]),
|
|
41991
42003
|
showSourceRail: import_zod41.z.boolean(),
|
|
41992
42004
|
showGeneratedAt: import_zod41.z.boolean(),
|
|
41993
42005
|
brandName: import_zod41.z.string().trim().min(1).max(80).optional()
|
|
41994
42006
|
}).strict();
|
|
42007
|
+
PersonalAuthorityFeatureFlagsSchema = import_zod41.z.object({
|
|
42008
|
+
navigation: import_zod41.z.boolean(),
|
|
42009
|
+
socialLinks: import_zod41.z.boolean(),
|
|
42010
|
+
authority: import_zod41.z.boolean(),
|
|
42011
|
+
consultation: import_zod41.z.boolean(),
|
|
42012
|
+
learning: import_zod41.z.boolean(),
|
|
42013
|
+
services: import_zod41.z.boolean(),
|
|
42014
|
+
proof: import_zod41.z.boolean(),
|
|
42015
|
+
finalCta: import_zod41.z.boolean()
|
|
42016
|
+
}).strict();
|
|
42017
|
+
PersonalAuthorityTemplateConfigSchema = import_zod41.z.object({
|
|
42018
|
+
theme: import_zod41.z.enum(["blue", "slate", "monochrome"]),
|
|
42019
|
+
showGeneratedAt: import_zod41.z.boolean(),
|
|
42020
|
+
brandName: import_zod41.z.string().trim().min(1).max(80).optional(),
|
|
42021
|
+
featureFlags: PersonalAuthorityFeatureFlagsSchema
|
|
42022
|
+
}).strict();
|
|
42023
|
+
ArtifactTemplateConfigSchema = import_zod41.z.union([
|
|
42024
|
+
EditorialArtifactTemplateConfigSchema,
|
|
42025
|
+
PersonalAuthorityTemplateConfigSchema
|
|
42026
|
+
]);
|
|
41995
42027
|
EditorialReadingRoomV1InputSchema = import_zod41.z.object({
|
|
41996
42028
|
title: import_zod41.z.string().trim().min(1).max(300),
|
|
41997
42029
|
dek: import_zod41.z.string().trim().max(1e3).optional(),
|
|
@@ -42013,7 +42045,7 @@ var init_contracts = __esm({
|
|
|
42013
42045
|
}).strict()).max(1e3).optional()
|
|
42014
42046
|
}).strict().superRefine((input, ctx) => {
|
|
42015
42047
|
const markdownBytes = input.sections.reduce(
|
|
42016
|
-
(total,
|
|
42048
|
+
(total, section2) => total + Buffer.byteLength(section2.markdown),
|
|
42017
42049
|
0
|
|
42018
42050
|
);
|
|
42019
42051
|
if (markdownBytes > 2e6) {
|
|
@@ -42024,25 +42056,104 @@ var init_contracts = __esm({
|
|
|
42024
42056
|
});
|
|
42025
42057
|
}
|
|
42026
42058
|
});
|
|
42027
|
-
|
|
42028
|
-
|
|
42059
|
+
PersonalAuthorityActionSchema = import_zod41.z.object({
|
|
42060
|
+
label: import_zod41.z.string().trim().min(1).max(120),
|
|
42061
|
+
href: import_zod41.z.string().trim().min(1).max(2e3)
|
|
42062
|
+
}).strict();
|
|
42063
|
+
PersonalAuthorityV1InputSchema = import_zod41.z.object({
|
|
42064
|
+
name: import_zod41.z.string().trim().min(1).max(160),
|
|
42065
|
+
professionalTitle: import_zod41.z.string().trim().min(1).max(300),
|
|
42066
|
+
summary: import_zod41.z.string().trim().min(1).max(1500),
|
|
42067
|
+
location: import_zod41.z.string().trim().max(160).optional(),
|
|
42068
|
+
email: import_zod41.z.string().trim().email().max(320).optional(),
|
|
42069
|
+
phone: import_zod41.z.string().trim().max(80).optional(),
|
|
42070
|
+
primaryAction: PersonalAuthorityActionSchema,
|
|
42071
|
+
secondaryAction: PersonalAuthorityActionSchema.optional(),
|
|
42072
|
+
socialLinks: import_zod41.z.array(import_zod41.z.object({
|
|
42073
|
+
label: import_zod41.z.string().trim().min(1).max(60),
|
|
42074
|
+
href: import_zod41.z.string().trim().min(1).max(2e3)
|
|
42075
|
+
}).strict()).max(8).default([]),
|
|
42076
|
+
authority: import_zod41.z.object({
|
|
42077
|
+
heading: import_zod41.z.string().trim().min(1).max(500),
|
|
42078
|
+
paragraphs: import_zod41.z.array(import_zod41.z.string().trim().min(1).max(2e3)).min(1).max(6)
|
|
42079
|
+
}).strict().optional(),
|
|
42080
|
+
consultation: import_zod41.z.object({
|
|
42081
|
+
eyebrow: import_zod41.z.string().trim().max(120).optional(),
|
|
42082
|
+
heading: import_zod41.z.string().trim().min(1).max(400),
|
|
42083
|
+
summary: import_zod41.z.string().trim().min(1).max(1e3),
|
|
42084
|
+
action: PersonalAuthorityActionSchema
|
|
42085
|
+
}).strict().optional(),
|
|
42086
|
+
learning: import_zod41.z.object({
|
|
42087
|
+
heading: import_zod41.z.string().trim().min(1).max(400),
|
|
42088
|
+
summary: import_zod41.z.string().trim().max(1e3).optional(),
|
|
42089
|
+
topics: import_zod41.z.array(import_zod41.z.object({
|
|
42090
|
+
title: import_zod41.z.string().trim().min(1).max(160),
|
|
42091
|
+
headline: import_zod41.z.string().trim().min(1).max(300),
|
|
42092
|
+
summary: import_zod41.z.string().trim().min(1).max(1500),
|
|
42093
|
+
href: import_zod41.z.string().trim().min(1).max(2e3).optional()
|
|
42094
|
+
}).strict()).min(1).max(12)
|
|
42095
|
+
}).strict().optional(),
|
|
42096
|
+
services: import_zod41.z.object({
|
|
42097
|
+
heading: import_zod41.z.string().trim().min(1).max(400),
|
|
42098
|
+
summary: import_zod41.z.string().trim().max(1e3).optional(),
|
|
42099
|
+
offers: import_zod41.z.array(import_zod41.z.object({
|
|
42100
|
+
title: import_zod41.z.string().trim().min(1).max(160),
|
|
42101
|
+
description: import_zod41.z.string().trim().min(1).max(1500),
|
|
42102
|
+
action: PersonalAuthorityActionSchema.optional()
|
|
42103
|
+
}).strict()).min(1).max(6)
|
|
42104
|
+
}).strict().optional(),
|
|
42105
|
+
proof: import_zod41.z.object({
|
|
42106
|
+
heading: import_zod41.z.string().trim().min(1).max(400),
|
|
42107
|
+
summary: import_zod41.z.string().trim().max(1e3).optional(),
|
|
42108
|
+
testimonials: import_zod41.z.array(import_zod41.z.object({
|
|
42109
|
+
quote: import_zod41.z.string().trim().min(1).max(1500),
|
|
42110
|
+
person: import_zod41.z.string().trim().min(1).max(160),
|
|
42111
|
+
role: import_zod41.z.string().trim().max(200).optional()
|
|
42112
|
+
}).strict()).min(1).max(12)
|
|
42113
|
+
}).strict().optional(),
|
|
42114
|
+
finalCta: import_zod41.z.object({
|
|
42115
|
+
eyebrow: import_zod41.z.string().trim().max(120).optional(),
|
|
42116
|
+
heading: import_zod41.z.string().trim().min(1).max(400),
|
|
42117
|
+
summary: import_zod41.z.string().trim().max(1e3).optional(),
|
|
42118
|
+
action: PersonalAuthorityActionSchema
|
|
42119
|
+
}).strict().optional()
|
|
42120
|
+
}).strict();
|
|
42121
|
+
TemplateIdentityFields = {
|
|
42029
42122
|
name: import_zod41.z.string().trim().min(1).max(120),
|
|
42030
42123
|
description: import_zod41.z.string().trim().max(500).default(""),
|
|
42031
|
-
config: ArtifactTemplateConfigSchema,
|
|
42032
42124
|
authoringInstructions: import_zod41.z.string().trim().max(4e3)
|
|
42033
|
-
}
|
|
42034
|
-
|
|
42035
|
-
|
|
42125
|
+
};
|
|
42126
|
+
CreateArtifactTemplateInputSchema = import_zod41.z.discriminatedUnion("presetKey", [
|
|
42127
|
+
import_zod41.z.object({
|
|
42128
|
+
presetKey: import_zod41.z.literal("editorial_reading_room_v1"),
|
|
42129
|
+
...TemplateIdentityFields,
|
|
42130
|
+
config: EditorialArtifactTemplateConfigSchema
|
|
42131
|
+
}).strict(),
|
|
42132
|
+
import_zod41.z.object({
|
|
42133
|
+
presetKey: import_zod41.z.literal("personal_authority_v1"),
|
|
42134
|
+
...TemplateIdentityFields,
|
|
42135
|
+
config: PersonalAuthorityTemplateConfigSchema
|
|
42136
|
+
}).strict()
|
|
42137
|
+
]);
|
|
42138
|
+
UpdateArtifactTemplateInputSchema = import_zod41.z.object({
|
|
42139
|
+
name: TemplateIdentityFields.name.optional(),
|
|
42140
|
+
description: import_zod41.z.string().trim().max(500).optional(),
|
|
42141
|
+
config: ArtifactTemplateConfigSchema.optional(),
|
|
42142
|
+
authoringInstructions: TemplateIdentityFields.authoringInstructions.optional()
|
|
42143
|
+
}).strict().refine((input) => Object.keys(input).length > 0, "At least one field is required");
|
|
42144
|
+
ArtifactTemplateVersionBase = {
|
|
42036
42145
|
templateVersionId: import_zod41.z.string().uuid(),
|
|
42037
42146
|
templateId: import_zod41.z.string().uuid(),
|
|
42038
42147
|
version: import_zod41.z.number().int().positive(),
|
|
42039
|
-
rendererKey: import_zod41.z.literal("editorial_reading_room_v1"),
|
|
42040
42148
|
rendererVersion: import_zod41.z.literal(1),
|
|
42041
42149
|
inputContractVersion: import_zod41.z.literal(1),
|
|
42042
|
-
config: ArtifactTemplateConfigSchema,
|
|
42043
42150
|
authoringInstructions: import_zod41.z.string().max(4e3),
|
|
42044
42151
|
createdAt: import_zod41.z.string().datetime()
|
|
42045
|
-
}
|
|
42152
|
+
};
|
|
42153
|
+
ArtifactTemplateVersionSchema = import_zod41.z.discriminatedUnion("rendererKey", [
|
|
42154
|
+
import_zod41.z.object({ ...ArtifactTemplateVersionBase, rendererKey: import_zod41.z.literal("editorial_reading_room_v1"), config: EditorialArtifactTemplateConfigSchema }).strict(),
|
|
42155
|
+
import_zod41.z.object({ ...ArtifactTemplateVersionBase, rendererKey: import_zod41.z.literal("personal_authority_v1"), config: PersonalAuthorityTemplateConfigSchema }).strict()
|
|
42156
|
+
]);
|
|
42046
42157
|
ArtifactTemplateSchema = import_zod41.z.object({
|
|
42047
42158
|
templateId: import_zod41.z.string().uuid(),
|
|
42048
42159
|
name: import_zod41.z.string().min(1).max(120),
|
|
@@ -42057,9 +42168,15 @@ var init_contracts = __esm({
|
|
|
42057
42168
|
ListArtifactTemplatesResponseSchema = import_zod41.z.object({
|
|
42058
42169
|
ok: import_zod41.z.literal(true),
|
|
42059
42170
|
presets: import_zod41.z.array(import_zod41.z.object({
|
|
42060
|
-
presetKey: import_zod41.z.
|
|
42171
|
+
presetKey: import_zod41.z.enum(["editorial_reading_room_v1", "personal_authority_v1"]),
|
|
42061
42172
|
name: import_zod41.z.string(),
|
|
42062
42173
|
description: import_zod41.z.string(),
|
|
42174
|
+
mark: import_zod41.z.string().min(1).max(4),
|
|
42175
|
+
featureFlags: import_zod41.z.array(import_zod41.z.object({
|
|
42176
|
+
key: import_zod41.z.string().min(1),
|
|
42177
|
+
label: import_zod41.z.string().min(1),
|
|
42178
|
+
description: import_zod41.z.string().min(1)
|
|
42179
|
+
}).strict()),
|
|
42063
42180
|
defaultConfig: ArtifactTemplateConfigSchema
|
|
42064
42181
|
}).strict()),
|
|
42065
42182
|
templates: import_zod41.z.array(ArtifactTemplateSchema)
|
|
@@ -42074,7 +42191,7 @@ var init_contracts = __esm({
|
|
|
42074
42191
|
artifactId: import_zod41.z.string().min(1).max(1e3),
|
|
42075
42192
|
templateId: import_zod41.z.string().uuid(),
|
|
42076
42193
|
templateVersionId: import_zod41.z.string().uuid(),
|
|
42077
|
-
rendererKey: import_zod41.z.
|
|
42194
|
+
rendererKey: import_zod41.z.enum(["editorial_reading_room_v1", "personal_authority_v1"]),
|
|
42078
42195
|
rendererVersion: import_zod41.z.literal(1),
|
|
42079
42196
|
mimeType: import_zod41.z.literal("text/html"),
|
|
42080
42197
|
title: import_zod41.z.string().min(1).max(300),
|
|
@@ -42126,18 +42243,29 @@ var init_contracts = __esm({
|
|
|
42126
42243
|
ok: import_zod41.z.literal(true),
|
|
42127
42244
|
run: ScheduledRunResultSchema
|
|
42128
42245
|
}).strict();
|
|
42129
|
-
|
|
42246
|
+
InternalScheduledArtifactRenderRequestBase = {
|
|
42130
42247
|
identity: import_zod41.z.string().min(1).max(320),
|
|
42131
42248
|
ownerId: import_zod41.z.string().regex(/^[a-f0-9]{24}$/),
|
|
42132
42249
|
runId: import_zod41.z.string().min(1).max(200),
|
|
42133
42250
|
scheduleId: import_zod41.z.string().uuid(),
|
|
42134
42251
|
templateId: import_zod41.z.string().uuid(),
|
|
42135
42252
|
templateVersionId: import_zod41.z.string().uuid(),
|
|
42136
|
-
|
|
42137
|
-
|
|
42138
|
-
|
|
42139
|
-
|
|
42140
|
-
|
|
42253
|
+
rendererVersion: import_zod41.z.literal(1)
|
|
42254
|
+
};
|
|
42255
|
+
InternalScheduledArtifactRenderRequestSchema = import_zod41.z.discriminatedUnion("rendererKey", [
|
|
42256
|
+
import_zod41.z.object({
|
|
42257
|
+
...InternalScheduledArtifactRenderRequestBase,
|
|
42258
|
+
rendererKey: import_zod41.z.literal("editorial_reading_room_v1"),
|
|
42259
|
+
config: EditorialArtifactTemplateConfigSchema,
|
|
42260
|
+
input: EditorialReadingRoomV1InputSchema
|
|
42261
|
+
}).strict(),
|
|
42262
|
+
import_zod41.z.object({
|
|
42263
|
+
...InternalScheduledArtifactRenderRequestBase,
|
|
42264
|
+
rendererKey: import_zod41.z.literal("personal_authority_v1"),
|
|
42265
|
+
config: PersonalAuthorityTemplateConfigSchema,
|
|
42266
|
+
input: PersonalAuthorityV1InputSchema
|
|
42267
|
+
}).strict()
|
|
42268
|
+
]);
|
|
42141
42269
|
CreateScheduledRunViewLinkInputSchema = import_zod41.z.object({
|
|
42142
42270
|
artifactId: import_zod41.z.string().min(1).max(1e3),
|
|
42143
42271
|
expiresInDays: import_zod41.z.number().int().min(1).max(30).default(7)
|
|
@@ -42160,10 +42288,15 @@ var init_contracts = __esm({
|
|
|
42160
42288
|
]),
|
|
42161
42289
|
requestId: import_zod41.z.string().max(200).optional()
|
|
42162
42290
|
}).strict();
|
|
42163
|
-
|
|
42291
|
+
EDITORIAL_READING_ROOM_TEMPLATE_PRESET = {
|
|
42164
42292
|
presetKey: "editorial_reading_room_v1",
|
|
42165
42293
|
name: "Editorial Reading Room",
|
|
42166
42294
|
description: "A self-contained, source-labelled reading experience for scheduled research and reports.",
|
|
42295
|
+
mark: "Aa",
|
|
42296
|
+
featureFlags: [
|
|
42297
|
+
{ key: "showSourceRail", label: "Source rail", description: "Keep source references visible beside the report." },
|
|
42298
|
+
{ key: "showGeneratedAt", label: "Generated time", description: "Show when the report was rendered." }
|
|
42299
|
+
],
|
|
42167
42300
|
defaultConfig: {
|
|
42168
42301
|
theme: "paper",
|
|
42169
42302
|
density: "comfortable",
|
|
@@ -42171,11 +42304,41 @@ var init_contracts = __esm({
|
|
|
42171
42304
|
showGeneratedAt: true
|
|
42172
42305
|
}
|
|
42173
42306
|
};
|
|
42307
|
+
PERSONAL_AUTHORITY_TEMPLATE_PRESET = {
|
|
42308
|
+
presetKey: "personal_authority_v1",
|
|
42309
|
+
name: "Personal Authority",
|
|
42310
|
+
description: "A flexible person-focused website for practitioners, founders, leaders, authors, coaches, and other professionals.",
|
|
42311
|
+
mark: "M",
|
|
42312
|
+
featureFlags: [
|
|
42313
|
+
{ key: "navigation", label: "Navigation", description: "Show the responsive header and section navigation." },
|
|
42314
|
+
{ key: "socialLinks", label: "Social links", description: "Show professional and media profile links." },
|
|
42315
|
+
{ key: "authority", label: "Experience", description: "Show the background and authority section." },
|
|
42316
|
+
{ key: "consultation", label: "Consultation", description: "Show an early invitation to connect." },
|
|
42317
|
+
{ key: "learning", label: "Ideas and resources", description: "Show educational topics and useful resources." },
|
|
42318
|
+
{ key: "services", label: "Ways to work together", description: "Show services, appointments, or offers." },
|
|
42319
|
+
{ key: "proof", label: "Proof", description: "Show testimonials, outcomes, or affiliations." },
|
|
42320
|
+
{ key: "finalCta", label: "Final invitation", description: "Show the closing contact call to action." }
|
|
42321
|
+
],
|
|
42322
|
+
defaultConfig: {
|
|
42323
|
+
theme: "blue",
|
|
42324
|
+
showGeneratedAt: false,
|
|
42325
|
+
featureFlags: {
|
|
42326
|
+
navigation: true,
|
|
42327
|
+
socialLinks: true,
|
|
42328
|
+
authority: true,
|
|
42329
|
+
consultation: true,
|
|
42330
|
+
learning: true,
|
|
42331
|
+
services: true,
|
|
42332
|
+
proof: true,
|
|
42333
|
+
finalCta: true
|
|
42334
|
+
}
|
|
42335
|
+
}
|
|
42336
|
+
};
|
|
42174
42337
|
}
|
|
42175
42338
|
});
|
|
42176
42339
|
|
|
42177
42340
|
// src/mcp/mcp-tool-schemas.ts
|
|
42178
|
-
var import_zod42, WEBSITE_URL_OR_DOMAIN_ERROR, WebsiteUrlOrDomainSchema, HarvestPaaInputSchema, ExtractUrlBaseInputSchema, ExtractUrlInputSchema, ExtractUrlLocalInputSchema, DiffPageBaseInputSchema, DiffPageInputSchema, DiffPageLocalInputSchema, MapSiteUrlsInputSchema, MapWaybackSnapshotsInputSchema, ExtractSiteInputSchema, AuditSiteInputSchema, CheckSiteExportInputSchema, ArchiveReadInputSchema, YoutubeHarvestInputSchema, YoutubeTranscribeInputSchema, FacebookPageIntelInputSchema, FacebookAdSearchInputSchema, RedditThreadInputSchema, RedditTrendingInputSchema, VideoFrameAnalysisInputSchema, VideoFrameAnalysisStatusInputSchema, FacebookAdTranscribeInputSchema, FacebookVideoTranscribeInputSchema, GoogleAdsSearchInputSchema, GoogleAdsPageIntelInputSchema, GoogleAdsTranscribeInputSchema, InstagramProfileContentInputSchema, InstagramMediaDownloadInputSchema, MapsPlaceIntelInputSchema, TrustpilotReviewsInputSchema, G2ReviewsInputSchema, ReviewCardSchema, MapsSearchInputSchema, DirectoryWorkflowInputSchema, LocationMarketsInputSchema, CommonsSearchEntitiesInputSchema, CommonsGetEntityInputSchema, CommonsFeaturedImageInputSchema, CommonsMediaInputSchema, CommonsCitationInputSchema, CommonsSourceInputSchema, CommonsRelatedLinkInputSchema, CommonsPrepareEntityInputSchema, CommonsSubmitEntityInputSchema, CommonsValidateEntityInputSchema, CommonsGetEntityLedgerInputSchema, CommonsSaveFilterInputSchema, CommonsListFiltersInputSchema, CommonsListNeedsLinksInputSchema, CommonsGenericOutputSchema, DirectoryWorkflowStatusInputSchema, LocalSourcebookSubmitInputSchema, LocalSourcebookCategorySchema, LocalSourcebookSchemaTypeInputSchema, LocalSourcebookTagCandidateObjectSchema, LocalSourcebookTagDecisionObjectSchema, LocalSourcebookIdentityObjectSchema, GetLocalSourcebookContractInputSchema, ListLocalSourcebookTagsInputSchema, ResolveLocalSourcebookTagsInputSchema, PrepareLocalSourcebookWriteInputSchema, ValidateLocalSourcebookWriteInputSchema, LocalSourcebookCaptureInputSchema, LocalSourcebookSubmissionStatusInputSchema, LocalSourcebookRefreshInputSchema, LocalSourcebookOutputSchema, ArtifactPointerOutputSchema, EditorialReadingRoomSiteSchema, EditorialReadingRoomArticleSchema, EditorialReadingRoomGuideInputSchema, EditorialReadingRoomGuideOutputSchema, CreateEditorialReadingRoomInputSchema, EditorialReadingRoomArtifactSchema, CreateEditorialReadingRoomOutputSchema, RenewEditorialReadingRoomDownloadInputSchema, RenewEditorialReadingRoomDownloadOutputSchema, RankTrackerModeSchema, RankTrackerBlueprintInputSchema, NullableString, MapsSearchAttemptOutput, MapsSearchOutputSchema, DirectoryMapsBusinessOutput, DirectoryCsvArtifactOutput, DirectoryWorkflowOutputSchema, LocationDatasetProvenanceOutput, LocationMarketsOutputSchema, RankTrackerToolPlanOutput, RankTrackerTableOutput, RankTrackerCronJobOutput, RankTrackerBlueprintOutputSchema, OrganicResultOutput, AiOverviewOutput, EntityIdsOutput, HarvestPaaOutputSchema, SearchSerpOutputSchema, ExtractUrlOutputSchema, DiffPageOutputSchema, ExtractSiteOutputSchema, AuditSiteOutputSchema, CheckSiteExportOutputSchema, ArchiveEntryOutputSchema, ArchiveReadOutputSchema, MapsPlaceIntelOutputSchema, TrustpilotReviewsOutputSchema, G2ReviewsOutputSchema, CreditsInfoOutputSchema, MapSiteUrlsOutputSchema, WaybackCaptureOutputSchema, MapWaybackSnapshotsOutputSchema, YoutubeHarvestOutputSchema, FacebookAdSearchOutputSchema, VideoFrameAnalysisOutputSchema, VideoFrameAnalysisStatusOutputSchema, RedditThreadOutputSchema, RedditTrendingOutputSchema, FacebookPageIntelOutputSchema, GoogleAdsSearchOutputSchema, GoogleAdsPageIntelOutputSchema, TranscriptSignalOutput, FacebookVideoTranscribeOutputSchema, TranscriptChunkOutput, InstagramBrowserOutput, InstagramPaginationOutput, InstagramProfileContentOutputSchema, InstagramMediaTrackOutput, InstagramDownloadOutput, InstagramMediaDownloadOutputSchema, YoutubeTranscribeOutputSchema, FacebookAdTranscribeOutputSchema, GoogleAdsTranscribeOutputSchema, CaptureSerpSnapshotOutputSchema, CaptureSerpPageSnapshotsOutputSchema, CreditsInfoInputSchema, WorkflowIdSchema2, WorkflowListInputSchema, WorkflowSuggestInputSchema, WorkflowRunInputSchema, WorkflowStepInputSchema, WorkflowStatusInputSchema, WorkflowArtifactReadInputSchema, WorkflowRecipeOutput, WorkflowDefinitionOutput, WorkflowArtifactOutput, WorkflowListOutputSchema, WorkflowSuggestOutputSchema, WorkflowRunOutputSchema, WorkflowStepOutputSchema, WorkflowStatusOutputSchema, WorkflowArtifactReadOutputSchema, SearchSerpInputSchema, CaptureSerpSnapshotInputSchema, ScreenshotInputSchema, CaptureSerpPageSnapshotsInputSchema, ReportArtifactReadInputSchema, ReportArtifactReadOutputSchema, ListServiceConnectionsInputSchema, ListServiceConnectionsOutputSchema, TestServiceConnectionInputSchema, TestServiceConnectionOutputSchema, ReadServiceConnectionInputSchema, ReadServiceConnectionOutputSchema, MetaAdCreativeMediaInputSchema, MetaAdCreativeMediaOutputSchema, ImportServiceConnectionToMemoryInputSchema, ImportServiceConnectionToMemoryOutputSchema, DescribeServiceConnectionToolInputSchema, DescribeServiceConnectionToolOutputSchema, ConnectedDataContinuationSchema, ExportConnectedServiceDataInputSchema, ConnectedDataArtifactSchema, ExportConnectedServiceDataOutputSchema, SearchConsoleTableColumnSchema, SearchConsoleTableFilterSchema, ExportSearchConsoleTableDataInputSchema, ExportSearchConsoleTableDataOutputSchema, RenewConnectedDataExportDownloadInputSchema, RenewConnectedDataExportDownloadOutputSchema, CallServiceConnectionActionInputSchema, CallServiceConnectionActionOutputSchema, SetScheduledActionConnectionsInputSchema, SetScheduledActionConnectionsOutputSchema, SlackSendMessageInputSchema, SlackSendMessageOutputSchema, GmailSendMessageInputSchema, GmailSendMessageOutputSchema, GmailSearchContactsInputSchema, GmailSearchContactsOutputSchema, GoogleCalendarCreateEventInputSchema, GoogleCalendarCreateEventOutputSchema, ZoomCreateMeetingInputSchema, ZoomCreateMeetingOutputSchema;
|
|
42341
|
+
var import_zod42, WEBSITE_URL_OR_DOMAIN_ERROR, WebsiteUrlOrDomainSchema, HarvestPaaInputSchema, ExtractUrlBaseInputSchema, ExtractUrlInputSchema, ExtractUrlLocalInputSchema, DiffPageBaseInputSchema, DiffPageInputSchema, DiffPageLocalInputSchema, MapSiteUrlsInputSchema, MapWaybackSnapshotsInputSchema, ExtractSiteInputSchema, AuditSiteInputSchema, CheckSiteExportInputSchema, ArchiveReadInputSchema, YoutubeHarvestInputSchema, YoutubeTranscribeInputSchema, FacebookPageIntelInputSchema, FacebookAdSearchInputSchema, RedditThreadInputSchema, RedditTrendingInputSchema, VideoFrameAnalysisInputSchema, VideoFrameAnalysisStatusInputSchema, FacebookAdTranscribeInputSchema, FacebookVideoTranscribeInputSchema, GoogleAdsSearchInputSchema, GoogleAdsPageIntelInputSchema, GoogleAdsTranscribeInputSchema, InstagramProfileContentInputSchema, InstagramMediaDownloadInputSchema, MapsPlaceIntelInputSchema, TrustpilotReviewsInputSchema, G2ReviewsInputSchema, ReviewCardSchema, MapsSearchInputSchema, DirectoryWorkflowInputSchema, LocationMarketsInputSchema, CommonsSearchEntitiesInputSchema, CommonsGetEntityInputSchema, CommonsFeaturedImageInputSchema, CommonsMediaInputSchema, CommonsCitationInputSchema, CommonsSourceInputSchema, CommonsRelatedLinkInputSchema, CommonsPrepareEntityInputSchema, CommonsSubmitEntityInputSchema, CommonsValidateEntityInputSchema, CommonsGetEntityLedgerInputSchema, CommonsSaveFilterInputSchema, CommonsListFiltersInputSchema, CommonsListNeedsLinksInputSchema, CommonsGenericOutputSchema, DirectoryWorkflowStatusInputSchema, LocalSourcebookSubmitInputSchema, LocalSourcebookCategorySchema, LocalSourcebookSchemaTypeInputSchema, LocalSourcebookTagCandidateObjectSchema, LocalSourcebookTagDecisionObjectSchema, LocalSourcebookIdentityObjectSchema, GetLocalSourcebookContractInputSchema, ListLocalSourcebookTagsInputSchema, ResolveLocalSourcebookTagsInputSchema, PrepareLocalSourcebookWriteInputSchema, ValidateLocalSourcebookWriteInputSchema, LocalSourcebookCaptureInputSchema, LocalSourcebookSubmissionStatusInputSchema, LocalSourcebookRefreshInputSchema, LocalSourcebookOutputSchema, ArtifactPointerOutputSchema, EditorialReadingRoomSiteSchema, EditorialReadingRoomArticleSchema, EditorialReadingRoomGuideInputSchema, EditorialReadingRoomGuideOutputSchema, CreateEditorialReadingRoomInputSchema, EditorialReadingRoomArtifactSchema, CreateEditorialReadingRoomOutputSchema, RenewEditorialReadingRoomDownloadInputSchema, RenewEditorialReadingRoomDownloadOutputSchema, CommonsPublicationSubdomainSchema, CommonsPreparePublicationInputSchema, CommonsValidatePublicationInputSchema, CommonsClaimPublicationInputSchema, CommonsPublishEditorialInputSchema, CommonsGetPublicationInputSchema, RankTrackerModeSchema, RankTrackerBlueprintInputSchema, NullableString, MapsSearchAttemptOutput, MapsSearchOutputSchema, DirectoryMapsBusinessOutput, DirectoryCsvArtifactOutput, DirectoryWorkflowOutputSchema, LocationDatasetProvenanceOutput, LocationMarketsOutputSchema, RankTrackerToolPlanOutput, RankTrackerTableOutput, RankTrackerCronJobOutput, RankTrackerBlueprintOutputSchema, OrganicResultOutput, AiOverviewOutput, EntityIdsOutput, HarvestPaaOutputSchema, SearchSerpOutputSchema, ExtractUrlOutputSchema, DiffPageOutputSchema, ExtractSiteOutputSchema, AuditSiteOutputSchema, CheckSiteExportOutputSchema, ArchiveEntryOutputSchema, ArchiveReadOutputSchema, MapsPlaceIntelOutputSchema, TrustpilotReviewsOutputSchema, G2ReviewsOutputSchema, CreditsInfoOutputSchema, MapSiteUrlsOutputSchema, WaybackCaptureOutputSchema, MapWaybackSnapshotsOutputSchema, YoutubeHarvestOutputSchema, FacebookAdSearchOutputSchema, VideoFrameAnalysisOutputSchema, VideoFrameAnalysisStatusOutputSchema, RedditThreadOutputSchema, RedditTrendingOutputSchema, FacebookPageIntelOutputSchema, GoogleAdsSearchOutputSchema, GoogleAdsPageIntelOutputSchema, TranscriptSignalOutput, FacebookVideoTranscribeOutputSchema, TranscriptChunkOutput, InstagramBrowserOutput, InstagramPaginationOutput, InstagramProfileContentOutputSchema, InstagramMediaTrackOutput, InstagramDownloadOutput, InstagramMediaDownloadOutputSchema, YoutubeTranscribeOutputSchema, FacebookAdTranscribeOutputSchema, GoogleAdsTranscribeOutputSchema, CaptureSerpSnapshotOutputSchema, CaptureSerpPageSnapshotsOutputSchema, CreditsInfoInputSchema, WorkflowIdSchema2, WorkflowListInputSchema, WorkflowSuggestInputSchema, WorkflowRunInputSchema, WorkflowStepInputSchema, WorkflowStatusInputSchema, WorkflowArtifactReadInputSchema, WorkflowRecipeOutput, WorkflowDefinitionOutput, WorkflowArtifactOutput, WorkflowListOutputSchema, WorkflowSuggestOutputSchema, WorkflowRunOutputSchema, WorkflowStepOutputSchema, WorkflowStatusOutputSchema, WorkflowArtifactReadOutputSchema, SearchSerpInputSchema, CaptureSerpSnapshotInputSchema, ScreenshotInputSchema, CaptureSerpPageSnapshotsInputSchema, ReportArtifactReadInputSchema, ReportArtifactReadOutputSchema, ListServiceConnectionsInputSchema, ListServiceConnectionsOutputSchema, TestServiceConnectionInputSchema, TestServiceConnectionOutputSchema, ReadServiceConnectionInputSchema, ReadServiceConnectionOutputSchema, MetaAdCreativeMediaInputSchema, MetaAdCreativeMediaOutputSchema, ImportServiceConnectionToMemoryInputSchema, ImportServiceConnectionToMemoryOutputSchema, DescribeServiceConnectionToolInputSchema, DescribeServiceConnectionToolOutputSchema, ConnectedDataContinuationSchema, ExportConnectedServiceDataInputSchema, ConnectedDataArtifactSchema, ExportConnectedServiceDataOutputSchema, SearchConsoleTableColumnSchema, SearchConsoleTableFilterSchema, ExportSearchConsoleTableDataInputSchema, ExportSearchConsoleTableDataOutputSchema, RenewConnectedDataExportDownloadInputSchema, RenewConnectedDataExportDownloadOutputSchema, CallServiceConnectionActionInputSchema, CallServiceConnectionActionOutputSchema, SetScheduledActionConnectionsInputSchema, SetScheduledActionConnectionsOutputSchema, SlackSendMessageInputSchema, SlackSendMessageOutputSchema, GmailSendMessageInputSchema, GmailSendMessageOutputSchema, GmailSearchContactsInputSchema, GmailSearchContactsOutputSchema, GoogleCalendarCreateEventInputSchema, GoogleCalendarCreateEventOutputSchema, ZoomCreateMeetingInputSchema, ZoomCreateMeetingOutputSchema;
|
|
42179
42342
|
var init_mcp_tool_schemas = __esm({
|
|
42180
42343
|
"src/mcp/mcp-tool-schemas.ts"() {
|
|
42181
42344
|
"use strict";
|
|
@@ -42794,6 +42957,37 @@ var init_mcp_tool_schemas = __esm({
|
|
|
42794
42957
|
downloadUrlExpiresAt: import_zod42.z.string(),
|
|
42795
42958
|
expiresAt: import_zod42.z.string()
|
|
42796
42959
|
};
|
|
42960
|
+
CommonsPublicationSubdomainSchema = import_zod42.z.string().trim().min(3).max(50).describe("Requested publication name under transparent-commons.cc. The server normalizes spaces to hyphens, rejects reserved names, and enforces one globally unique name per account.");
|
|
42961
|
+
CommonsPreparePublicationInputSchema = {
|
|
42962
|
+
requestedSubdomain: CommonsPublicationSubdomainSchema,
|
|
42963
|
+
title: import_zod42.z.string().trim().min(1).max(140).optional().describe("Reader-facing publication title. Omit to derive it from the chosen subdomain."),
|
|
42964
|
+
description: import_zod42.z.string().trim().max(500).optional().describe("Short description used on the publication archive and discovery surfaces.")
|
|
42965
|
+
};
|
|
42966
|
+
CommonsValidatePublicationInputSchema = {
|
|
42967
|
+
operation: import_zod42.z.enum(["claim", "publish"]).describe("Validate either a new name claim or a finished editorial edition without writing."),
|
|
42968
|
+
requestedSubdomain: CommonsPublicationSubdomainSchema.optional().describe("Publication name to validate when operation is claim."),
|
|
42969
|
+
publicationSubdomain: CommonsPublicationSubdomainSchema.optional().describe("Already claimed publication name to validate when operation is publish."),
|
|
42970
|
+
title: import_zod42.z.string().trim().min(1).max(140).optional(),
|
|
42971
|
+
description: import_zod42.z.string().trim().max(500).optional(),
|
|
42972
|
+
edition: import_zod42.z.object(CreateEditorialReadingRoomInputSchema).strict().optional().describe("Complete source-grounded reading-room payload to validate when operation is publish."),
|
|
42973
|
+
editionSlug: import_zod42.z.string().trim().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(80).optional().describe("Stable public edition slug. Defaults to edition.site.slug."),
|
|
42974
|
+
baseRevision: import_zod42.z.number().int().positive().optional().describe("Current edition revision when validating an edit.")
|
|
42975
|
+
};
|
|
42976
|
+
CommonsClaimPublicationInputSchema = {
|
|
42977
|
+
...CommonsPreparePublicationInputSchema,
|
|
42978
|
+
idempotencyKey: import_zod42.z.string().trim().min(8).max(200).describe("Unique key for this intended claim. Reuse it only when retrying the same claim.")
|
|
42979
|
+
};
|
|
42980
|
+
CommonsPublishEditorialInputSchema = {
|
|
42981
|
+
publicationSubdomain: CommonsPublicationSubdomainSchema.describe("Publication owned by the authenticated account."),
|
|
42982
|
+
editionSlug: import_zod42.z.string().trim().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(80).optional().describe("Stable public edition slug. Defaults to site.slug."),
|
|
42983
|
+
idempotencyKey: import_zod42.z.string().trim().min(8).max(200).describe("Unique key for this intended publish. Reuse it only when retrying the same revision."),
|
|
42984
|
+
baseRevision: import_zod42.z.number().int().positive().optional().describe("Required when revising an existing edition; use the current revision from commons_get_publication."),
|
|
42985
|
+
...CreateEditorialReadingRoomInputSchema
|
|
42986
|
+
};
|
|
42987
|
+
CommonsGetPublicationInputSchema = {
|
|
42988
|
+
subdomain: CommonsPublicationSubdomainSchema.optional().describe("Public publication name to inspect. Omit to return the publication owned by the authenticated account."),
|
|
42989
|
+
includeEditions: import_zod42.z.boolean().default(true).describe("Include the latest revision of every published edition.")
|
|
42990
|
+
};
|
|
42797
42991
|
RankTrackerModeSchema = import_zod42.z.enum(["maps", "organic", "ai_overview", "paa"]);
|
|
42798
42992
|
RankTrackerBlueprintInputSchema = {
|
|
42799
42993
|
projectName: import_zod42.z.string().min(1).optional().describe("Optional name for the rank tracker project, client, or campaign."),
|
|
@@ -45614,6 +45808,41 @@ function registerPaaExtractorMcpTools(server, executor, options = {}) {
|
|
|
45614
45808
|
openWorldHint: false
|
|
45615
45809
|
}
|
|
45616
45810
|
}, async (input) => executor.commonsListFilters(input));
|
|
45811
|
+
server.registerTool("commons_prepare_publication", {
|
|
45812
|
+
title: "Prepare Transparent Commons Publication",
|
|
45813
|
+
description: "Check and normalize a subscriber-chosen Transparent Commons publication name before any write. Returns name availability, the caller's existing publication, permanent URL shape, ownership rules, and the required validate/claim/publish workflow. This is for a user-owned editorial publication, not a neutral /wiki/ entity.",
|
|
45814
|
+
inputSchema: CommonsPreparePublicationInputSchema,
|
|
45815
|
+
outputSchema: recordOutputSchema("commons_prepare_publication", CommonsGenericOutputSchema),
|
|
45816
|
+
annotations: { title: "Prepare Transparent Commons Publication", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
45817
|
+
}, async (input) => executor.commonsPreparePublication(input));
|
|
45818
|
+
server.registerTool("commons_validate_publication", {
|
|
45819
|
+
title: "Validate Transparent Commons Publication",
|
|
45820
|
+
description: "Validate a publication name claim or a complete source-grounded editorial edition without writing. Use operation claim before commons_claim_publication and operation publish before commons_publish_editorial. This uses the editorial reading-room contract and checks ownership plus revision conflicts.",
|
|
45821
|
+
inputSchema: CommonsValidatePublicationInputSchema,
|
|
45822
|
+
outputSchema: recordOutputSchema("commons_validate_publication", CommonsGenericOutputSchema),
|
|
45823
|
+
annotations: { title: "Validate Transparent Commons Publication", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
45824
|
+
}, async (input) => executor.commonsValidatePublication(input));
|
|
45825
|
+
server.registerTool("commons_claim_publication", {
|
|
45826
|
+
title: "Claim Transparent Commons Publication",
|
|
45827
|
+
description: "Permanently claim one globally unique publication subdomain for the authenticated MCP Scraper account. Call commons_prepare_publication and commons_validate_publication first. This creates public identity state but does not publish an edition. Requires an idempotencyKey; retries with the same intended claim are safe.",
|
|
45828
|
+
inputSchema: CommonsClaimPublicationInputSchema,
|
|
45829
|
+
outputSchema: recordOutputSchema("commons_claim_publication", CommonsGenericOutputSchema),
|
|
45830
|
+
annotations: { title: "Claim Transparent Commons Publication", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }
|
|
45831
|
+
}, async (input) => executor.commonsClaimPublication(input));
|
|
45832
|
+
server.registerTool("commons_publish_editorial", {
|
|
45833
|
+
title: "Publish Transparent Commons Editorial Edition",
|
|
45834
|
+
description: "Publish a fully authored editorial reading-room edition to the caller-owned Transparent Commons subdomain and return permanent root, archive, and edition URLs. The calling AI must research and author the source-grounded edition first; this tool validates, renders, and persists it. For an existing edition, pass its current baseRevision. Requires an idempotencyKey; this is not the neutral wiki write tool.",
|
|
45835
|
+
inputSchema: CommonsPublishEditorialInputSchema,
|
|
45836
|
+
outputSchema: recordOutputSchema("commons_publish_editorial", CommonsGenericOutputSchema),
|
|
45837
|
+
annotations: { title: "Publish Transparent Commons Editorial Edition", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }
|
|
45838
|
+
}, async (input) => executor.commonsPublishEditorial(input));
|
|
45839
|
+
server.registerTool("commons_get_publication", {
|
|
45840
|
+
title: "Get Transparent Commons Publication",
|
|
45841
|
+
description: "Read a Transparent Commons publication and its latest edition revisions. Omit subdomain to inspect the caller-owned publication; pass a name to inspect a public publication. Returns the permanent public and archive URLs needed for sharing or later edits.",
|
|
45842
|
+
inputSchema: CommonsGetPublicationInputSchema,
|
|
45843
|
+
outputSchema: recordOutputSchema("commons_get_publication", CommonsGenericOutputSchema),
|
|
45844
|
+
annotations: { title: "Get Transparent Commons Publication", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
45845
|
+
}, async (input) => executor.commonsGetPublication(input));
|
|
45617
45846
|
server.registerTool("directory_workflow", {
|
|
45618
45847
|
title: "Directory Workflow: Markets + Maps",
|
|
45619
45848
|
description: `Start a durable directory/prospecting job: selects US city markets from versioned hosted Census-place data, optionally joins the active hosted ZIP dataset, then runs Google Maps business searches per city. Pass a new idempotencyKey for each intended job and reuse it only when retrying that call. Production does not read server-local location CSVs. Always returns a background jobId; poll with directory_workflow_status. ${fileBehavior("Saves a CSV of results per city.", "Completed jobs return an owner-scoped CSV artifact.")}`,
|
|
@@ -46482,6 +46711,28 @@ var init_http_mcp_tool_executor = __esm({
|
|
|
46482
46711
|
commonsListNeedsLinks(input) {
|
|
46483
46712
|
return this.call("/commons/needs-links/search", input);
|
|
46484
46713
|
}
|
|
46714
|
+
commonsPreparePublication(input) {
|
|
46715
|
+
return this.call("/commons/publications/prepare", input);
|
|
46716
|
+
}
|
|
46717
|
+
commonsValidatePublication(input) {
|
|
46718
|
+
return this.call("/commons/publications/validate", input);
|
|
46719
|
+
}
|
|
46720
|
+
commonsClaimPublication(input) {
|
|
46721
|
+
const { idempotencyKey: idempotencyKey3, ...body } = input;
|
|
46722
|
+
return this.call("/commons/publications/claim", { ...body, idempotencyKey: idempotencyKey3 }, this.timeoutMs, "POST", {
|
|
46723
|
+
"Idempotency-Key": `commons-publication-claim-${(0, import_node_crypto26.createHash)("sha256").update(idempotencyKey3).digest("hex")}`
|
|
46724
|
+
});
|
|
46725
|
+
}
|
|
46726
|
+
commonsPublishEditorial(input) {
|
|
46727
|
+
const { idempotencyKey: idempotencyKey3, ...body } = input;
|
|
46728
|
+
return this.call("/commons/publications/publish", { ...body, idempotencyKey: idempotencyKey3 }, this.timeoutMs, "POST", {
|
|
46729
|
+
"Idempotency-Key": `commons-publication-publish-${(0, import_node_crypto26.createHash)("sha256").update(idempotencyKey3).digest("hex")}`
|
|
46730
|
+
});
|
|
46731
|
+
}
|
|
46732
|
+
commonsGetPublication(input) {
|
|
46733
|
+
const query = new URLSearchParams({ includeEditions: String(input.includeEditions ?? true) });
|
|
46734
|
+
return this.getJson(input.subdomain ? `/commons/publications/${encodeURIComponent(input.subdomain)}?${query}` : `/commons/publications/me?${query}`);
|
|
46735
|
+
}
|
|
46485
46736
|
async captureSerpSnapshot(input) {
|
|
46486
46737
|
const fingerprint = (0, import_node_crypto26.createHash)("sha256").update(JSON.stringify(input)).digest("hex");
|
|
46487
46738
|
const now = Date.now();
|
|
@@ -51408,40 +51659,40 @@ function annotations(title, readOnlyHint, destructiveHint = false, idempotentHin
|
|
|
51408
51659
|
}
|
|
51409
51660
|
function registerScheduledResultsMcpTools(server, executor) {
|
|
51410
51661
|
server.registerTool("list_artifact_templates", {
|
|
51411
|
-
title: "List
|
|
51412
|
-
description: "List
|
|
51662
|
+
title: "List Templates",
|
|
51663
|
+
description: "List registered presentation presets and saved immutable template versions. A preset must be saved before an automation can select it.",
|
|
51413
51664
|
inputSchema: import_zod47.z.object({
|
|
51414
51665
|
status: import_zod47.z.enum(["active", "archived", "all"]).default("active")
|
|
51415
51666
|
}).strict(),
|
|
51416
51667
|
outputSchema: recordOutputSchema("list_artifact_templates", McpListArtifactTemplatesOutputSchema),
|
|
51417
|
-
annotations: annotations("List
|
|
51668
|
+
annotations: annotations("List Templates", true)
|
|
51418
51669
|
}, (input) => executor.call(
|
|
51419
51670
|
`/artifact-templates?status=${encodeURIComponent(input.status)}`,
|
|
51420
51671
|
ListArtifactTemplatesOutputSchema
|
|
51421
51672
|
));
|
|
51422
51673
|
server.registerTool("get_artifact_template", {
|
|
51423
|
-
title: "Get
|
|
51424
|
-
description: "Read one saved
|
|
51674
|
+
title: "Get Template",
|
|
51675
|
+
description: "Read one saved template, its renderer family, configuration, and immutable version history.",
|
|
51425
51676
|
inputSchema: import_zod47.z.object({ templateId: TemplateIdSchema }).strict(),
|
|
51426
51677
|
outputSchema: recordOutputSchema("get_artifact_template", McpArtifactTemplateOutputSchema),
|
|
51427
|
-
annotations: annotations("Get
|
|
51678
|
+
annotations: annotations("Get Template", true)
|
|
51428
51679
|
}, (input) => executor.call(
|
|
51429
51680
|
`/artifact-templates/${encodeURIComponent(input.templateId)}`,
|
|
51430
51681
|
ArtifactTemplateOutputSchema
|
|
51431
51682
|
));
|
|
51432
51683
|
server.registerTool("create_artifact_template", {
|
|
51433
|
-
title: "
|
|
51434
|
-
description: "
|
|
51684
|
+
title: "Create Template",
|
|
51685
|
+
description: "Create a user-owned template from a registered preset. Customize supported flags and presentation guidance; arbitrary executable code is not accepted.",
|
|
51435
51686
|
inputSchema: CreateArtifactTemplateInputSchema,
|
|
51436
51687
|
outputSchema: recordOutputSchema("create_artifact_template", McpArtifactTemplateOutputSchema),
|
|
51437
|
-
annotations: annotations("
|
|
51688
|
+
annotations: annotations("Create Template", false)
|
|
51438
51689
|
}, (input) => executor.call("/artifact-templates", ArtifactTemplateOutputSchema, "POST", input));
|
|
51439
51690
|
server.registerTool("update_artifact_template", {
|
|
51440
|
-
title: "
|
|
51441
|
-
description: "Create the next immutable version of a saved
|
|
51691
|
+
title: "Update Template",
|
|
51692
|
+
description: "Create the next immutable version of a saved template. Existing automations remain pinned to their exact prior version until explicitly changed.",
|
|
51442
51693
|
inputSchema: UpdateArtifactTemplateToolInputSchema,
|
|
51443
51694
|
outputSchema: recordOutputSchema("update_artifact_template", McpArtifactTemplateOutputSchema),
|
|
51444
|
-
annotations: annotations("
|
|
51695
|
+
annotations: annotations("Update Template", false)
|
|
51445
51696
|
}, (input) => {
|
|
51446
51697
|
const { templateId, ...body } = input;
|
|
51447
51698
|
UpdateArtifactTemplateInputSchema.parse(body);
|
|
@@ -51453,14 +51704,14 @@ function registerScheduledResultsMcpTools(server, executor) {
|
|
|
51453
51704
|
);
|
|
51454
51705
|
});
|
|
51455
51706
|
server.registerTool("archive_artifact_template", {
|
|
51456
|
-
title: "Archive
|
|
51707
|
+
title: "Archive Template",
|
|
51457
51708
|
description: "Archive or restore a saved template without deleting its immutable versions. Existing pinned automations continue to work.",
|
|
51458
51709
|
inputSchema: import_zod47.z.object({
|
|
51459
51710
|
templateId: TemplateIdSchema,
|
|
51460
51711
|
archived: import_zod47.z.boolean()
|
|
51461
51712
|
}).strict(),
|
|
51462
51713
|
outputSchema: recordOutputSchema("archive_artifact_template", McpArtifactTemplateOutputSchema),
|
|
51463
|
-
annotations: annotations("Archive
|
|
51714
|
+
annotations: annotations("Archive Template", false, false, true)
|
|
51464
51715
|
}, (input) => executor.call(
|
|
51465
51716
|
`/artifact-templates/${encodeURIComponent(input.templateId)}/${input.archived ? "archive" : "restore"}`,
|
|
51466
51717
|
ArtifactTemplateOutputSchema,
|
|
@@ -54888,10 +55139,10 @@ var init_oauth_routes = __esm({
|
|
|
54888
55139
|
return typeof v === "string" ? v : void 0;
|
|
54889
55140
|
};
|
|
54890
55141
|
const p = parseAuthParams(get);
|
|
54891
|
-
const
|
|
55142
|
+
const action2 = get("action") ?? "";
|
|
54892
55143
|
const valid = await validateAuthRequest(p);
|
|
54893
55144
|
if (!valid.ok) return c.text(valid.message, valid.status);
|
|
54894
|
-
if (
|
|
55145
|
+
if (action2 === "login") {
|
|
54895
55146
|
const email = (get("email") ?? "").trim().toLowerCase();
|
|
54896
55147
|
const password = get("password") ?? "";
|
|
54897
55148
|
const user2 = email ? await withOAuthDatabaseDeadline("login-user", getUserByEmail(email)) : void 0;
|
|
@@ -54905,8 +55156,8 @@ var init_oauth_routes = __esm({
|
|
|
54905
55156
|
}
|
|
54906
55157
|
const user = await sessionUser((0, import_cookie.getCookie)(c, "session"));
|
|
54907
55158
|
if (!user) return c.html(renderLogin(p, "Your session expired. Please sign in again."));
|
|
54908
|
-
if (
|
|
54909
|
-
if (
|
|
55159
|
+
if (action2 === "deny") return redirectWithError(p.redirect_uri, p.state, "access_denied");
|
|
55160
|
+
if (action2 !== "approve") return c.text("unsupported action", 400);
|
|
54910
55161
|
const scope = negotiateScope(p.scope, user, p.resource);
|
|
54911
55162
|
const code = `code_${(0, import_node_crypto30.randomBytes)(32).toString("base64url")}`;
|
|
54912
55163
|
const expiresAt = new Date(Date.now() + CODE_TTL_SECONDS * 1e3).toISOString();
|
|
@@ -55964,12 +56215,12 @@ var init_vault_routes = __esm({
|
|
|
55964
56215
|
const token4 = typeof body.token === "string" ? body.token : void 0;
|
|
55965
56216
|
if (!validToken(token4)) return c.json({ ok: false, error: "missing or malformed Vault App link" }, 401);
|
|
55966
56217
|
const path6 = stringValue(body.path, 320);
|
|
55967
|
-
const
|
|
56218
|
+
const action2 = stringValue(body.action, 24);
|
|
55968
56219
|
const title = typeof body.title === "string" ? stringValue(body.title, 320) : void 0;
|
|
55969
56220
|
const content = typeof body.content === "string" && body.content.length <= 1e5 ? body.content : void 0;
|
|
55970
56221
|
const feedback = typeof body.feedback === "string" ? body.feedback.trim().slice(0, 1e4) : void 0;
|
|
55971
56222
|
const baseRevision = typeof body.baseRevision === "number" && Number.isInteger(body.baseRevision) ? body.baseRevision : void 0;
|
|
55972
|
-
const normalizedAction =
|
|
56223
|
+
const normalizedAction = action2 === "accept" ? "approve" : action2;
|
|
55973
56224
|
if (!path6 || !normalizedAction || !["approve", "deny", "edit"].includes(normalizedAction) || body.title !== void 0 && !title) {
|
|
55974
56225
|
return c.json({ ok: false, error: "valid path, action, and optional draft fields are required" }, 400);
|
|
55975
56226
|
}
|
|
@@ -58133,30 +58384,30 @@ function renderEditorialReadingRoomV1(input, config, now = /* @__PURE__ */ new D
|
|
|
58133
58384
|
startLabel: "Start reading"
|
|
58134
58385
|
},
|
|
58135
58386
|
deck: input.dek ?? `Prepared for ${input.generatedFor}.`,
|
|
58136
|
-
articles: input.sections.map((
|
|
58387
|
+
articles: input.sections.map((section2, index) => {
|
|
58137
58388
|
const provenance = [
|
|
58138
58389
|
"",
|
|
58139
58390
|
"## Sources",
|
|
58140
58391
|
"",
|
|
58141
|
-
...
|
|
58142
|
-
...
|
|
58392
|
+
...section2.sourceLabels.map((label) => `- ${label}`),
|
|
58393
|
+
...section2.sourceRefs.map((ref) => `- ${scheduledSourceRef(ref)}`)
|
|
58143
58394
|
].join("\n");
|
|
58144
|
-
const withFiles = index === input.sections.length - 1 && filesMarkdown ? `${
|
|
58395
|
+
const withFiles = index === input.sections.length - 1 && filesMarkdown ? `${section2.markdown}
|
|
58145
58396
|
|
|
58146
58397
|
${provenance}
|
|
58147
58398
|
|
|
58148
|
-
${filesMarkdown}` : `${
|
|
58399
|
+
${filesMarkdown}` : `${section2.markdown}
|
|
58149
58400
|
|
|
58150
58401
|
${provenance}`;
|
|
58151
58402
|
return {
|
|
58152
|
-
slug:
|
|
58403
|
+
slug: section2.id,
|
|
58153
58404
|
category: "Report",
|
|
58154
|
-
kicker:
|
|
58405
|
+
kicker: section2.summary ?? "Scheduled result",
|
|
58155
58406
|
order: index + 1,
|
|
58156
|
-
title:
|
|
58157
|
-
summary:
|
|
58407
|
+
title: section2.title,
|
|
58408
|
+
summary: section2.summary ?? section2.title,
|
|
58158
58409
|
sourceType: "Scheduled result",
|
|
58159
|
-
sourceLabel:
|
|
58410
|
+
sourceLabel: section2.sourceLabels.join(" \xB7 ").slice(0, 500),
|
|
58160
58411
|
markdown: withFiles
|
|
58161
58412
|
};
|
|
58162
58413
|
}),
|
|
@@ -58451,6 +58702,54 @@ async function ensureCommonsSchema() {
|
|
|
58451
58702
|
},
|
|
58452
58703
|
{ sql: `CREATE INDEX IF NOT EXISTS commons_index_documents_status_updated ON commons_index_documents(embedding_status, updated_at DESC)`, args: [] },
|
|
58453
58704
|
{ sql: `CREATE INDEX IF NOT EXISTS commons_index_documents_entity_type ON commons_index_documents(entity_id, document_type)`, args: [] },
|
|
58705
|
+
{
|
|
58706
|
+
sql: `
|
|
58707
|
+
CREATE TABLE IF NOT EXISTS commons_publications (
|
|
58708
|
+
id TEXT PRIMARY KEY,
|
|
58709
|
+
owner_user_id INTEGER NOT NULL REFERENCES users(id),
|
|
58710
|
+
subdomain TEXT NOT NULL UNIQUE,
|
|
58711
|
+
title TEXT NOT NULL,
|
|
58712
|
+
description TEXT NOT NULL DEFAULT '',
|
|
58713
|
+
claim_idempotency_key TEXT NOT NULL,
|
|
58714
|
+
latest_edition_id TEXT,
|
|
58715
|
+
created_at TEXT NOT NULL,
|
|
58716
|
+
updated_at TEXT NOT NULL,
|
|
58717
|
+
UNIQUE(owner_user_id),
|
|
58718
|
+
UNIQUE(owner_user_id, claim_idempotency_key)
|
|
58719
|
+
)
|
|
58720
|
+
`,
|
|
58721
|
+
args: []
|
|
58722
|
+
},
|
|
58723
|
+
{ sql: `CREATE INDEX IF NOT EXISTS commons_publications_updated ON commons_publications(updated_at DESC)`, args: [] },
|
|
58724
|
+
{
|
|
58725
|
+
sql: `
|
|
58726
|
+
CREATE TABLE IF NOT EXISTS commons_publication_editions (
|
|
58727
|
+
id TEXT PRIMARY KEY,
|
|
58728
|
+
publication_id TEXT NOT NULL REFERENCES commons_publications(id),
|
|
58729
|
+
owner_user_id INTEGER NOT NULL REFERENCES users(id),
|
|
58730
|
+
edition_slug TEXT NOT NULL,
|
|
58731
|
+
revision INTEGER NOT NULL,
|
|
58732
|
+
title TEXT NOT NULL,
|
|
58733
|
+
site_json TEXT NOT NULL,
|
|
58734
|
+
deck TEXT NOT NULL,
|
|
58735
|
+
articles_json TEXT NOT NULL,
|
|
58736
|
+
html TEXT NOT NULL,
|
|
58737
|
+
filename TEXT NOT NULL,
|
|
58738
|
+
sha256 TEXT NOT NULL,
|
|
58739
|
+
article_count INTEGER NOT NULL,
|
|
58740
|
+
word_count INTEGER NOT NULL,
|
|
58741
|
+
bytes INTEGER NOT NULL,
|
|
58742
|
+
warnings_json TEXT NOT NULL DEFAULT '[]',
|
|
58743
|
+
idempotency_key TEXT NOT NULL,
|
|
58744
|
+
created_at TEXT NOT NULL,
|
|
58745
|
+
published_at TEXT NOT NULL,
|
|
58746
|
+
UNIQUE(publication_id, edition_slug, revision),
|
|
58747
|
+
UNIQUE(owner_user_id, idempotency_key)
|
|
58748
|
+
)
|
|
58749
|
+
`,
|
|
58750
|
+
args: []
|
|
58751
|
+
},
|
|
58752
|
+
{ sql: `CREATE INDEX IF NOT EXISTS commons_publication_editions_publication_published ON commons_publication_editions(publication_id, published_at DESC)`, args: [] },
|
|
58454
58753
|
{
|
|
58455
58754
|
sql: "INSERT OR IGNORE INTO schema_migrations (version) VALUES (?)",
|
|
58456
58755
|
args: [COMMONS_SCHEMA_VERSION]
|
|
@@ -58567,7 +58866,7 @@ async function prepareCommonsEntity(input, user) {
|
|
|
58567
58866
|
presentHeadings: headings,
|
|
58568
58867
|
recommendedSections: contract.recommendedSections,
|
|
58569
58868
|
optionalSections: contract.optionalSections,
|
|
58570
|
-
missingRecommendedSections: contract.recommendedSections.filter((
|
|
58869
|
+
missingRecommendedSections: contract.recommendedSections.filter((section2) => !presentHeadingLabels.has(section2.toLowerCase())),
|
|
58571
58870
|
rule: "Use the entity profile as a guide, but omit any section or subsection that is not supported by source evidence."
|
|
58572
58871
|
},
|
|
58573
58872
|
instructions: [
|
|
@@ -58640,8 +58939,8 @@ async function validateCommonsEntity(input, user) {
|
|
|
58640
58939
|
headings,
|
|
58641
58940
|
placeholderSections,
|
|
58642
58941
|
requiredOmissionRule: "Omit unsupported profile sections; do not publish sections whose only content is that the source lacks evidence.",
|
|
58643
|
-
supportedRecommendedSections: contract.recommendedSections.filter((
|
|
58644
|
-
unsupportedRecommendedSections: contract.recommendedSections.filter((
|
|
58942
|
+
supportedRecommendedSections: contract.recommendedSections.filter((section2) => headings.some((heading) => heading.text.toLowerCase() === section2.toLowerCase())),
|
|
58943
|
+
unsupportedRecommendedSections: contract.recommendedSections.filter((section2) => !headings.some((heading) => heading.text.toLowerCase() === section2.toLowerCase()))
|
|
58645
58944
|
},
|
|
58646
58945
|
tagResolutions: resolveCommonsTags(
|
|
58647
58946
|
uniqueStrings([...input.tags ?? [], ...input.keywords ?? []]).slice(0, 20),
|
|
@@ -59166,7 +59465,7 @@ function unsupportedPlaceholderSections(markdown) {
|
|
|
59166
59465
|
/insufficient evidence/i,
|
|
59167
59466
|
/source material does not/i
|
|
59168
59467
|
];
|
|
59169
|
-
return sections.filter((
|
|
59468
|
+
return sections.filter((section2) => placeholderPatterns.some((pattern) => pattern.test(section2.body)) && wordCount2(section2.body) <= 160).map((section2) => section2.heading);
|
|
59170
59469
|
}
|
|
59171
59470
|
function markdownSectionBodies(markdown) {
|
|
59172
59471
|
const lines = String(markdown || "").split(/\r?\n/);
|
|
@@ -59650,18 +59949,18 @@ function normalizeBody(bodyMarkdown, contentSections) {
|
|
|
59650
59949
|
const body = String(bodyMarkdown ?? "").trim();
|
|
59651
59950
|
if (body) return body.slice(0, 5e5);
|
|
59652
59951
|
const sections = normalizeContentSections(contentSections);
|
|
59653
|
-
return sections.map((
|
|
59952
|
+
return sections.map((section2) => `## ${section2.heading}
|
|
59654
59953
|
|
|
59655
|
-
${
|
|
59954
|
+
${section2.body}`).join("\n\n").slice(0, 5e5);
|
|
59656
59955
|
}
|
|
59657
59956
|
function normalizeContentSections(sections) {
|
|
59658
59957
|
if (!Array.isArray(sections)) return [];
|
|
59659
|
-
return sections.map((
|
|
59660
|
-
id: normalizeSlug(
|
|
59661
|
-
heading: requiredText(
|
|
59662
|
-
body: requiredText(
|
|
59663
|
-
position: Number.isFinite(
|
|
59664
|
-
citations: normalizeCitations(
|
|
59958
|
+
return sections.map((section2, index) => ({
|
|
59959
|
+
id: normalizeSlug(section2.id || section2.heading),
|
|
59960
|
+
heading: requiredText(section2.heading, "section.heading", 1, 180),
|
|
59961
|
+
body: requiredText(section2.body, "section.body", 1, 1e5),
|
|
59962
|
+
position: Number.isFinite(section2.position) ? Number(section2.position) : index + 1,
|
|
59963
|
+
citations: normalizeCitations(section2.citations)
|
|
59665
59964
|
})).slice(0, 80);
|
|
59666
59965
|
}
|
|
59667
59966
|
function normalizeArticleSections(sections) {
|
|
@@ -60024,7 +60323,7 @@ var init_commons_repository = __esm({
|
|
|
60024
60323
|
import_node_crypto34 = require("crypto");
|
|
60025
60324
|
init_db();
|
|
60026
60325
|
init_rates();
|
|
60027
|
-
COMMONS_SCHEMA_VERSION = "2026-08-04.
|
|
60326
|
+
COMMONS_SCHEMA_VERSION = "2026-08-04.3";
|
|
60028
60327
|
DEFAULT_COMMONS_BASE_URL = "https://transparent-commons.cc";
|
|
60029
60328
|
DEFAULT_ENTITY_TYPE = "PublicArticle";
|
|
60030
60329
|
COMMONS_ENTITY_PROFILES = {
|
|
@@ -60186,6 +60485,401 @@ var init_commons_repository = __esm({
|
|
|
60186
60485
|
}
|
|
60187
60486
|
});
|
|
60188
60487
|
|
|
60488
|
+
// src/api/commons-publication-repository.ts
|
|
60489
|
+
async function prepareCommonsPublication(input, user) {
|
|
60490
|
+
await ensureCommonsSchema();
|
|
60491
|
+
const subdomain = normalizePublicationSubdomain(input.requestedSubdomain);
|
|
60492
|
+
const [owned, claimed] = await Promise.all([
|
|
60493
|
+
getCommonsPublicationForOwner(Number(user.id)),
|
|
60494
|
+
getCommonsPublicationBySubdomain(subdomain)
|
|
60495
|
+
]);
|
|
60496
|
+
const availability = claimed ? claimed.ownerUserId === Number(user.id) ? "owned_by_caller" : "unavailable" : "available";
|
|
60497
|
+
return {
|
|
60498
|
+
requestedSubdomain: input.requestedSubdomain,
|
|
60499
|
+
normalizedSubdomain: subdomain,
|
|
60500
|
+
availability,
|
|
60501
|
+
requestedPublicUrl: publicationPublicUrl(subdomain),
|
|
60502
|
+
currentPublication: owned,
|
|
60503
|
+
contract: {
|
|
60504
|
+
ownership: "One publication per authenticated MCP Scraper account.",
|
|
60505
|
+
permanence: "Claimed names are stable and globally unique.",
|
|
60506
|
+
renderer: "Published editions use the MCP Scraper editorial reading-room renderer.",
|
|
60507
|
+
revisionRule: "Editing an existing edition requires its current baseRevision.",
|
|
60508
|
+
publicRoutes: ["/", "/archive", "/editions/{editionSlug}"],
|
|
60509
|
+
workflow: [
|
|
60510
|
+
"commons_prepare_publication",
|
|
60511
|
+
"commons_validate_publication",
|
|
60512
|
+
"commons_claim_publication",
|
|
60513
|
+
"commons_publish_editorial"
|
|
60514
|
+
]
|
|
60515
|
+
},
|
|
60516
|
+
proposed: {
|
|
60517
|
+
title: cleanText(input.title, 140) || publicationTitleFromSubdomain(subdomain),
|
|
60518
|
+
description: cleanText(input.description, 500)
|
|
60519
|
+
}
|
|
60520
|
+
};
|
|
60521
|
+
}
|
|
60522
|
+
async function validateCommonsPublication(input, user) {
|
|
60523
|
+
await ensureCommonsSchema();
|
|
60524
|
+
const errors = [];
|
|
60525
|
+
const warnings = [];
|
|
60526
|
+
let subdomain = "";
|
|
60527
|
+
try {
|
|
60528
|
+
subdomain = normalizePublicationSubdomain(input.requestedSubdomain || input.publicationSubdomain || "");
|
|
60529
|
+
} catch (error) {
|
|
60530
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
60531
|
+
}
|
|
60532
|
+
const publication = subdomain ? await getCommonsPublicationBySubdomain(subdomain) : null;
|
|
60533
|
+
if (input.operation === "claim") {
|
|
60534
|
+
const owned = await getCommonsPublicationForOwner(Number(user.id));
|
|
60535
|
+
if (publication && publication.ownerUserId !== Number(user.id)) errors.push("That publication name is already claimed by another account.");
|
|
60536
|
+
if (owned && owned.subdomain !== subdomain) errors.push(`This account already owns ${owned.publicUrl}.`);
|
|
60537
|
+
if (!cleanText(input.title, 140)) warnings.push("No display title was supplied; the publication name will be title-cased.");
|
|
60538
|
+
} else {
|
|
60539
|
+
if (!publication) errors.push("Claim this publication name before publishing an edition.");
|
|
60540
|
+
else if (publication.ownerUserId !== Number(user.id)) errors.push("Only the account that claimed this publication can publish to it.");
|
|
60541
|
+
if (!input.edition) errors.push("A complete editorial reading-room edition is required for publish validation.");
|
|
60542
|
+
if (input.edition) {
|
|
60543
|
+
try {
|
|
60544
|
+
renderEditorialReadingRoom(input.edition);
|
|
60545
|
+
} catch (error) {
|
|
60546
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
60547
|
+
}
|
|
60548
|
+
const slug2 = normalizeEditionSlug(input.editionSlug || input.edition.site.slug);
|
|
60549
|
+
const latest = publication ? await getLatestEdition(publication.id, slug2) : null;
|
|
60550
|
+
if (latest && input.baseRevision === void 0) errors.push(`Edition ${slug2} already exists at revision ${latest.revision}; supply baseRevision to edit it.`);
|
|
60551
|
+
if (latest && input.baseRevision !== void 0 && latest.revision !== input.baseRevision) {
|
|
60552
|
+
errors.push(`Edition ${slug2} is revision ${latest.revision}; the proposed edit targeted ${input.baseRevision}.`);
|
|
60553
|
+
}
|
|
60554
|
+
}
|
|
60555
|
+
}
|
|
60556
|
+
return {
|
|
60557
|
+
valid: errors.length === 0,
|
|
60558
|
+
operation: input.operation,
|
|
60559
|
+
normalizedSubdomain: subdomain || null,
|
|
60560
|
+
publicUrl: subdomain ? publicationPublicUrl(subdomain) : null,
|
|
60561
|
+
errors,
|
|
60562
|
+
warnings,
|
|
60563
|
+
publication
|
|
60564
|
+
};
|
|
60565
|
+
}
|
|
60566
|
+
async function claimCommonsPublication(input, user) {
|
|
60567
|
+
await ensureCommonsSchema();
|
|
60568
|
+
const subdomain = normalizePublicationSubdomain(input.requestedSubdomain);
|
|
60569
|
+
const userId = Number(user.id);
|
|
60570
|
+
const existingOwned = await getCommonsPublicationForOwner(userId);
|
|
60571
|
+
if (existingOwned) {
|
|
60572
|
+
if (existingOwned.subdomain === subdomain) return { publication: existingOwned, idempotentReplay: true };
|
|
60573
|
+
throw new CommonsPublicationError("publication_already_claimed", `This account already owns ${existingOwned.publicUrl}.`, 409);
|
|
60574
|
+
}
|
|
60575
|
+
const existingName = await getCommonsPublicationBySubdomain(subdomain);
|
|
60576
|
+
if (existingName) throw new CommonsPublicationError("publication_name_unavailable", "That publication name is already claimed.", 409);
|
|
60577
|
+
const id = `tcpub_${(0, import_node_crypto35.randomUUID)()}`;
|
|
60578
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
60579
|
+
try {
|
|
60580
|
+
await getDb().execute({
|
|
60581
|
+
sql: `
|
|
60582
|
+
INSERT INTO commons_publications (
|
|
60583
|
+
id, owner_user_id, subdomain, title, description, claim_idempotency_key, created_at, updated_at
|
|
60584
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
60585
|
+
`,
|
|
60586
|
+
args: [
|
|
60587
|
+
id,
|
|
60588
|
+
userId,
|
|
60589
|
+
subdomain,
|
|
60590
|
+
cleanText(input.title, 140) || publicationTitleFromSubdomain(subdomain),
|
|
60591
|
+
cleanText(input.description, 500),
|
|
60592
|
+
requiredIdempotencyKey(input.idempotencyKey),
|
|
60593
|
+
now,
|
|
60594
|
+
now
|
|
60595
|
+
]
|
|
60596
|
+
});
|
|
60597
|
+
} catch (error) {
|
|
60598
|
+
const replay = await getCommonsPublicationForOwner(userId);
|
|
60599
|
+
if (replay?.subdomain === subdomain) return { publication: replay, idempotentReplay: true };
|
|
60600
|
+
throw error;
|
|
60601
|
+
}
|
|
60602
|
+
const publication = await getCommonsPublicationBySubdomain(subdomain);
|
|
60603
|
+
if (!publication) throw new CommonsPublicationError("publication_claim_failed", "The publication claim was not persisted.");
|
|
60604
|
+
return { publication, idempotentReplay: false };
|
|
60605
|
+
}
|
|
60606
|
+
async function publishCommonsEditorial(input, user) {
|
|
60607
|
+
await ensureCommonsSchema();
|
|
60608
|
+
const subdomain = normalizePublicationSubdomain(input.publicationSubdomain);
|
|
60609
|
+
const publication = await getCommonsPublicationBySubdomain(subdomain);
|
|
60610
|
+
if (!publication) throw new CommonsPublicationError("publication_not_found", "Claim this publication name before publishing an edition.", 404);
|
|
60611
|
+
if (publication.ownerUserId !== Number(user.id)) {
|
|
60612
|
+
throw new CommonsPublicationError("publication_not_owned", "Only the account that claimed this publication can publish to it.", 404);
|
|
60613
|
+
}
|
|
60614
|
+
const idempotencyKey3 = requiredIdempotencyKey(input.idempotencyKey);
|
|
60615
|
+
const replay = await getEditionByIdempotency(Number(user.id), idempotencyKey3);
|
|
60616
|
+
if (replay) return publicationResult(publication, replay, true);
|
|
60617
|
+
const editionSlug = normalizeEditionSlug(input.editionSlug || input.site.slug);
|
|
60618
|
+
const latest = await getLatestEdition(publication.id, editionSlug);
|
|
60619
|
+
if (latest && input.baseRevision === void 0) {
|
|
60620
|
+
throw new CommonsPublicationError("publication_base_revision_required", `Edition ${editionSlug} already exists at revision ${latest.revision}; supply baseRevision to edit it.`, 409);
|
|
60621
|
+
}
|
|
60622
|
+
if (latest && input.baseRevision !== latest.revision) {
|
|
60623
|
+
throw new CommonsPublicationError("publication_revision_conflict", `Edition ${editionSlug} is revision ${latest.revision}; refresh it before publishing an edit.`, 409);
|
|
60624
|
+
}
|
|
60625
|
+
const { publicationSubdomain: _publicationSubdomain, editionSlug: _editionSlug, idempotencyKey: _idempotencyKey, baseRevision: _baseRevision, ...editionInput } = input;
|
|
60626
|
+
const canonicalUrl = editionPublicUrl(subdomain, editionSlug);
|
|
60627
|
+
const rendered = renderEditorialReadingRoom(editionInput);
|
|
60628
|
+
const html = addPublicMetadata(rendered.html, canonicalUrl, publication.title);
|
|
60629
|
+
const editionId = `tced_${(0, import_node_crypto35.randomUUID)()}`;
|
|
60630
|
+
const revision = (latest?.revision ?? 0) + 1;
|
|
60631
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
60632
|
+
await getDb().batch([
|
|
60633
|
+
{
|
|
60634
|
+
sql: `
|
|
60635
|
+
INSERT INTO commons_publication_editions (
|
|
60636
|
+
id, publication_id, owner_user_id, edition_slug, revision, title, site_json, deck,
|
|
60637
|
+
articles_json, html, filename, sha256, article_count, word_count, bytes, warnings_json,
|
|
60638
|
+
idempotency_key, created_at, published_at
|
|
60639
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
60640
|
+
`,
|
|
60641
|
+
args: [
|
|
60642
|
+
editionId,
|
|
60643
|
+
publication.id,
|
|
60644
|
+
Number(user.id),
|
|
60645
|
+
editionSlug,
|
|
60646
|
+
revision,
|
|
60647
|
+
editionInput.site.title,
|
|
60648
|
+
JSON.stringify(editionInput.site),
|
|
60649
|
+
editionInput.deck,
|
|
60650
|
+
JSON.stringify(editionInput.articles),
|
|
60651
|
+
html,
|
|
60652
|
+
rendered.filename,
|
|
60653
|
+
(0, import_node_crypto35.createHash)("sha256").update(html).digest("hex"),
|
|
60654
|
+
rendered.articleCount,
|
|
60655
|
+
rendered.wordCount,
|
|
60656
|
+
Buffer.byteLength(html),
|
|
60657
|
+
JSON.stringify(rendered.warnings),
|
|
60658
|
+
idempotencyKey3,
|
|
60659
|
+
now,
|
|
60660
|
+
now
|
|
60661
|
+
]
|
|
60662
|
+
},
|
|
60663
|
+
{
|
|
60664
|
+
sql: "UPDATE commons_publications SET latest_edition_id = ?, updated_at = ? WHERE id = ? AND owner_user_id = ?",
|
|
60665
|
+
args: [editionId, now, publication.id, Number(user.id)]
|
|
60666
|
+
}
|
|
60667
|
+
], "write");
|
|
60668
|
+
const edition = await getPublicationEditionById(editionId);
|
|
60669
|
+
if (!edition) throw new CommonsPublicationError("publication_publish_failed", "The published edition was not persisted.");
|
|
60670
|
+
return publicationResult({ ...publication, latestEditionId: editionId, updatedAt: now }, edition, false);
|
|
60671
|
+
}
|
|
60672
|
+
async function getCommonsPublicationBySubdomain(subdomainInput) {
|
|
60673
|
+
await ensureCommonsSchema();
|
|
60674
|
+
const subdomain = normalizePublicationSubdomain(subdomainInput);
|
|
60675
|
+
const result = await getDb().execute({ sql: "SELECT * FROM commons_publications WHERE subdomain = ? LIMIT 1", args: [subdomain] });
|
|
60676
|
+
return result.rows[0] ? rowToPublication(result.rows[0]) : null;
|
|
60677
|
+
}
|
|
60678
|
+
async function getCommonsPublicationForOwner(userId) {
|
|
60679
|
+
await ensureCommonsSchema();
|
|
60680
|
+
const result = await getDb().execute({ sql: "SELECT * FROM commons_publications WHERE owner_user_id = ? LIMIT 1", args: [userId] });
|
|
60681
|
+
return result.rows[0] ? rowToPublication(result.rows[0]) : null;
|
|
60682
|
+
}
|
|
60683
|
+
async function listCommonsPublicationEditions(publicationId) {
|
|
60684
|
+
await ensureCommonsSchema();
|
|
60685
|
+
const result = await getDb().execute({
|
|
60686
|
+
sql: `
|
|
60687
|
+
SELECT edition.* FROM commons_publication_editions edition
|
|
60688
|
+
JOIN (
|
|
60689
|
+
SELECT edition_slug, MAX(revision) AS revision
|
|
60690
|
+
FROM commons_publication_editions WHERE publication_id = ? GROUP BY edition_slug
|
|
60691
|
+
) latest ON latest.edition_slug = edition.edition_slug AND latest.revision = edition.revision
|
|
60692
|
+
WHERE edition.publication_id = ? ORDER BY edition.published_at DESC
|
|
60693
|
+
`,
|
|
60694
|
+
args: [publicationId, publicationId]
|
|
60695
|
+
});
|
|
60696
|
+
const publication = await getPublicationById(publicationId);
|
|
60697
|
+
if (!publication) return [];
|
|
60698
|
+
return result.rows.map((row) => rowToEdition(row, publication.subdomain));
|
|
60699
|
+
}
|
|
60700
|
+
async function getCommonsPublicationEditionHtml(subdomainInput, editionSlugInput) {
|
|
60701
|
+
const publication = await getCommonsPublicationBySubdomain(subdomainInput);
|
|
60702
|
+
if (!publication) return null;
|
|
60703
|
+
const result = editionSlugInput ? await getDb().execute({
|
|
60704
|
+
sql: "SELECT * FROM commons_publication_editions WHERE publication_id = ? AND edition_slug = ? ORDER BY revision DESC LIMIT 1",
|
|
60705
|
+
args: [publication.id, normalizeEditionSlug(editionSlugInput)]
|
|
60706
|
+
}) : await getDb().execute({
|
|
60707
|
+
sql: "SELECT * FROM commons_publication_editions WHERE id = ? AND publication_id = ? LIMIT 1",
|
|
60708
|
+
args: [publication.latestEditionId || "", publication.id]
|
|
60709
|
+
});
|
|
60710
|
+
if (!result.rows[0]) return null;
|
|
60711
|
+
const record = result.rows[0];
|
|
60712
|
+
return { publication, edition: rowToEdition(record, publication.subdomain), html: String(record.html || "") };
|
|
60713
|
+
}
|
|
60714
|
+
async function getPublicationById(id) {
|
|
60715
|
+
const result = await getDb().execute({ sql: "SELECT * FROM commons_publications WHERE id = ? LIMIT 1", args: [id] });
|
|
60716
|
+
return result.rows[0] ? rowToPublication(result.rows[0]) : null;
|
|
60717
|
+
}
|
|
60718
|
+
async function getLatestEdition(publicationId, editionSlug) {
|
|
60719
|
+
const publication = await getPublicationById(publicationId);
|
|
60720
|
+
if (!publication) return null;
|
|
60721
|
+
const result = await getDb().execute({
|
|
60722
|
+
sql: "SELECT * FROM commons_publication_editions WHERE publication_id = ? AND edition_slug = ? ORDER BY revision DESC LIMIT 1",
|
|
60723
|
+
args: [publicationId, editionSlug]
|
|
60724
|
+
});
|
|
60725
|
+
return result.rows[0] ? rowToEdition(result.rows[0], publication.subdomain) : null;
|
|
60726
|
+
}
|
|
60727
|
+
async function getEditionByIdempotency(userId, idempotencyKey3) {
|
|
60728
|
+
const result = await getDb().execute({
|
|
60729
|
+
sql: `SELECT edition.*, publication.subdomain FROM commons_publication_editions edition JOIN commons_publications publication ON publication.id = edition.publication_id WHERE edition.owner_user_id = ? AND edition.idempotency_key = ? LIMIT 1`,
|
|
60730
|
+
args: [userId, idempotencyKey3]
|
|
60731
|
+
});
|
|
60732
|
+
if (!result.rows[0]) return null;
|
|
60733
|
+
const record = result.rows[0];
|
|
60734
|
+
return rowToEdition(record, String(record.subdomain));
|
|
60735
|
+
}
|
|
60736
|
+
async function getPublicationEditionById(id) {
|
|
60737
|
+
const result = await getDb().execute({
|
|
60738
|
+
sql: `SELECT edition.*, publication.subdomain FROM commons_publication_editions edition JOIN commons_publications publication ON publication.id = edition.publication_id WHERE edition.id = ? LIMIT 1`,
|
|
60739
|
+
args: [id]
|
|
60740
|
+
});
|
|
60741
|
+
if (!result.rows[0]) return null;
|
|
60742
|
+
const record = result.rows[0];
|
|
60743
|
+
return rowToEdition(record, String(record.subdomain));
|
|
60744
|
+
}
|
|
60745
|
+
function rowToPublication(row) {
|
|
60746
|
+
const subdomain = String(row.subdomain);
|
|
60747
|
+
return {
|
|
60748
|
+
id: String(row.id),
|
|
60749
|
+
ownerUserId: Number(row.owner_user_id),
|
|
60750
|
+
subdomain,
|
|
60751
|
+
title: String(row.title),
|
|
60752
|
+
description: String(row.description || ""),
|
|
60753
|
+
latestEditionId: row.latest_edition_id ? String(row.latest_edition_id) : null,
|
|
60754
|
+
createdAt: String(row.created_at),
|
|
60755
|
+
updatedAt: String(row.updated_at),
|
|
60756
|
+
publicUrl: publicationPublicUrl(subdomain),
|
|
60757
|
+
archiveUrl: `${publicationPublicUrl(subdomain)}/archive`
|
|
60758
|
+
};
|
|
60759
|
+
}
|
|
60760
|
+
function rowToEdition(row, subdomain) {
|
|
60761
|
+
const editionSlug = String(row.edition_slug);
|
|
60762
|
+
return {
|
|
60763
|
+
id: String(row.id),
|
|
60764
|
+
publicationId: String(row.publication_id),
|
|
60765
|
+
editionSlug,
|
|
60766
|
+
revision: Number(row.revision),
|
|
60767
|
+
title: String(row.title),
|
|
60768
|
+
site: parseJson4(row.site_json, {}),
|
|
60769
|
+
deck: String(row.deck),
|
|
60770
|
+
filename: String(row.filename),
|
|
60771
|
+
sha256: String(row.sha256),
|
|
60772
|
+
articleCount: Number(row.article_count),
|
|
60773
|
+
wordCount: Number(row.word_count),
|
|
60774
|
+
bytes: Number(row.bytes),
|
|
60775
|
+
warnings: parseJson4(row.warnings_json, []),
|
|
60776
|
+
createdAt: String(row.created_at),
|
|
60777
|
+
publishedAt: String(row.published_at),
|
|
60778
|
+
publicUrl: editionPublicUrl(subdomain, editionSlug)
|
|
60779
|
+
};
|
|
60780
|
+
}
|
|
60781
|
+
function publicationResult(publication, edition, idempotentReplay) {
|
|
60782
|
+
return {
|
|
60783
|
+
publication,
|
|
60784
|
+
edition,
|
|
60785
|
+
publicUrl: publication.publicUrl,
|
|
60786
|
+
archiveUrl: publication.archiveUrl,
|
|
60787
|
+
editionUrl: edition.publicUrl,
|
|
60788
|
+
idempotentReplay
|
|
60789
|
+
};
|
|
60790
|
+
}
|
|
60791
|
+
function normalizePublicationSubdomain(value) {
|
|
60792
|
+
const normalized = String(value || "").trim().toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
60793
|
+
if (!/^[a-z0-9](?:[a-z0-9-]{1,48}[a-z0-9])$/.test(normalized)) {
|
|
60794
|
+
throw new CommonsPublicationError("publication_name_invalid", "Choose a publication name between 3 and 50 characters using letters, numbers, and interior hyphens.");
|
|
60795
|
+
}
|
|
60796
|
+
if (RESERVED_SUBDOMAINS.has(normalized)) throw new CommonsPublicationError("publication_name_reserved", "That publication name is reserved; choose a more specific name.", 409);
|
|
60797
|
+
return normalized;
|
|
60798
|
+
}
|
|
60799
|
+
function normalizeEditionSlug(value) {
|
|
60800
|
+
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 80);
|
|
60801
|
+
if (!normalized) throw new CommonsPublicationError("edition_slug_invalid", "A published edition needs a stable slug.");
|
|
60802
|
+
return normalized;
|
|
60803
|
+
}
|
|
60804
|
+
function requiredIdempotencyKey(value) {
|
|
60805
|
+
const normalized = cleanText(value, 200);
|
|
60806
|
+
if (normalized.length < 8) throw new CommonsPublicationError("idempotency_key_invalid", "Use an idempotency key of at least 8 characters and reuse it only when retrying the same write.");
|
|
60807
|
+
return normalized;
|
|
60808
|
+
}
|
|
60809
|
+
function publicationPublicUrl(subdomain) {
|
|
60810
|
+
return `https://${subdomain}.${PUBLICATION_ROOT_DOMAIN}`;
|
|
60811
|
+
}
|
|
60812
|
+
function editionPublicUrl(subdomain, editionSlug) {
|
|
60813
|
+
return `${publicationPublicUrl(subdomain)}/editions/${encodeURIComponent(editionSlug)}`;
|
|
60814
|
+
}
|
|
60815
|
+
function publicationTitleFromSubdomain(subdomain) {
|
|
60816
|
+
return subdomain.split("-").map((part) => part ? `${part[0]?.toUpperCase()}${part.slice(1)}` : "").join(" ");
|
|
60817
|
+
}
|
|
60818
|
+
function cleanText(value, max) {
|
|
60819
|
+
return String(value || "").replace(/\s+/g, " ").trim().slice(0, max);
|
|
60820
|
+
}
|
|
60821
|
+
function parseJson4(value, fallback) {
|
|
60822
|
+
try {
|
|
60823
|
+
return JSON.parse(String(value || ""));
|
|
60824
|
+
} catch {
|
|
60825
|
+
return fallback;
|
|
60826
|
+
}
|
|
60827
|
+
}
|
|
60828
|
+
function addPublicMetadata(html, canonicalUrl, publicationTitle) {
|
|
60829
|
+
const escapedUrl = canonicalUrl.replace(/&/g, "&").replace(/"/g, """);
|
|
60830
|
+
const escapedTitle = publicationTitle.replace(/&/g, "&").replace(/"/g, """);
|
|
60831
|
+
return html.replace("</head>", [
|
|
60832
|
+
` <link rel="canonical" href="${escapedUrl}">`,
|
|
60833
|
+
` <meta property="og:url" content="${escapedUrl}">`,
|
|
60834
|
+
` <meta property="og:site_name" content="${escapedTitle}">`,
|
|
60835
|
+
' <meta name="robots" content="index,follow">',
|
|
60836
|
+
"</head>"
|
|
60837
|
+
].join("\n"));
|
|
60838
|
+
}
|
|
60839
|
+
var import_node_crypto35, PUBLICATION_ROOT_DOMAIN, RESERVED_SUBDOMAINS, CommonsPublicationError;
|
|
60840
|
+
var init_commons_publication_repository = __esm({
|
|
60841
|
+
"src/api/commons-publication-repository.ts"() {
|
|
60842
|
+
"use strict";
|
|
60843
|
+
import_node_crypto35 = require("crypto");
|
|
60844
|
+
init_db();
|
|
60845
|
+
init_commons_repository();
|
|
60846
|
+
init_render();
|
|
60847
|
+
PUBLICATION_ROOT_DOMAIN = process.env.COMMONS_PUBLICATION_ROOT_DOMAIN || "transparent-commons.cc";
|
|
60848
|
+
RESERVED_SUBDOMAINS = /* @__PURE__ */ new Set([
|
|
60849
|
+
"admin",
|
|
60850
|
+
"api",
|
|
60851
|
+
"app",
|
|
60852
|
+
"assets",
|
|
60853
|
+
"auth",
|
|
60854
|
+
"blog",
|
|
60855
|
+
"cdn",
|
|
60856
|
+
"docs",
|
|
60857
|
+
"help",
|
|
60858
|
+
"login",
|
|
60859
|
+
"mail",
|
|
60860
|
+
"mcp",
|
|
60861
|
+
"signup",
|
|
60862
|
+
"sitemap",
|
|
60863
|
+
"static",
|
|
60864
|
+
"support",
|
|
60865
|
+
"transparent-commons",
|
|
60866
|
+
"transparentcommons",
|
|
60867
|
+
"www",
|
|
60868
|
+
"wiki"
|
|
60869
|
+
]);
|
|
60870
|
+
CommonsPublicationError = class extends Error {
|
|
60871
|
+
constructor(code, message, httpStatus = 400) {
|
|
60872
|
+
super(message);
|
|
60873
|
+
this.code = code;
|
|
60874
|
+
this.httpStatus = httpStatus;
|
|
60875
|
+
this.name = "CommonsPublicationError";
|
|
60876
|
+
}
|
|
60877
|
+
code;
|
|
60878
|
+
httpStatus;
|
|
60879
|
+
};
|
|
60880
|
+
}
|
|
60881
|
+
});
|
|
60882
|
+
|
|
60189
60883
|
// src/api/commons-routes.ts
|
|
60190
60884
|
function filtersFromQuery(query) {
|
|
60191
60885
|
return {
|
|
@@ -60231,10 +60925,23 @@ function repositoryStatus(error) {
|
|
|
60231
60925
|
if (error.httpStatus === 409) return 409;
|
|
60232
60926
|
return 400;
|
|
60233
60927
|
}
|
|
60928
|
+
async function publicationOperation(c, operation, successStatus = 200) {
|
|
60929
|
+
try {
|
|
60930
|
+
return c.json({ ok: true, data: await operation() }, successStatus);
|
|
60931
|
+
} catch (error) {
|
|
60932
|
+
return publicationError(c, error);
|
|
60933
|
+
}
|
|
60934
|
+
}
|
|
60935
|
+
function publicationError(c, error) {
|
|
60936
|
+
if (error instanceof CommonsPublicationError) {
|
|
60937
|
+
return c.json({ ok: false, error: error.code, message: error.message }, error.httpStatus);
|
|
60938
|
+
}
|
|
60939
|
+
throw error;
|
|
60940
|
+
}
|
|
60234
60941
|
function xmlEscape(value) {
|
|
60235
60942
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
60236
60943
|
}
|
|
60237
|
-
var import_hono31, import_zod50, commonsApp, auth2, SearchBodySchema, FeaturedImageSchema, MediaSchema, CitationSchema, RelatedLinkSchema, SubmitEntitySchema, PrepareEntitySchema, ValidateEntitySchema, SaveFilterSchema, NeedsLinkBodySchema;
|
|
60944
|
+
var import_hono31, import_zod50, commonsApp, auth2, SearchBodySchema, FeaturedImageSchema, MediaSchema, CitationSchema, RelatedLinkSchema, SubmitEntitySchema, PrepareEntitySchema, ValidateEntitySchema, SaveFilterSchema, NeedsLinkBodySchema, PreparePublicationSchema, ValidatePublicationSchema, ClaimPublicationSchema, PublishEditorialSchema;
|
|
60238
60945
|
var init_commons_routes = __esm({
|
|
60239
60946
|
"src/api/commons-routes.ts"() {
|
|
60240
60947
|
"use strict";
|
|
@@ -60243,6 +60950,8 @@ var init_commons_routes = __esm({
|
|
|
60243
60950
|
init_api_auth();
|
|
60244
60951
|
init_commons_repository();
|
|
60245
60952
|
init_listing_write_billing();
|
|
60953
|
+
init_commons_publication_repository();
|
|
60954
|
+
init_mcp_tool_schemas();
|
|
60246
60955
|
commonsApp = new import_hono31.Hono();
|
|
60247
60956
|
auth2 = createApiKeyAuth();
|
|
60248
60957
|
SearchBodySchema = import_zod50.z.object({
|
|
@@ -60403,10 +61112,83 @@ var init_commons_routes = __esm({
|
|
|
60403
61112
|
limit: import_zod50.z.number().int().min(1).max(100).optional(),
|
|
60404
61113
|
offset: import_zod50.z.number().int().min(0).max(1e4).optional()
|
|
60405
61114
|
}).strict();
|
|
61115
|
+
PreparePublicationSchema = import_zod50.z.object(CommonsPreparePublicationInputSchema).strict();
|
|
61116
|
+
ValidatePublicationSchema = import_zod50.z.object(CommonsValidatePublicationInputSchema).strict();
|
|
61117
|
+
ClaimPublicationSchema = import_zod50.z.object(CommonsClaimPublicationInputSchema).strict();
|
|
61118
|
+
PublishEditorialSchema = import_zod50.z.object(CommonsPublishEditorialInputSchema).strict();
|
|
60406
61119
|
commonsApp.get("/health", async (c) => {
|
|
60407
61120
|
await ensureCommonsSchema();
|
|
60408
61121
|
return c.json({ ok: true, data: commonsDatabaseReport() });
|
|
60409
61122
|
});
|
|
61123
|
+
commonsApp.post("/publications/prepare", auth2, async (c) => {
|
|
61124
|
+
const parsed = PreparePublicationSchema.safeParse(await c.req.json().catch(() => ({})));
|
|
61125
|
+
if (!parsed.success) return validationError(c, parsed.error);
|
|
61126
|
+
return publicationOperation(c, () => prepareCommonsPublication(parsed.data, c.get("user")));
|
|
61127
|
+
});
|
|
61128
|
+
commonsApp.post("/publications/validate", auth2, async (c) => {
|
|
61129
|
+
const parsed = ValidatePublicationSchema.safeParse(await c.req.json().catch(() => ({})));
|
|
61130
|
+
if (!parsed.success) return validationError(c, parsed.error);
|
|
61131
|
+
return publicationOperation(c, () => validateCommonsPublication(parsed.data, c.get("user")));
|
|
61132
|
+
});
|
|
61133
|
+
commonsApp.post("/publications/claim", auth2, async (c) => {
|
|
61134
|
+
const parsed = ClaimPublicationSchema.safeParse(await c.req.json().catch(() => ({})));
|
|
61135
|
+
if (!parsed.success) return validationError(c, parsed.error);
|
|
61136
|
+
return publicationOperation(c, () => claimCommonsPublication(parsed.data, c.get("user")), 201);
|
|
61137
|
+
});
|
|
61138
|
+
commonsApp.post("/publications/publish", auth2, async (c) => {
|
|
61139
|
+
const parsed = PublishEditorialSchema.safeParse(await c.req.json().catch(() => ({})));
|
|
61140
|
+
if (!parsed.success) return validationError(c, parsed.error);
|
|
61141
|
+
return publicationOperation(c, () => publishCommonsEditorial(parsed.data, c.get("user")), 201);
|
|
61142
|
+
});
|
|
61143
|
+
commonsApp.get("/publications/me", auth2, async (c) => {
|
|
61144
|
+
const publication = await getCommonsPublicationForOwner(Number(c.get("user").id));
|
|
61145
|
+
if (!publication) return c.json({ ok: false, error: "publication_not_found", message: "This account has not claimed a Commons publication yet." }, 404);
|
|
61146
|
+
const editions = c.req.query("includeEditions") === "false" ? [] : await listCommonsPublicationEditions(publication.id);
|
|
61147
|
+
return c.json({ ok: true, data: { publication, editions } });
|
|
61148
|
+
});
|
|
61149
|
+
commonsApp.get("/publications/:subdomain/site", async (c) => {
|
|
61150
|
+
try {
|
|
61151
|
+
const result = await getCommonsPublicationEditionHtml(c.req.param("subdomain"));
|
|
61152
|
+
if (!result) return c.json({ ok: false, error: "publication_not_published", message: "No published edition exists for this publication." }, 404);
|
|
61153
|
+
return c.html(result.html, 200, {
|
|
61154
|
+
"cache-control": "public, max-age=60, s-maxage=300",
|
|
61155
|
+
"x-robots-tag": "index, follow"
|
|
61156
|
+
});
|
|
61157
|
+
} catch (error) {
|
|
61158
|
+
return publicationError(c, error);
|
|
61159
|
+
}
|
|
61160
|
+
});
|
|
61161
|
+
commonsApp.get("/publications/:subdomain/editions/:editionSlug/site", async (c) => {
|
|
61162
|
+
try {
|
|
61163
|
+
const result = await getCommonsPublicationEditionHtml(c.req.param("subdomain"), c.req.param("editionSlug"));
|
|
61164
|
+
if (!result) return c.json({ ok: false, error: "edition_not_found", message: "No published edition matched that publication and slug." }, 404);
|
|
61165
|
+
return c.html(result.html, 200, {
|
|
61166
|
+
"cache-control": "public, max-age=60, s-maxage=300",
|
|
61167
|
+
"x-robots-tag": "index, follow"
|
|
61168
|
+
});
|
|
61169
|
+
} catch (error) {
|
|
61170
|
+
return publicationError(c, error);
|
|
61171
|
+
}
|
|
61172
|
+
});
|
|
61173
|
+
commonsApp.get("/publications/:subdomain/editions", async (c) => {
|
|
61174
|
+
try {
|
|
61175
|
+
const publication = await getCommonsPublicationBySubdomain(c.req.param("subdomain"));
|
|
61176
|
+
if (!publication) return c.json({ ok: false, error: "publication_not_found", message: "No Commons publication matched that name." }, 404);
|
|
61177
|
+
return c.json({ ok: true, data: { publication, editions: await listCommonsPublicationEditions(publication.id) } });
|
|
61178
|
+
} catch (error) {
|
|
61179
|
+
return publicationError(c, error);
|
|
61180
|
+
}
|
|
61181
|
+
});
|
|
61182
|
+
commonsApp.get("/publications/:subdomain", async (c) => {
|
|
61183
|
+
try {
|
|
61184
|
+
const publication = await getCommonsPublicationBySubdomain(c.req.param("subdomain"));
|
|
61185
|
+
if (!publication) return c.json({ ok: false, error: "publication_not_found", message: "No Commons publication matched that name." }, 404);
|
|
61186
|
+
const editions = c.req.query("includeEditions") === "false" ? [] : await listCommonsPublicationEditions(publication.id);
|
|
61187
|
+
return c.json({ ok: true, data: { publication, editions } });
|
|
61188
|
+
} catch (error) {
|
|
61189
|
+
return publicationError(c, error);
|
|
61190
|
+
}
|
|
61191
|
+
});
|
|
60410
61192
|
commonsApp.get("/entities", async (c) => {
|
|
60411
61193
|
const result = await searchCommonsEntities(filtersFromQuery(c.req.query()));
|
|
60412
61194
|
return c.json({ ok: true, data: result });
|
|
@@ -60529,13 +61311,13 @@ ${urls.join("\n")}
|
|
|
60529
61311
|
|
|
60530
61312
|
// src/api/scheduled-artifact-owner.ts
|
|
60531
61313
|
function scheduledArtifactOwnerIdForApiKey(apiKey) {
|
|
60532
|
-
return (0,
|
|
61314
|
+
return (0, import_node_crypto36.createHash)("sha256").update(apiKey).digest("hex").slice(0, 24);
|
|
60533
61315
|
}
|
|
60534
|
-
var
|
|
61316
|
+
var import_node_crypto36;
|
|
60535
61317
|
var init_scheduled_artifact_owner = __esm({
|
|
60536
61318
|
"src/api/scheduled-artifact-owner.ts"() {
|
|
60537
61319
|
"use strict";
|
|
60538
|
-
|
|
61320
|
+
import_node_crypto36 = require("crypto");
|
|
60539
61321
|
}
|
|
60540
61322
|
});
|
|
60541
61323
|
|
|
@@ -60551,13 +61333,36 @@ async function ensureScheduledRunViewLinksSchema() {
|
|
|
60551
61333
|
artifact_id TEXT NOT NULL,
|
|
60552
61334
|
title TEXT NOT NULL,
|
|
60553
61335
|
summary TEXT NOT NULL,
|
|
60554
|
-
renderer_key TEXT NOT NULL CHECK (renderer_key
|
|
61336
|
+
renderer_key TEXT NOT NULL CHECK (renderer_key IN ('editorial_reading_room_v1','personal_authority_v1')),
|
|
60555
61337
|
token_hash TEXT NOT NULL UNIQUE,
|
|
60556
61338
|
expires_at TEXT NOT NULL,
|
|
60557
61339
|
revoked_at TEXT,
|
|
60558
61340
|
created_at TEXT NOT NULL
|
|
60559
61341
|
)
|
|
60560
61342
|
`);
|
|
61343
|
+
const schema = await db.execute({
|
|
61344
|
+
sql: `SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'scheduled_run_view_links' LIMIT 1`,
|
|
61345
|
+
args: []
|
|
61346
|
+
});
|
|
61347
|
+
const createSql = String(schema.rows[0]?.sql ?? "");
|
|
61348
|
+
if (createSql.includes("renderer_key = 'editorial_reading_room_v1'")) {
|
|
61349
|
+
await db.batch([
|
|
61350
|
+
`DROP TABLE IF EXISTS scheduled_run_view_links_v2`,
|
|
61351
|
+
`CREATE TABLE scheduled_run_view_links_v2 (
|
|
61352
|
+
share_id TEXT PRIMARY KEY, owner_id TEXT NOT NULL, run_id TEXT NOT NULL,
|
|
61353
|
+
artifact_id TEXT NOT NULL, title TEXT NOT NULL, summary TEXT NOT NULL,
|
|
61354
|
+
renderer_key TEXT NOT NULL CHECK (renderer_key IN ('editorial_reading_room_v1','personal_authority_v1')),
|
|
61355
|
+
token_hash TEXT NOT NULL UNIQUE, expires_at TEXT NOT NULL, revoked_at TEXT,
|
|
61356
|
+
created_at TEXT NOT NULL
|
|
61357
|
+
)`,
|
|
61358
|
+
`INSERT INTO scheduled_run_view_links_v2
|
|
61359
|
+
SELECT share_id, owner_id, run_id, artifact_id, title, summary, renderer_key,
|
|
61360
|
+
token_hash, expires_at, revoked_at, created_at
|
|
61361
|
+
FROM scheduled_run_view_links`,
|
|
61362
|
+
`DROP TABLE scheduled_run_view_links`,
|
|
61363
|
+
`ALTER TABLE scheduled_run_view_links_v2 RENAME TO scheduled_run_view_links`
|
|
61364
|
+
], "write");
|
|
61365
|
+
}
|
|
60561
61366
|
await db.execute(`
|
|
60562
61367
|
CREATE INDEX IF NOT EXISTS scheduled_run_view_links_owner_run
|
|
60563
61368
|
ON scheduled_run_view_links(owner_id, run_id, created_at DESC)
|
|
@@ -60569,7 +61374,7 @@ async function ensureScheduledRunViewLinksSchema() {
|
|
|
60569
61374
|
schemaReady3 = true;
|
|
60570
61375
|
}
|
|
60571
61376
|
function tokenHash2(token4) {
|
|
60572
|
-
return (0,
|
|
61377
|
+
return (0, import_node_crypto37.createHash)("sha256").update(token4).digest("hex");
|
|
60573
61378
|
}
|
|
60574
61379
|
function mapRow(row) {
|
|
60575
61380
|
return {
|
|
@@ -60579,7 +61384,7 @@ function mapRow(row) {
|
|
|
60579
61384
|
artifactId: String(row.artifact_id),
|
|
60580
61385
|
title: String(row.title),
|
|
60581
61386
|
summary: String(row.summary),
|
|
60582
|
-
rendererKey: "editorial_reading_room_v1",
|
|
61387
|
+
rendererKey: row.renderer_key === "personal_authority_v1" ? "personal_authority_v1" : "editorial_reading_room_v1",
|
|
60583
61388
|
tokenHash: String(row.token_hash),
|
|
60584
61389
|
expiresAt: String(row.expires_at),
|
|
60585
61390
|
revokedAt: row.revoked_at == null ? null : String(row.revoked_at),
|
|
@@ -60589,9 +61394,9 @@ function mapRow(row) {
|
|
|
60589
61394
|
async function createScheduledRunViewLink(input) {
|
|
60590
61395
|
await ensureScheduledRunViewLinksSchema();
|
|
60591
61396
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
60592
|
-
const token4 = (0,
|
|
61397
|
+
const token4 = (0, import_node_crypto37.randomBytes)(32).toString("base64url");
|
|
60593
61398
|
const record = {
|
|
60594
|
-
shareId: (0,
|
|
61399
|
+
shareId: (0, import_node_crypto37.randomUUID)(),
|
|
60595
61400
|
ownerId: input.ownerId,
|
|
60596
61401
|
runId: input.runId,
|
|
60597
61402
|
artifactId: input.artifactId,
|
|
@@ -60654,16 +61459,146 @@ async function revokeScheduledRunViewLink(ownerId, runId, shareId, now = /* @__P
|
|
|
60654
61459
|
});
|
|
60655
61460
|
return result.rowsAffected > 0;
|
|
60656
61461
|
}
|
|
60657
|
-
var
|
|
61462
|
+
var import_node_crypto37, schemaReady3;
|
|
60658
61463
|
var init_scheduled_run_view_links = __esm({
|
|
60659
61464
|
"src/api/scheduled-run-view-links.ts"() {
|
|
60660
61465
|
"use strict";
|
|
60661
|
-
|
|
61466
|
+
import_node_crypto37 = require("crypto");
|
|
60662
61467
|
init_db();
|
|
60663
61468
|
schemaReady3 = false;
|
|
60664
61469
|
}
|
|
60665
61470
|
});
|
|
60666
61471
|
|
|
61472
|
+
// src/personal-authority/render.ts
|
|
61473
|
+
function escapeHtml7(value) {
|
|
61474
|
+
return value.replace(/[&<>"']/g, (character) => ({
|
|
61475
|
+
"&": "&",
|
|
61476
|
+
"<": "<",
|
|
61477
|
+
">": ">",
|
|
61478
|
+
'"': """,
|
|
61479
|
+
"'": "'"
|
|
61480
|
+
})[character] ?? character);
|
|
61481
|
+
}
|
|
61482
|
+
function safeHref(value) {
|
|
61483
|
+
const trimmed = value.trim();
|
|
61484
|
+
return /^(?:https?:|mailto:|tel:|#|\/)/i.test(trimmed) ? escapeHtml7(trimmed) : "#";
|
|
61485
|
+
}
|
|
61486
|
+
function initials(name) {
|
|
61487
|
+
return name.split(/\s+/).filter(Boolean).slice(0, 2).map((part) => part[0]?.toUpperCase()).join("") || "PA";
|
|
61488
|
+
}
|
|
61489
|
+
function action(action2, secondary = false) {
|
|
61490
|
+
return `<a class="button${secondary ? " button--secondary" : ""}" href="${safeHref(action2.href)}">${escapeHtml7(action2.label)} <span aria-hidden="true">\u2197</span></a>`;
|
|
61491
|
+
}
|
|
61492
|
+
function section(enabled, html) {
|
|
61493
|
+
return enabled ? html : "";
|
|
61494
|
+
}
|
|
61495
|
+
function renderPersonalAuthorityV1(input, config, generatedAt) {
|
|
61496
|
+
const flags = config.featureFlags;
|
|
61497
|
+
const brand = config.brandName || input.name;
|
|
61498
|
+
const generatedAtIso = generatedAt.toISOString();
|
|
61499
|
+
const social = flags.socialLinks && input.socialLinks.length > 0 ? `<nav class="social" aria-label="Professional profiles">${input.socialLinks.map((link) => `<a href="${safeHref(link.href)}">${escapeHtml7(link.label)}</a>`).join("")}</nav>` : "";
|
|
61500
|
+
const navigation = flags.navigation ? `<button class="menu" type="button" aria-expanded="false" aria-controls="nav">Menu</button><nav id="nav" class="nav" aria-label="Primary navigation"><a href="#about">About</a><a href="#services">Work</a><a href="#proof">Proof</a><a href="#contact">Contact</a></nav>` : "";
|
|
61501
|
+
const authority = input.authority;
|
|
61502
|
+
const consultation = input.consultation;
|
|
61503
|
+
const learning = input.learning;
|
|
61504
|
+
const services = input.services;
|
|
61505
|
+
const proof = input.proof;
|
|
61506
|
+
const finalCta = input.finalCta;
|
|
61507
|
+
const html = `<!doctype html>
|
|
61508
|
+
<html lang="en" data-theme="${config.theme}">
|
|
61509
|
+
<head>
|
|
61510
|
+
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
61511
|
+
<meta name="description" content="${escapeHtml7(input.summary)}"><title>${escapeHtml7(input.name)} \u2014 ${escapeHtml7(input.professionalTitle)}</title>
|
|
61512
|
+
<style>
|
|
61513
|
+
:root{--blue:#2f66eb;--blue-soft:#dbe6ff;--ink:#050708;--paper:#f7f8fb;--white:#fff;--gray:#9ca5b5;--line:#27303b;--serif:Georgia,'Times New Roman',serif;--sans:Arial,Helvetica,sans-serif}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--ink);color:var(--white);font-family:var(--sans);line-height:1.55}a{color:inherit}.skip{position:absolute;left:-9999px}.skip:focus{left:16px;top:16px;z-index:9;background:#fff;color:#000;padding:10px}.header{height:88px;display:flex;align-items:center;justify-content:space-between;padding:0 clamp(20px,4vw,72px);border-bottom:1px solid var(--line);position:relative;z-index:3;background:rgba(5,7,8,.96)}.brand{display:flex;align-items:center;gap:12px;text-decoration:none;font-family:var(--serif);font-size:24px}.mark{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;background:var(--blue);font-family:var(--sans);font-weight:700}.nav{display:flex;align-items:center;gap:28px}.nav a{text-decoration:none;color:#c8ced8;font-size:14px}.nav a:hover{color:#fff}.menu{display:none;background:transparent;color:#fff;border:1px solid #5b6471;padding:10px 14px}.hero{display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.25fr);min-height:760px;border-bottom:3px solid var(--blue)}.portrait{display:grid;place-items:end center;background:radial-gradient(circle at 50% 38%,#273243 0,#11161d 38%,#060708 70%);overflow:hidden}.portrait-card{width:min(82%,560px);aspect-ratio:4/5;display:grid;place-items:center;align-self:end;border:1px solid #263142;border-bottom:0;background:linear-gradient(145deg,#252d38,#0b0d10 58%);font-family:var(--serif);font-size:clamp(80px,13vw,180px);color:#d9e4ff;text-shadow:0 0 42px rgba(47,102,235,.5)}.hero-copy{padding:clamp(44px,7vw,110px) clamp(24px,6vw,100px);display:flex;flex-direction:column;justify-content:center;background:linear-gradient(135deg,#080a0d,#101318)}h1,h2,h3,p{margin-top:0}.hero h1{font-family:var(--serif);font-size:clamp(58px,8vw,116px);line-height:.92;font-weight:400;color:var(--blue);margin-bottom:24px}.role{font-family:var(--serif);font-size:clamp(28px,3.8vw,52px);line-height:1.05;border-left:5px solid var(--blue);padding-left:22px;max-width:820px}.summary{color:#c6cbd3;font-size:clamp(17px,1.5vw,22px);max-width:760px}.actions{display:flex;gap:12px;flex-wrap:wrap;margin:24px 0}.button{display:inline-flex;align-items:center;justify-content:space-between;gap:28px;min-height:58px;padding:0 26px;background:var(--blue);border:1px solid var(--blue);text-decoration:none;font-weight:700}.button--secondary{background:transparent;border-color:#5c6572}.social{display:flex;gap:10px;flex-wrap:wrap}.social a{border:1px solid #39414d;border-radius:999px;padding:8px 13px;text-decoration:none;color:#d8dce4;font-size:13px}.light{background:var(--paper);color:#111722;padding:clamp(70px,10vw,150px) clamp(20px,6vw,90px)}.light h2,.section h2{font-family:var(--serif);font-size:clamp(42px,6vw,82px);line-height:1.02;font-weight:400;max-width:1080px}.light p{max-width:920px;color:#4e596a;font-size:18px}.section{padding:clamp(70px,9vw,130px) clamp(20px,6vw,90px);border-bottom:1px solid var(--line)}.section-head{max-width:920px;margin-bottom:46px}.eyebrow{text-transform:uppercase;letter-spacing:.18em;font-size:12px;color:#aab2bf}.consult{display:grid;grid-template-columns:1.3fr .7fr;gap:50px;background:linear-gradient(130deg,#060708,#111721)}.accent-card{min-height:360px;border:1px solid #2a3545;background:linear-gradient(145deg,rgba(47,102,235,.22),transparent 55%);display:grid;place-items:center;font-family:var(--serif);font-size:96px;color:var(--blue)}.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.card{border:1px solid #323a46;padding:26px;min-height:220px;background:#0b0e12}.card h3{font-family:var(--serif);font-size:30px}.card p{color:#b9c0ca}.learning{background:#020303}.topic-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1px;background:#29313c;border:1px solid #29313c}.topic{background:#050708;padding:30px}.topic strong{display:block;color:var(--blue);text-transform:uppercase;font-size:11px;letter-spacing:.15em}.topic h3{font-family:var(--serif);font-size:30px;margin:8px 0}.topic p{color:#aeb6c1}.proof{background:linear-gradient(180deg,#0a0d11,#050607)}.quotes{display:flex;gap:14px;overflow:auto;scroll-snap-type:x mandatory;padding-bottom:12px}.quote{min-width:min(420px,86vw);scroll-snap-align:start;border:1px solid #343d49;padding:30px;background:#0c1015}.quote q{font-family:var(--serif);font-size:30px;line-height:1.25}.quote span{display:block;margin-top:24px;color:#aeb5c0;font-size:12px;text-transform:uppercase;letter-spacing:.12em}.cta{text-align:center;border-top:3px solid var(--blue);background:radial-gradient(circle at 50% 0,rgba(47,102,235,.25),transparent 50%)}.cta h2{margin-left:auto;margin-right:auto}.footer{display:grid;grid-template-columns:1fr auto;gap:40px;padding:46px clamp(20px,6vw,90px);color:#abb3bf}.footer strong{color:#fff;font-family:var(--serif);font-size:26px}.generated{font-size:11px;color:#737d8b;margin-top:10px}html[data-theme='slate']{--blue:#7f95b8;--blue-soft:#dfe6ef}html[data-theme='monochrome']{--blue:#fff;--blue-soft:#e7e7e7}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
|
|
61514
|
+
@media(max-width:760px){.header{height:78px}.menu{display:block}.nav{display:none;position:absolute;left:0;right:0;top:77px;padding:18px 20px;background:#090b0e;border-bottom:1px solid #303844;flex-direction:column;align-items:stretch}.nav.open{display:flex}.hero{grid-template-columns:1fr;min-height:0}.portrait{min-height:390px}.portrait-card{width:72%;max-height:360px}.hero-copy{padding:48px 20px 66px}.hero h1{font-size:64px}.role{font-size:34px}.actions{display:grid}.button{width:100%}.consult{grid-template-columns:1fr}.accent-card{min-height:220px}.grid,.topic-grid{grid-template-columns:1fr}.light,.section{padding:64px 20px}.light h2,.section h2{font-size:46px}.footer{grid-template-columns:1fr}}
|
|
61515
|
+
</style></head>
|
|
61516
|
+
<body><a class="skip" href="#main">Skip to main content</a>
|
|
61517
|
+
<header class="header"><a class="brand" href="#top"><span class="mark">${escapeHtml7(initials(input.name).slice(0, 1))}</span><strong>${escapeHtml7(brand)}</strong></a>${navigation}</header>
|
|
61518
|
+
<main id="main"><section class="hero" id="top"><div class="portrait" aria-label="Portrait placeholder"><div class="portrait-card" aria-hidden="true">${escapeHtml7(initials(input.name))}</div></div><div class="hero-copy"><h1>${escapeHtml7(input.name)}</h1><p class="role">${escapeHtml7(input.professionalTitle)}</p><p class="summary">${escapeHtml7(input.summary)}</p><div class="actions">${action(input.primaryAction)}${input.secondaryAction ? action(input.secondaryAction, true) : ""}</div>${social}</div></section>
|
|
61519
|
+
${section(flags.authority && Boolean(authority), `<section class="light" id="about"><h2>${escapeHtml7(authority?.heading ?? "")}</h2>${authority?.paragraphs.map((paragraph) => `<p>${escapeHtml7(paragraph)}</p>`).join("") ?? ""}</section>`)}
|
|
61520
|
+
${section(flags.consultation && Boolean(consultation), `<section class="section consult"><div><p class="eyebrow">${escapeHtml7(consultation?.eyebrow ?? "Start a conversation")}</p><h2>${escapeHtml7(consultation?.heading ?? "")}</h2><p class="summary">${escapeHtml7(consultation?.summary ?? "")}</p>${consultation ? action(consultation.action) : ""}</div><div class="accent-card" aria-label="Image placeholder">${escapeHtml7(initials(input.name))}</div></section>`)}
|
|
61521
|
+
${section(flags.learning && Boolean(learning), `<section class="section learning"><div class="section-head"><h2>${escapeHtml7(learning?.heading ?? "")}</h2><p class="summary">${escapeHtml7(learning?.summary ?? "")}</p></div><div class="topic-grid">${learning?.topics.map((topic) => `<article class="topic"><strong>${escapeHtml7(topic.title)}</strong><h3>${escapeHtml7(topic.headline)}</h3><p>${escapeHtml7(topic.summary)}</p>${topic.href ? `<a href="${safeHref(topic.href)}">Explore \u2192</a>` : ""}</article>`).join("") ?? ""}</div></section>`)}
|
|
61522
|
+
${section(flags.services && Boolean(services), `<section class="section" id="services"><div class="section-head"><h2>${escapeHtml7(services?.heading ?? "")}</h2><p class="summary">${escapeHtml7(services?.summary ?? "")}</p></div><div class="grid">${services?.offers.map((offer) => `<article class="card"><h3>${escapeHtml7(offer.title)}</h3><p>${escapeHtml7(offer.description)}</p>${offer.action ? action(offer.action, true) : ""}</article>`).join("") ?? ""}</div></section>`)}
|
|
61523
|
+
${section(flags.proof && Boolean(proof), `<section class="section proof" id="proof"><div class="section-head"><h2>${escapeHtml7(proof?.heading ?? "")}</h2><p class="summary">${escapeHtml7(proof?.summary ?? "")}</p></div><div class="quotes">${proof?.testimonials.map((item) => `<article class="quote"><q>${escapeHtml7(item.quote)}</q><span>${escapeHtml7(item.person)}${item.role ? ` / ${escapeHtml7(item.role)}` : ""}</span></article>`).join("") ?? ""}</div></section>`)}
|
|
61524
|
+
${section(flags.finalCta && Boolean(finalCta), `<section class="section cta" id="contact"><p class="eyebrow">${escapeHtml7(finalCta?.eyebrow ?? "Ready when you are")}</p><h2>${escapeHtml7(finalCta?.heading ?? "")}</h2><p class="summary">${escapeHtml7(finalCta?.summary ?? "")}</p>${finalCta ? action(finalCta.action) : ""}</section>`)}
|
|
61525
|
+
</main><footer class="footer"><div><strong>${escapeHtml7(input.name)}</strong><div>${escapeHtml7(input.professionalTitle)}</div>${config.showGeneratedAt ? `<div class="generated">Generated ${escapeHtml7(generatedAtIso)}</div>` : ""}</div><div>${input.location ? `<div>${escapeHtml7(input.location)}</div>` : ""}${input.email ? `<a href="mailto:${escapeHtml7(input.email)}">${escapeHtml7(input.email)}</a>` : ""}${input.phone ? `<div>${escapeHtml7(input.phone)}</div>` : ""}</div></footer>
|
|
61526
|
+
<script>document.querySelector('.menu')?.addEventListener('click',function(){var nav=document.querySelector('.nav');var open=this.getAttribute('aria-expanded')!=='true';this.setAttribute('aria-expanded',String(open));nav?.classList.toggle('open',open)});document.querySelectorAll('.nav a').forEach(function(link){link.addEventListener('click',function(){document.querySelector('.nav')?.classList.remove('open');document.querySelector('.menu')?.setAttribute('aria-expanded','false')})});</script></body></html>`;
|
|
61527
|
+
const bytes = Buffer.byteLength(html, "utf8");
|
|
61528
|
+
return {
|
|
61529
|
+
html,
|
|
61530
|
+
filename: `${input.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "personal-authority"}.html`,
|
|
61531
|
+
bytes,
|
|
61532
|
+
sha256: (0, import_node_crypto38.createHash)("sha256").update(html).digest("hex"),
|
|
61533
|
+
generatedAt: generatedAtIso
|
|
61534
|
+
};
|
|
61535
|
+
}
|
|
61536
|
+
var import_node_crypto38;
|
|
61537
|
+
var init_render2 = __esm({
|
|
61538
|
+
"src/personal-authority/render.ts"() {
|
|
61539
|
+
"use strict";
|
|
61540
|
+
import_node_crypto38 = require("crypto");
|
|
61541
|
+
}
|
|
61542
|
+
});
|
|
61543
|
+
|
|
61544
|
+
// src/scheduled-artifacts/scheduled-artifact-renderer-registry.ts
|
|
61545
|
+
function getScheduledArtifactRenderer(rendererKey, rendererVersion) {
|
|
61546
|
+
return scheduledArtifactRendererRegistry[`${rendererKey}:${rendererVersion}`] ?? null;
|
|
61547
|
+
}
|
|
61548
|
+
var editorialReadingRoomV1, personalAuthorityV1, scheduledArtifactRendererRegistry, scheduledArtifactTemplatePresets;
|
|
61549
|
+
var init_scheduled_artifact_renderer_registry = __esm({
|
|
61550
|
+
"src/scheduled-artifacts/scheduled-artifact-renderer-registry.ts"() {
|
|
61551
|
+
"use strict";
|
|
61552
|
+
init_render();
|
|
61553
|
+
init_render2();
|
|
61554
|
+
init_contracts();
|
|
61555
|
+
editorialReadingRoomV1 = {
|
|
61556
|
+
rendererKey: "editorial_reading_room_v1",
|
|
61557
|
+
rendererVersion: 1,
|
|
61558
|
+
async render(rawInput, rawConfig, generatedAt) {
|
|
61559
|
+
const input = EditorialReadingRoomV1InputSchema.parse(rawInput);
|
|
61560
|
+
const config = EditorialArtifactTemplateConfigSchema.parse(rawConfig);
|
|
61561
|
+
const rendered = renderEditorialReadingRoomV1(input, config, generatedAt);
|
|
61562
|
+
if (rendered.bytes > 2e6) {
|
|
61563
|
+
throw new Error("Scheduled artifact HTML must be 2,000,000 bytes or fewer.");
|
|
61564
|
+
}
|
|
61565
|
+
return {
|
|
61566
|
+
html: rendered.html,
|
|
61567
|
+
filename: rendered.filename,
|
|
61568
|
+
title: input.title,
|
|
61569
|
+
bytes: rendered.bytes,
|
|
61570
|
+
sha256: rendered.sha256,
|
|
61571
|
+
generatedAt: rendered.generatedAt
|
|
61572
|
+
};
|
|
61573
|
+
}
|
|
61574
|
+
};
|
|
61575
|
+
personalAuthorityV1 = {
|
|
61576
|
+
rendererKey: "personal_authority_v1",
|
|
61577
|
+
rendererVersion: 1,
|
|
61578
|
+
async render(rawInput, rawConfig, generatedAt) {
|
|
61579
|
+
const input = PersonalAuthorityV1InputSchema.parse(rawInput);
|
|
61580
|
+
const config = PersonalAuthorityTemplateConfigSchema.parse(rawConfig);
|
|
61581
|
+
const rendered = renderPersonalAuthorityV1(input, config, generatedAt);
|
|
61582
|
+
if (rendered.bytes > 2e6) {
|
|
61583
|
+
throw new Error("Scheduled artifact HTML must be 2,000,000 bytes or fewer.");
|
|
61584
|
+
}
|
|
61585
|
+
return {
|
|
61586
|
+
...rendered,
|
|
61587
|
+
title: input.name
|
|
61588
|
+
};
|
|
61589
|
+
}
|
|
61590
|
+
};
|
|
61591
|
+
scheduledArtifactRendererRegistry = Object.freeze({
|
|
61592
|
+
"editorial_reading_room_v1:1": editorialReadingRoomV1,
|
|
61593
|
+
"personal_authority_v1:1": personalAuthorityV1
|
|
61594
|
+
});
|
|
61595
|
+
scheduledArtifactTemplatePresets = [
|
|
61596
|
+
EDITORIAL_READING_ROOM_TEMPLATE_PRESET,
|
|
61597
|
+
PERSONAL_AUTHORITY_TEMPLATE_PRESET
|
|
61598
|
+
];
|
|
61599
|
+
}
|
|
61600
|
+
});
|
|
61601
|
+
|
|
60667
61602
|
// src/api/scheduled-result-routes.ts
|
|
60668
61603
|
function apiError(error, errorCode = "invalid_request") {
|
|
60669
61604
|
return { ok: false, error, errorCode };
|
|
@@ -60703,6 +61638,7 @@ var init_scheduled_result_routes = __esm({
|
|
|
60703
61638
|
init_scheduled_artifact_owner();
|
|
60704
61639
|
init_scheduled_run_view_links();
|
|
60705
61640
|
init_contracts();
|
|
61641
|
+
init_scheduled_artifact_renderer_registry();
|
|
60706
61642
|
TemplateParamsSchema = import_zod51.z.object({ templateId: import_zod51.z.string().uuid() }).strict();
|
|
60707
61643
|
RunParamsSchema = import_zod51.z.object({ runId: import_zod51.z.string().min(1).max(200) }).strict();
|
|
60708
61644
|
ViewLinkParamsSchema = import_zod51.z.object({
|
|
@@ -60726,7 +61662,7 @@ var init_scheduled_result_routes = __esm({
|
|
|
60726
61662
|
c.header("Cache-Control", "private, no-store");
|
|
60727
61663
|
return c.json({
|
|
60728
61664
|
...result,
|
|
60729
|
-
presets: Array.isArray(result.presets) ? result.presets :
|
|
61665
|
+
presets: Array.isArray(result.presets) ? result.presets : scheduledArtifactTemplatePresets
|
|
60730
61666
|
});
|
|
60731
61667
|
});
|
|
60732
61668
|
scheduledResultApp.post("/artifact-templates", async (c) => {
|
|
@@ -60859,7 +61795,7 @@ function policy4() {
|
|
|
60859
61795
|
};
|
|
60860
61796
|
}
|
|
60861
61797
|
function runStorageSegment(runId) {
|
|
60862
|
-
return /^[a-zA-Z0-9_-]{1,160}$/.test(runId) ? runId : `run-${(0,
|
|
61798
|
+
return /^[a-zA-Z0-9_-]{1,160}$/.test(runId) ? runId : `run-${(0, import_node_crypto39.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}`;
|
|
60863
61799
|
}
|
|
60864
61800
|
async function createScheduledRunArtifact(args) {
|
|
60865
61801
|
if (args.rendered.bytes > SCHEDULED_RUN_ARTIFACT_MAX_BYTES) {
|
|
@@ -60900,12 +61836,12 @@ async function readScheduledRunArtifact(args) {
|
|
|
60900
61836
|
if (!window2 || window2.nextOffset !== null || window2.totalBytes > SCHEDULED_RUN_ARTIFACT_MAX_BYTES) return null;
|
|
60901
61837
|
return window2.text;
|
|
60902
61838
|
}
|
|
60903
|
-
var
|
|
61839
|
+
var import_node_crypto39, SCHEDULED_RUN_ARTIFACT_PREFIX, SCHEDULED_RUN_ARTIFACT_DOWNLOAD_TTL_MS, SCHEDULED_RUN_ARTIFACT_MAX_BYTES;
|
|
60904
61840
|
var init_scheduled_run_artifact_store = __esm({
|
|
60905
61841
|
"src/scheduled-artifacts/scheduled-run-artifact-store.ts"() {
|
|
60906
61842
|
"use strict";
|
|
60907
61843
|
init_private_artifacts();
|
|
60908
|
-
|
|
61844
|
+
import_node_crypto39 = require("crypto");
|
|
60909
61845
|
SCHEDULED_RUN_ARTIFACT_PREFIX = "scheduled-run-artifacts/";
|
|
60910
61846
|
SCHEDULED_RUN_ARTIFACT_DOWNLOAD_TTL_MS = 15 * 60 * 1e3;
|
|
60911
61847
|
SCHEDULED_RUN_ARTIFACT_MAX_BYTES = 2e6;
|
|
@@ -61123,7 +62059,7 @@ async function reconcileDiscoveredNangoConnections(identity, discovered) {
|
|
|
61123
62059
|
updated_at = excluded.updated_at
|
|
61124
62060
|
`,
|
|
61125
62061
|
args: [
|
|
61126
|
-
(0,
|
|
62062
|
+
(0, import_node_crypto40.randomUUID)(),
|
|
61127
62063
|
userId,
|
|
61128
62064
|
connection.providerConfigKey,
|
|
61129
62065
|
connection.provider,
|
|
@@ -61194,7 +62130,7 @@ async function recordServiceConnectionHealth(args) {
|
|
|
61194
62130
|
});
|
|
61195
62131
|
await getDb().execute({
|
|
61196
62132
|
sql: `INSERT INTO service_connection_health_events (id, connection_id, operational_status, failure_code, retryable, evidence_source) VALUES (?, ?, ?, ?, ?, ?)`,
|
|
61197
|
-
args: [(0,
|
|
62133
|
+
args: [(0, import_node_crypto40.randomUUID)(), args.connectionId, args.operationalStatus, args.failureCode ?? null, args.retryable == null ? null : args.retryable ? 1 : 0, args.evidenceSource]
|
|
61198
62134
|
});
|
|
61199
62135
|
}
|
|
61200
62136
|
async function setServiceConnectionActions(identity, connectionId, enabled) {
|
|
@@ -61234,7 +62170,7 @@ async function claimServiceConnectionAction(args) {
|
|
|
61234
62170
|
if (!connection) throw new Error("service_connection_not_found");
|
|
61235
62171
|
const inserted = await getDb().execute({
|
|
61236
62172
|
sql: `INSERT OR IGNORE INTO service_connection_action_audit (id, connection_id, user_id, tool, request_id, status, request_digest) VALUES (?, ?, ?, ?, ?, 'started', ?)`,
|
|
61237
|
-
args: [(0,
|
|
62173
|
+
args: [(0, import_node_crypto40.randomUUID)(), connection.id, connection.userId, args.tool, args.requestId, args.requestDigest]
|
|
61238
62174
|
});
|
|
61239
62175
|
if (Number(inserted.rowsAffected ?? 0) === 1) return { claimed: true };
|
|
61240
62176
|
const existing = await getDb().execute({
|
|
@@ -61259,11 +62195,11 @@ async function claimServiceConnectionAction(args) {
|
|
|
61259
62195
|
...result !== void 0 ? { result } : {}
|
|
61260
62196
|
};
|
|
61261
62197
|
}
|
|
61262
|
-
var
|
|
62198
|
+
var import_node_crypto40, schemaReady4, schemaDb4;
|
|
61263
62199
|
var init_service_connections = __esm({
|
|
61264
62200
|
"src/api/service-connections.ts"() {
|
|
61265
62201
|
"use strict";
|
|
61266
|
-
|
|
62202
|
+
import_node_crypto40 = require("crypto");
|
|
61267
62203
|
init_db();
|
|
61268
62204
|
schemaReady4 = null;
|
|
61269
62205
|
schemaDb4 = null;
|
|
@@ -61277,8 +62213,8 @@ function signingSecret() {
|
|
|
61277
62213
|
return secret2;
|
|
61278
62214
|
}
|
|
61279
62215
|
function schedulerIntegrationSignature(args) {
|
|
61280
|
-
const bodyHash = (0,
|
|
61281
|
-
return (0,
|
|
62216
|
+
const bodyHash = (0, import_node_crypto41.createHash)("sha256").update(args.body).digest("hex");
|
|
62217
|
+
return (0, import_node_crypto41.createHmac)("sha256", args.secret).update(`${args.method.toUpperCase()}
|
|
61282
62218
|
${args.path}
|
|
61283
62219
|
${args.timestamp}
|
|
61284
62220
|
${args.nonce}
|
|
@@ -61325,17 +62261,17 @@ async function verifySchedulerIntegrationRequest(request, rawBody) {
|
|
|
61325
62261
|
});
|
|
61326
62262
|
const suppliedBytes = Buffer.from(signature, "hex");
|
|
61327
62263
|
const expectedBytes = Buffer.from(expected, "hex");
|
|
61328
|
-
if (suppliedBytes.length !== expectedBytes.length || !(0,
|
|
62264
|
+
if (suppliedBytes.length !== expectedBytes.length || !(0, import_node_crypto41.timingSafeEqual)(suppliedBytes, expectedBytes)) {
|
|
61329
62265
|
throw new SchedulerIntegrationAuthError("invalid_signature");
|
|
61330
62266
|
}
|
|
61331
62267
|
await claimNonce(nonce, timestampMs);
|
|
61332
62268
|
return { requestId };
|
|
61333
62269
|
}
|
|
61334
|
-
var
|
|
62270
|
+
var import_node_crypto41, MAX_CLOCK_SKEW_MS, SchedulerIntegrationAuthError;
|
|
61335
62271
|
var init_scheduler_integration_auth = __esm({
|
|
61336
62272
|
"src/api/scheduler-integration-auth.ts"() {
|
|
61337
62273
|
"use strict";
|
|
61338
|
-
|
|
62274
|
+
import_node_crypto41 = require("crypto");
|
|
61339
62275
|
init_db();
|
|
61340
62276
|
init_service_connections();
|
|
61341
62277
|
MAX_CLOCK_SKEW_MS = 5 * 60 * 1e3;
|
|
@@ -61350,42 +62286,6 @@ var init_scheduler_integration_auth = __esm({
|
|
|
61350
62286
|
}
|
|
61351
62287
|
});
|
|
61352
62288
|
|
|
61353
|
-
// src/scheduled-artifacts/scheduled-artifact-renderer-registry.ts
|
|
61354
|
-
function getScheduledArtifactRenderer(rendererKey, rendererVersion) {
|
|
61355
|
-
return scheduledArtifactRendererRegistry[`${rendererKey}:${rendererVersion}`] ?? null;
|
|
61356
|
-
}
|
|
61357
|
-
var editorialReadingRoomV1, scheduledArtifactRendererRegistry;
|
|
61358
|
-
var init_scheduled_artifact_renderer_registry = __esm({
|
|
61359
|
-
"src/scheduled-artifacts/scheduled-artifact-renderer-registry.ts"() {
|
|
61360
|
-
"use strict";
|
|
61361
|
-
init_render();
|
|
61362
|
-
init_contracts();
|
|
61363
|
-
editorialReadingRoomV1 = {
|
|
61364
|
-
rendererKey: "editorial_reading_room_v1",
|
|
61365
|
-
rendererVersion: 1,
|
|
61366
|
-
async render(rawInput, rawConfig, generatedAt) {
|
|
61367
|
-
const input = EditorialReadingRoomV1InputSchema.parse(rawInput);
|
|
61368
|
-
const config = ArtifactTemplateConfigSchema.parse(rawConfig);
|
|
61369
|
-
const rendered = renderEditorialReadingRoomV1(input, config, generatedAt);
|
|
61370
|
-
if (rendered.bytes > 2e6) {
|
|
61371
|
-
throw new Error("Scheduled artifact HTML must be 2,000,000 bytes or fewer.");
|
|
61372
|
-
}
|
|
61373
|
-
return {
|
|
61374
|
-
html: rendered.html,
|
|
61375
|
-
filename: rendered.filename,
|
|
61376
|
-
title: input.title,
|
|
61377
|
-
bytes: rendered.bytes,
|
|
61378
|
-
sha256: rendered.sha256,
|
|
61379
|
-
generatedAt: rendered.generatedAt
|
|
61380
|
-
};
|
|
61381
|
-
}
|
|
61382
|
-
};
|
|
61383
|
-
scheduledArtifactRendererRegistry = Object.freeze({
|
|
61384
|
-
"editorial_reading_room_v1:1": editorialReadingRoomV1
|
|
61385
|
-
});
|
|
61386
|
-
}
|
|
61387
|
-
});
|
|
61388
|
-
|
|
61389
62289
|
// src/api/scheduled-artifact-internal-routes.ts
|
|
61390
62290
|
function errorPayload(errorCode, error, requestId) {
|
|
61391
62291
|
return ApiErrorResponseSchema.parse({
|
|
@@ -61619,7 +62519,7 @@ var init_site_extract_reconciliation = __esm({
|
|
|
61619
62519
|
|
|
61620
62520
|
// src/api/page-diff.ts
|
|
61621
62521
|
function sha256Hex(value) {
|
|
61622
|
-
return (0,
|
|
62522
|
+
return (0, import_node_crypto42.createHash)("sha256").update(value).digest("hex");
|
|
61623
62523
|
}
|
|
61624
62524
|
function truncateForStorage(value, maxChars = MAX_SNAPSHOT_CONTENT_CHARS) {
|
|
61625
62525
|
if (value.length <= maxChars) return { value, truncated: false };
|
|
@@ -61676,11 +62576,11 @@ function diffPageContent(oldContent, newContent) {
|
|
|
61676
62576
|
totalChangedLineCount
|
|
61677
62577
|
};
|
|
61678
62578
|
}
|
|
61679
|
-
var
|
|
62579
|
+
var import_node_crypto42, import_diff, MAX_SNAPSHOT_CONTENT_CHARS, MAX_DIFF_HUNKS, MAX_DIFF_LINES_PER_RESPONSE;
|
|
61680
62580
|
var init_page_diff = __esm({
|
|
61681
62581
|
"src/api/page-diff.ts"() {
|
|
61682
62582
|
"use strict";
|
|
61683
|
-
|
|
62583
|
+
import_node_crypto42 = require("crypto");
|
|
61684
62584
|
import_diff = require("diff");
|
|
61685
62585
|
MAX_SNAPSHOT_CONTENT_CHARS = 25e4;
|
|
61686
62586
|
MAX_DIFF_HUNKS = 200;
|
|
@@ -61754,7 +62654,7 @@ var init_scrape_vault_sink = __esm({
|
|
|
61754
62654
|
|
|
61755
62655
|
// src/api/scrape-image-sink.ts
|
|
61756
62656
|
function idempotencyKey2(userId, vault, input) {
|
|
61757
|
-
return `scrape-image-${(0,
|
|
62657
|
+
return `scrape-image-${(0, import_node_crypto43.createHash)("sha256").update(`${userId}\0${vault}\0${input.sourceKind}\0${input.sourceUrl}\0${input.imageUrl ?? ""}\0${input.imageBase64 ?? ""}`).digest("hex")}`;
|
|
61758
62658
|
}
|
|
61759
62659
|
async function persistScrapeImagesToMemory(user, inputs, vault) {
|
|
61760
62660
|
const selected = inputs.slice(0, MAX_IMAGES_PER_SCRAPE);
|
|
@@ -61796,11 +62696,11 @@ async function persistScrapeImagesToMemory(user, inputs, vault) {
|
|
|
61796
62696
|
assets
|
|
61797
62697
|
};
|
|
61798
62698
|
}
|
|
61799
|
-
var
|
|
62699
|
+
var import_node_crypto43, MAX_IMAGES_PER_SCRAPE;
|
|
61800
62700
|
var init_scrape_image_sink = __esm({
|
|
61801
62701
|
"src/api/scrape-image-sink.ts"() {
|
|
61802
62702
|
"use strict";
|
|
61803
|
-
|
|
62703
|
+
import_node_crypto43 = require("crypto");
|
|
61804
62704
|
init_memory();
|
|
61805
62705
|
MAX_IMAGES_PER_SCRAPE = 25;
|
|
61806
62706
|
}
|
|
@@ -62253,7 +63153,7 @@ function canonicalJson(value) {
|
|
|
62253
63153
|
return JSON.stringify(value);
|
|
62254
63154
|
}
|
|
62255
63155
|
function sha2562(value) {
|
|
62256
|
-
return (0,
|
|
63156
|
+
return (0, import_node_crypto44.createHash)("sha256").update(value).digest("hex");
|
|
62257
63157
|
}
|
|
62258
63158
|
function sensitiveKey(key) {
|
|
62259
63159
|
const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
@@ -62468,11 +63368,11 @@ async function importServiceConnectionToMemory(identity, input, dependencies) {
|
|
|
62468
63368
|
...!searchReady ? { warning: "The snapshot was stored, but no search chunks were indexed yet." } : {}
|
|
62469
63369
|
};
|
|
62470
63370
|
}
|
|
62471
|
-
var
|
|
63371
|
+
var import_node_crypto44, CONNECTION_MEMORY_IMPORT_MAX_ARGS_BYTES, CONNECTION_MEMORY_IMPORT_MAX_RESULT_BYTES, CONNECTION_MEMORY_IMPORT_MAX_STRING_CHARS, CONNECTION_MEMORY_IMPORT_MAX_DEPTH, ConnectionMemoryImportError;
|
|
62472
63372
|
var init_connection_memory_import = __esm({
|
|
62473
63373
|
"src/api/connection-memory-import.ts"() {
|
|
62474
63374
|
"use strict";
|
|
62475
|
-
|
|
63375
|
+
import_node_crypto44 = require("crypto");
|
|
62476
63376
|
init_slugify();
|
|
62477
63377
|
CONNECTION_MEMORY_IMPORT_MAX_ARGS_BYTES = 64 * 1024;
|
|
62478
63378
|
CONNECTION_MEMORY_IMPORT_MAX_RESULT_BYTES = 1e6;
|
|
@@ -62690,7 +63590,7 @@ function finitePositive(value, fallback) {
|
|
|
62690
63590
|
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
62691
63591
|
}
|
|
62692
63592
|
async function collectConnectedDataExport(args) {
|
|
62693
|
-
const exportId = (0,
|
|
63593
|
+
const exportId = (0, import_node_crypto45.randomUUID)();
|
|
62694
63594
|
const now = args.now ?? Date.now;
|
|
62695
63595
|
const startedAt = now();
|
|
62696
63596
|
const budgetMs = finitePositive(CONNECTED_DATA_EXPORT_BUDGET_MS, 24e4);
|
|
@@ -62804,11 +63704,11 @@ ${lines.length ? `${lines.join("\n")}
|
|
|
62804
63704
|
untrustedContent: true
|
|
62805
63705
|
};
|
|
62806
63706
|
}
|
|
62807
|
-
var
|
|
63707
|
+
var import_node_crypto45, CONNECTED_DATA_INLINE_BUDGET_BYTES, CONNECTED_DATA_MAX_EXPORT_BYTES, CONNECTED_DATA_EXPORT_BUDGET_MS, CONNECTED_DATA_PAGE_START_HEADROOM_MS, CONNECTED_DATA_DATASETS, ConnectedDataExportValidationError;
|
|
62808
63708
|
var init_connected_data_export = __esm({
|
|
62809
63709
|
"src/api/connected-data-export.ts"() {
|
|
62810
63710
|
"use strict";
|
|
62811
|
-
|
|
63711
|
+
import_node_crypto45 = require("crypto");
|
|
62812
63712
|
CONNECTED_DATA_INLINE_BUDGET_BYTES = Number(
|
|
62813
63713
|
process.env.MCP_SCRAPER_CONNECTED_DATA_INLINE_BUDGET_BYTES ?? 5e4
|
|
62814
63714
|
);
|
|
@@ -62922,7 +63822,7 @@ async function exportSearchConsoleTableData(args) {
|
|
|
62922
63822
|
offset += rows.length;
|
|
62923
63823
|
if (stoppedForBytes || rows.length < limit || offset >= matchedRows) break;
|
|
62924
63824
|
}
|
|
62925
|
-
const exportId = (0,
|
|
63825
|
+
const exportId = (0, import_node_crypto46.randomUUID)();
|
|
62926
63826
|
const artifact = await args.writeArtifact({
|
|
62927
63827
|
ownerId: args.ownerId,
|
|
62928
63828
|
exportId,
|
|
@@ -62944,11 +63844,11 @@ async function exportSearchConsoleTableData(args) {
|
|
|
62944
63844
|
warnings
|
|
62945
63845
|
};
|
|
62946
63846
|
}
|
|
62947
|
-
var
|
|
63847
|
+
var import_node_crypto46, SEARCH_CONSOLE_TABLE_EXPORT_MAX_ROWS, SEARCH_CONSOLE_TABLE_EXPORT_PAGE_SIZE, SEARCH_CONSOLE_TABLE_EXPORT_MAX_BYTES, SEARCH_CONSOLE_TABLE_COLUMNS, SearchConsoleTableExportValidationError;
|
|
62948
63848
|
var init_search_console_table_export = __esm({
|
|
62949
63849
|
"src/api/search-console-table-export.ts"() {
|
|
62950
63850
|
"use strict";
|
|
62951
|
-
|
|
63851
|
+
import_node_crypto46 = require("crypto");
|
|
62952
63852
|
SEARCH_CONSOLE_TABLE_EXPORT_MAX_ROWS = 5e4;
|
|
62953
63853
|
SEARCH_CONSOLE_TABLE_EXPORT_PAGE_SIZE = 2e3;
|
|
62954
63854
|
SEARCH_CONSOLE_TABLE_EXPORT_MAX_BYTES = 50 * 1024 * 1024;
|
|
@@ -64127,7 +65027,7 @@ async function listNangoToolsDirect(identity, connectionId) {
|
|
|
64127
65027
|
});
|
|
64128
65028
|
const readTools = [...policies.values()].filter((policy5) => policy5.classification === "read").map((policy5) => policy5.name);
|
|
64129
65029
|
const actionTools = [...policies.values()].filter((policy5) => policy5.classification === "action").map((policy5) => policy5.name);
|
|
64130
|
-
const revision = (0,
|
|
65030
|
+
const revision = (0, import_node_crypto47.createHash)("sha256").update(JSON.stringify(tools.map((tool) => ({ name: tool.name, inputSchema: tool.inputSchema })))).digest("hex");
|
|
64131
65031
|
await updateServiceConnectionTools(connection.id, readTools, actionTools, revision);
|
|
64132
65032
|
const refreshed = await getOwnedServiceConnection(identity, connection.id);
|
|
64133
65033
|
return { connection: refreshed ?? { ...connection, readTools, actionTools, toolRevision: revision }, tools };
|
|
@@ -64154,8 +65054,8 @@ async function callNangoToolDirect(args) {
|
|
|
64154
65054
|
identity: args.identity,
|
|
64155
65055
|
ratePolicyVersion: CONNECTED_USAGE_RATE_POLICY_VERSION
|
|
64156
65056
|
});
|
|
64157
|
-
const requestId = args.requestId?.trim() || (0,
|
|
64158
|
-
const idempotencyKey3 = `main-nango:${(0,
|
|
65057
|
+
const requestId = args.requestId?.trim() || (0, import_node_crypto47.randomUUID)();
|
|
65058
|
+
const idempotencyKey3 = `main-nango:${(0, import_node_crypto47.createHash)("sha256").update(args.identity.toLowerCase()).update("\0").update(connection.id).update("\0").update(args.tool).update("\0").update(requestId).digest("hex")}`;
|
|
64159
65059
|
const startedAt = /* @__PURE__ */ new Date();
|
|
64160
65060
|
const started = performance.now();
|
|
64161
65061
|
let result;
|
|
@@ -64180,7 +65080,7 @@ async function callNangoToolDirect(args) {
|
|
|
64180
65080
|
toolName: args.tool,
|
|
64181
65081
|
operationKind: args.operationKind ?? args.classification,
|
|
64182
65082
|
outcome: providerError ? "error" : "partial",
|
|
64183
|
-
requestId: requestId.length <= 200 ? requestId : (0,
|
|
65083
|
+
requestId: requestId.length <= 200 ? requestId : (0, import_node_crypto47.createHash)("sha256").update(requestId).digest("hex"),
|
|
64184
65084
|
startedAt: startedAt.toISOString(),
|
|
64185
65085
|
completedAt: completedAt.toISOString()
|
|
64186
65086
|
}
|
|
@@ -64222,15 +65122,15 @@ async function describeNangoToolDirect(identity, connectionId, toolName) {
|
|
|
64222
65122
|
providerContractHash: MAIN_INTEGRATION_CONTRACT_HASH,
|
|
64223
65123
|
protocolVersion: null,
|
|
64224
65124
|
schemaSource: "live_tools_list",
|
|
64225
|
-
schemaHash: (0,
|
|
65125
|
+
schemaHash: (0, import_node_crypto47.createHash)("sha256").update(JSON.stringify(projected)).digest("hex"),
|
|
64226
65126
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
64227
65127
|
};
|
|
64228
65128
|
}
|
|
64229
|
-
var
|
|
65129
|
+
var import_node_crypto47, import_client13, DEFAULT_NANGO_MCP_URL, NANGO_TIMEOUT_MS, NANGO_CONNECTION_PAGE_SIZE, NANGO_CONNECTION_MAX_PAGES, MAIN_INTEGRATION_CONTRACT_VERSION, MAIN_INTEGRATION_CONTRACT_HASH, MainNangoTransportError;
|
|
64230
65130
|
var init_main_nango_transport = __esm({
|
|
64231
65131
|
"src/api/main-nango-transport.ts"() {
|
|
64232
65132
|
"use strict";
|
|
64233
|
-
|
|
65133
|
+
import_node_crypto47 = require("crypto");
|
|
64234
65134
|
import_client13 = require("@modelcontextprotocol/client");
|
|
64235
65135
|
init_service_connections();
|
|
64236
65136
|
init_connected_usage_billing();
|
|
@@ -64854,8 +65754,8 @@ async function setScheduleConnectionActionsEnabled(identity, connectionId, enabl
|
|
|
64854
65754
|
return data.connection.actionsEnabled === true;
|
|
64855
65755
|
}
|
|
64856
65756
|
async function callScheduleConnectionAction(identity, connectionId, input, tool, idempotencyKey3) {
|
|
64857
|
-
const requestId = `main-connected-action:${(0,
|
|
64858
|
-
const requestDigest = (0,
|
|
65757
|
+
const requestId = `main-connected-action:${(0, import_node_crypto48.createHash)("sha256").update(identity).update("\0").update(idempotencyKey3?.trim() || (0, import_node_crypto48.randomUUID)()).digest("hex")}`;
|
|
65758
|
+
const requestDigest = (0, import_node_crypto48.createHash)("sha256").update(connectionId).update("\0").update(tool?.trim() ?? "").update("\0").update(canonicalJson2(input)).digest("hex");
|
|
64859
65759
|
if (mainOwnsIntegrations()) {
|
|
64860
65760
|
const selectedTool = tool?.trim();
|
|
64861
65761
|
if (!selectedTool) throw new NangoControlError("An action tool is required.", 400, "invalid_request", false);
|
|
@@ -65006,7 +65906,7 @@ function canonicalJson2(value) {
|
|
|
65006
65906
|
return JSON.stringify(value);
|
|
65007
65907
|
}
|
|
65008
65908
|
function projectedToolSchemaHash(tool) {
|
|
65009
|
-
return (0,
|
|
65909
|
+
return (0, import_node_crypto48.createHash)("sha256").update(canonicalJson2(tool)).digest("hex");
|
|
65010
65910
|
}
|
|
65011
65911
|
async function describeNangoTool(identity, connectionId, tool, fresh) {
|
|
65012
65912
|
if (mainOwnsIntegrations()) {
|
|
@@ -65283,11 +66183,11 @@ async function callMainOwnedExportPage(identity, input) {
|
|
|
65283
66183
|
untrustedContent: true
|
|
65284
66184
|
};
|
|
65285
66185
|
}
|
|
65286
|
-
var
|
|
66186
|
+
var import_node_crypto48, DEFAULT_NANGO_CONTROL_URL, DISABLED_NANGO_TOOLS, CONNECTION_SYNC_REQUIRED_TOOLS, CONNECTION_SYNC_OPTIONAL_TOOLS, NangoControlError, ScheduleConnectionValidationError, SAFE_CONTROL_ERROR_CODES, FIXED_CONTROL_ERROR_MESSAGES, CONTROL_ERROR_CODE_ALIASES;
|
|
65287
66187
|
var init_nango_control = __esm({
|
|
65288
66188
|
"src/api/nango-control.ts"() {
|
|
65289
66189
|
"use strict";
|
|
65290
|
-
|
|
66190
|
+
import_node_crypto48 = require("crypto");
|
|
65291
66191
|
init_connected_data_export();
|
|
65292
66192
|
init_slack_connected_data_export();
|
|
65293
66193
|
init_main_nango_transport();
|
|
@@ -65643,7 +66543,7 @@ async function callResendRead(identity, connectionId, tool, args) {
|
|
|
65643
66543
|
return isRecord5(data) ? data.result ?? data : data;
|
|
65644
66544
|
}
|
|
65645
66545
|
async function callResendAction(identity, connectionId, tool, input, idempotencyKey3) {
|
|
65646
|
-
const requestId = `main-resend-action:${(0,
|
|
66546
|
+
const requestId = `main-resend-action:${(0, import_node_crypto49.createHash)("sha256").update(identity).update("\0").update(idempotencyKey3.trim()).digest("hex")}`;
|
|
65647
66547
|
const body = await controlRequest2("/api/internal/resend/actions/call", {
|
|
65648
66548
|
method: "POST",
|
|
65649
66549
|
headers: { "x-request-id": requestId },
|
|
@@ -65708,12 +66608,12 @@ async function callResendExportPage(identity, input) {
|
|
|
65708
66608
|
untrustedContent: true
|
|
65709
66609
|
};
|
|
65710
66610
|
}
|
|
65711
|
-
var
|
|
66611
|
+
var import_node_crypto49, DEFAULT_CONNECTION_CONTROL_URL, RESEND_PROVIDER_CONFIG_KEY, RESEND_LOGO_URL, RESEND_DOCS_URL, RESEND_ADMIN_BLOCKED_TOOLS, RESEND_CONNECTION_SYNC_REQUIRED_TOOLS, ResendControlError;
|
|
65712
66612
|
var init_resend_control = __esm({
|
|
65713
66613
|
"src/api/resend-control.ts"() {
|
|
65714
66614
|
"use strict";
|
|
65715
66615
|
init_connected_data_export();
|
|
65716
|
-
|
|
66616
|
+
import_node_crypto49 = require("crypto");
|
|
65717
66617
|
DEFAULT_CONNECTION_CONTROL_URL = "https://mcp-scraper-scheduler.vercel.app";
|
|
65718
66618
|
RESEND_PROVIDER_CONFIG_KEY = "resend";
|
|
65719
66619
|
RESEND_LOGO_URL = "https://cdn.resend.com/brand/resend-icon-black.svg";
|
|
@@ -66231,7 +67131,7 @@ async function chargeTierChangeNow(stripeClient, subscriptionId, customerId) {
|
|
|
66231
67131
|
return { ok: false, amountDue: 0, error: err instanceof Error ? err.message : "Unable to charge the plan change immediately." };
|
|
66232
67132
|
}
|
|
66233
67133
|
}
|
|
66234
|
-
var import_resend3,
|
|
67134
|
+
var import_resend3, import_node_crypto50, import_hono35, import_hono36, import_factory7, import_cookie2, import_stripe2, secureCookies2, isProduction2, sessionCookieOptions2, requireAllowedOrigin, auth3, sessionAuth, requireIntegrationsTier, requirePaidSchedulingTier, app, deploymentProfile, STRIPE_API_VERSION, SYNC_HARVEST_TIMEOUT_OVERRIDE_MS;
|
|
66235
67135
|
var init_server = __esm({
|
|
66236
67136
|
"src/api/server.ts"() {
|
|
66237
67137
|
"use strict";
|
|
@@ -66244,7 +67144,7 @@ var init_server = __esm({
|
|
|
66244
67144
|
init_og();
|
|
66245
67145
|
import_resend3 = require("resend");
|
|
66246
67146
|
init_url_utils();
|
|
66247
|
-
|
|
67147
|
+
import_node_crypto50 = require("crypto");
|
|
66248
67148
|
init_kpo_extractor();
|
|
66249
67149
|
init_screenshot();
|
|
66250
67150
|
init_media_extractor();
|
|
@@ -67518,12 +68418,12 @@ var init_server = __esm({
|
|
|
67518
68418
|
const r = await memoryCall("listScheduledActionsTool", {}, key);
|
|
67519
68419
|
if (!r.ok || !Array.isArray(r.actions)) return c.json(r);
|
|
67520
68420
|
try {
|
|
67521
|
-
const actions = await Promise.all(r.actions.map(async (
|
|
67522
|
-
const id = typeof
|
|
67523
|
-
const executionMode =
|
|
67524
|
-
if (!id) return { ...
|
|
68421
|
+
const actions = await Promise.all(r.actions.map(async (action2) => {
|
|
68422
|
+
const id = typeof action2.id === "string" ? action2.id : "";
|
|
68423
|
+
const executionMode = action2.executionMode === "connection_sync" ? "connection_sync" : "agent";
|
|
68424
|
+
if (!id) return { ...action2, executionMode, connections: [] };
|
|
67525
68425
|
const bindings = await getScheduleConnectionBindings(user.email, id);
|
|
67526
|
-
return { ...
|
|
68426
|
+
return { ...action2, executionMode, connections: bindingsForSchedule(bindings, id) };
|
|
67527
68427
|
}));
|
|
67528
68428
|
return c.json({
|
|
67529
68429
|
...r,
|
|
@@ -67533,7 +68433,7 @@ var init_server = __esm({
|
|
|
67533
68433
|
console.warn("[schedule-actions] connection bindings unavailable:", err instanceof Error ? err.message : String(err));
|
|
67534
68434
|
return c.json({
|
|
67535
68435
|
...r,
|
|
67536
|
-
actions: r.actions.map((
|
|
68436
|
+
actions: r.actions.map((action2) => ({ ...action2, executionMode: action2.executionMode === "connection_sync" ? "connection_sync" : "agent", connections: [] })),
|
|
67537
68437
|
connectionBindingsUnavailable: true
|
|
67538
68438
|
});
|
|
67539
68439
|
}
|
|
@@ -67616,7 +68516,7 @@ var init_server = __esm({
|
|
|
67616
68516
|
if (!key) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
67617
68517
|
const schedules = await memoryCall("listScheduledActionsTool", {}, key);
|
|
67618
68518
|
if (!schedules.ok || !Array.isArray(schedules.actions)) return c.json(schedules, 502);
|
|
67619
|
-
const schedule = schedules.actions.find((
|
|
68519
|
+
const schedule = schedules.actions.find((action2) => action2.id === scheduleActionId);
|
|
67620
68520
|
if (!schedule) return c.json({ ok: false, error: "scheduled action not found" }, 404);
|
|
67621
68521
|
if (schedule.executionMode === "connection_sync") {
|
|
67622
68522
|
const policyError = connectionSyncSelectionError(connections);
|
|
@@ -67776,7 +68676,7 @@ var init_server = __esm({
|
|
|
67776
68676
|
if (!harvestOk) return c.json(insufficientBalanceResponse(harvestBal, harvestCost), 402);
|
|
67777
68677
|
jobId2 = await createJob(user.id, options.query, { ...options, billingHoldMc: harvestCost }, body.callback_url);
|
|
67778
68678
|
} else {
|
|
67779
|
-
jobId2 = (0,
|
|
68679
|
+
jobId2 = (0, import_node_crypto50.randomUUID)();
|
|
67780
68680
|
const billingDebitKey = `paa-harvest:${jobId2}:hold`;
|
|
67781
68681
|
const description = `PAA harvest: ${options.query}`.slice(0, 500);
|
|
67782
68682
|
const hold = await debitMcIdempotent(
|