@farming-labs/svelte 0.2.60 → 0.2.62
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/dist/server.js +55 -3
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
import fs from "node:fs";
|
|
31
31
|
import path from "node:path";
|
|
32
32
|
import matter from "gray-matter";
|
|
33
|
-
import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsAgentDiscoverySpec, buildDocsConfigMap, buildDocsDiagnostics, createDocsStandardsDiscoveryResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue, getDocsDiscoveryLinkHeader, isDocsAgentDiscoveryRequest, isDocsAgentsRequest, isDocsConfigRequest, isDocsDiagnosticsRequest, isDocsSkillRequest, isDocsStandardsDiscoveryRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, parseDocsAgentFeedbackData, performDocsSearch, renderDocsMarkdownDocument, renderDocsLlmsTxt, renderDocsAgentsDocument, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAudienceMdxContent, resolveDocsAgentFeedbackConfig, resolveDocsAgentFeedbackRequest, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsRequestApiRoute, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsAgentsFormat, resolveDocsSkillFormat, inferDocsTelemetryAgentSurface, renderDocsPageStructuredDataJson, selectDocsLlmsTxtContent, validateDocsAgentFeedbackPayload, } from "@farming-labs/docs";
|
|
34
|
-
import { buildApiReferenceOpenApiDocumentAsync, createDocsCloudAskAIResponse, createDocsMcpHttpHandler, isDocsCloudAskAIProvider, readDocsSitemapManifest, resolveApiReferenceConfig, resolveDocsMcpConfig, serializeDocsIconRegistry, serializeOpenDocsProviders, } from "@farming-labs/docs/server";
|
|
33
|
+
import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsAgentDiscoverySpec, buildDocsConfigMap, buildDocsDiagnostics, createDocsStandardsDiscoveryResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue, getDocsDiscoveryLinkHeader, isDocsAgentDiscoveryRequest, isDocsAgentsRequest, isDocsConfigRequest, isDocsDiagnosticsRequest, isDocsSkillRequest, isDocsStandardsDiscoveryRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, parseDocsAgentFeedbackData, performDocsSearch, renderDocsMarkdownDocument, renderDocsLlmsTxt, renderDocsAgentsDocument, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAudienceMdxContent, resolveDocsAgentFeedbackConfig, resolveDocsAgentFeedbackRequest, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveDocsSearchAudience, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsRequestApiRoute, resolveDocsPublishedAgentSkill, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsAgentsFormat, resolveDocsSkillFormat, inferDocsTelemetryAgentSurface, renderDocsPageStructuredDataJson, selectDocsLlmsTxtContent, validateDocsAgentFeedbackPayload, } from "@farming-labs/docs";
|
|
34
|
+
import { buildApiReferenceOpenApiDocumentAsync, createDocsCloudAskAIResponse, createDocsMcpHttpHandler, isDocsCloudAskAIProvider, readDocsSitemapManifest, resolveApiReferenceConfig, resolveDocsMcpConfig, resolveConfiguredAgentSkills, serializeDocsIconRegistry, serializeOpenDocsProviders, } from "@farming-labs/docs/server";
|
|
35
35
|
import { loadDocsNavTree, loadDocsContent, flattenNavTree } from "./content.js";
|
|
36
36
|
import { renderMarkdown } from "./markdown.js";
|
|
37
37
|
export { createSvelteApiReference } from "./api-reference.js";
|
|
@@ -405,6 +405,9 @@ export function createDocsServer(config = {}) {
|
|
|
405
405
|
const observability = config.observability;
|
|
406
406
|
const contentDirBase = config.contentDir ?? entry;
|
|
407
407
|
const rootDir = path.resolve(config.rootDir ?? process.cwd());
|
|
408
|
+
const publishedAgentSkills = Array.isArray(config._preloadedAgentSkills)
|
|
409
|
+
? Promise.resolve(config._preloadedAgentSkills)
|
|
410
|
+
: resolveConfiguredAgentSkills(config.agent?.skills, { rootDir });
|
|
408
411
|
const i18n = resolveDocsI18n(config.i18n);
|
|
409
412
|
const githubRaw = config.github;
|
|
410
413
|
const github = typeof githubRaw === "string" ? { url: githubRaw } : (githubRaw ?? null);
|
|
@@ -646,6 +649,7 @@ export function createDocsServer(config = {}) {
|
|
|
646
649
|
: undefined;
|
|
647
650
|
const discoveryLinkHeader = getDocsDiscoveryLinkHeader({
|
|
648
651
|
includeApiCatalog: apiCatalogEnabled,
|
|
652
|
+
includeAgentCard: Boolean(config.agent?.a2a),
|
|
649
653
|
});
|
|
650
654
|
const openapiDiscovery = resolveApiReferenceOpenApiDiscovery(config.apiReference);
|
|
651
655
|
const mcpConfig = resolveDocsMcpConfig(config.mcp, {
|
|
@@ -773,12 +777,24 @@ export function createDocsServer(config = {}) {
|
|
|
773
777
|
...discoveryOptions,
|
|
774
778
|
preferredSkillDocument: readRootSkillDocument(preloaded, rootDir),
|
|
775
779
|
fallbackSkillDocument: renderDocsSkillDocument(discoveryOptions),
|
|
780
|
+
publishedSkills: await publishedAgentSkills,
|
|
781
|
+
agentCard: config.agent?.a2a,
|
|
776
782
|
});
|
|
777
783
|
if (standardsDiscoveryResponse)
|
|
778
784
|
return standardsDiscoveryResponse;
|
|
779
785
|
}
|
|
780
786
|
if (isDocsAgentDiscoveryRequest(event.url, { apiRoute: discoveryApiRoute })) {
|
|
781
|
-
return new Response(JSON.stringify(buildDocsAgentDiscoverySpec(
|
|
787
|
+
return new Response(JSON.stringify(buildDocsAgentDiscoverySpec({
|
|
788
|
+
...discoveryOptions,
|
|
789
|
+
publishedSkills: [
|
|
790
|
+
await resolveDocsPublishedAgentSkill({
|
|
791
|
+
preferredDocument: readRootSkillDocument(preloaded, rootDir),
|
|
792
|
+
fallbackDocument: renderDocsSkillDocument(discoveryOptions),
|
|
793
|
+
}),
|
|
794
|
+
...(await publishedAgentSkills),
|
|
795
|
+
],
|
|
796
|
+
agentCard: config.agent?.a2a,
|
|
797
|
+
}), null, 2), {
|
|
782
798
|
headers: {
|
|
783
799
|
"Content-Type": "application/json; charset=utf-8",
|
|
784
800
|
"Cache-Control": "public, max-age=0, s-maxage=3600",
|
|
@@ -864,6 +880,7 @@ export function createDocsServer(config = {}) {
|
|
|
864
880
|
if (sitemapResponse)
|
|
865
881
|
return sitemapResponse;
|
|
866
882
|
const robotsResponse = createDocsRobotsResponse({
|
|
883
|
+
agentCard: Boolean(config.agent?.a2a),
|
|
867
884
|
request: event.request,
|
|
868
885
|
entry,
|
|
869
886
|
apiCatalog: apiCatalogEnabled,
|
|
@@ -942,13 +959,16 @@ export function createDocsServer(config = {}) {
|
|
|
942
959
|
});
|
|
943
960
|
}
|
|
944
961
|
const searchStartedAt = Date.now();
|
|
962
|
+
const audience = resolveDocsSearchAudience(event.url.searchParams.get("audience"));
|
|
945
963
|
const results = await performDocsSearch({
|
|
946
964
|
pages: getSearchIndex(ctx),
|
|
947
965
|
query,
|
|
948
966
|
search: resolveSearchRequestConfig(config.search, event.request.url),
|
|
967
|
+
audience,
|
|
949
968
|
locale: ctx.locale,
|
|
950
969
|
pathname: event.url.searchParams.get("pathname") ?? undefined,
|
|
951
970
|
siteTitle: llmsTitle,
|
|
971
|
+
baseUrl: markdownMetadataBaseUrl || event.url.origin,
|
|
952
972
|
});
|
|
953
973
|
await emitDocsAnalyticsEvent(analytics, {
|
|
954
974
|
type: "api_search",
|
|
@@ -959,6 +979,7 @@ export function createDocsServer(config = {}) {
|
|
|
959
979
|
input: { query },
|
|
960
980
|
properties: {
|
|
961
981
|
queryLength: query.length,
|
|
982
|
+
audience,
|
|
962
983
|
resultCount: results.length,
|
|
963
984
|
pathname: event.url.searchParams.get("pathname") ?? undefined,
|
|
964
985
|
durationMs: Math.max(0, Date.now() - searchStartedAt),
|
|
@@ -1516,6 +1537,37 @@ export function createDocsServer(config = {}) {
|
|
|
1516
1537
|
defaultBehavior: "toggle",
|
|
1517
1538
|
});
|
|
1518
1539
|
},
|
|
1540
|
+
async getSkills(context) {
|
|
1541
|
+
const origin = context?.request
|
|
1542
|
+
? new URL(context.request.url).origin
|
|
1543
|
+
: llmsBaseUrl || "http://localhost";
|
|
1544
|
+
const skillOptions = {
|
|
1545
|
+
origin,
|
|
1546
|
+
entry,
|
|
1547
|
+
apiRoute: configuredApiRoute,
|
|
1548
|
+
docsPath: config.docsPath,
|
|
1549
|
+
apiCatalog: apiCatalogEnabled,
|
|
1550
|
+
i18n,
|
|
1551
|
+
search: config.search,
|
|
1552
|
+
mcp: mcpConfig,
|
|
1553
|
+
feedback: agentFeedbackDiscovery,
|
|
1554
|
+
llms: {
|
|
1555
|
+
enabled: llmsEnabled,
|
|
1556
|
+
apiCatalog: apiCatalogEnabled,
|
|
1557
|
+
baseUrl: llmsBaseUrl || undefined,
|
|
1558
|
+
siteTitle: llmsTitle,
|
|
1559
|
+
siteDescription: llmsDesc,
|
|
1560
|
+
},
|
|
1561
|
+
sitemap: config.sitemap,
|
|
1562
|
+
robots: config.robots,
|
|
1563
|
+
openapi: openapiDiscovery,
|
|
1564
|
+
};
|
|
1565
|
+
const rootSkill = await resolveDocsPublishedAgentSkill({
|
|
1566
|
+
preferredDocument: readRootSkillDocument(preloaded, rootDir),
|
|
1567
|
+
fallbackDocument: renderDocsSkillDocument(skillOptions),
|
|
1568
|
+
});
|
|
1569
|
+
return [rootSkill, ...(await publishedAgentSkills)];
|
|
1570
|
+
},
|
|
1519
1571
|
},
|
|
1520
1572
|
mcp: config.mcp,
|
|
1521
1573
|
analytics,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.62",
|
|
4
4
|
"description": "SvelteKit adapter for @farming-labs/docs — content loading and navigation utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^22.10.0",
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
|
-
"@farming-labs/docs": "0.2.
|
|
59
|
+
"@farming-labs/docs": "0.2.62"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@farming-labs/docs": "*"
|