@nextblock-cms/cortex 0.15.10 → 0.16.1
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/index.cjs.js +1 -1
- package/index.d.ts +2 -0
- package/index.es.js +153 -139
- package/lib/ai-client.cjs.js +1 -1
- package/lib/ai-client.es.js +20 -18
- package/lib/ai-seo-metadata.cjs.js +4 -0
- package/lib/ai-seo-metadata.d.ts +127 -0
- package/lib/ai-seo-metadata.es.js +193 -0
- package/lib/ai-vision.cjs.js +3 -0
- package/lib/ai-vision.d.ts +133 -0
- package/lib/ai-vision.es.js +227 -0
- package/package.json +4 -4
package/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./lib/ai-block-generation.cjs.js"),E=require("./lib/ai-client.cjs.js"),t=require("./lib/ai-config.cjs.js"),S=require("./lib/ai-cortex-widget-builder.cjs.js"),n=require("./lib/ai-global-agent-custom-block-tools.cjs.js"),C=require("./lib/ai-global-agent-db-tools.cjs.js"),e=require("./lib/ai-global-agent-tools.cjs.js"),u=require("./lib/ai-key-crypto.cjs.js"),l=require("./lib/ai-model-catalog.cjs.js"),o=require("./lib/ai-model-registry.cjs.js"),s=require("./lib/cortex-widget-registry.cjs.js"),i=require("./lib/cortex-widget-schema.cjs.js"),r=require("./lib/mcp-server.cjs.js"),a=require("./lib/mcp-tokens.cjs.js"),c=require("./lib/mcp-tool-registry.cjs.js");require("./lib/zod-config.cjs.js");const R=require("zod");exports.INLINE_HTML_ASSISTANT_SYSTEM_PROMPT=_.INLINE_HTML_ASSISTANT_SYSTEM_PROMPT;exports.generateEditorBlocksRequestSchema=_.generateEditorBlocksRequestSchema;exports.generateEditorHtmlFragment=_.generateEditorHtmlFragment;exports.validateGeneratedEditorHtmlFragment=_.validateGeneratedEditorHtmlFragment;exports.createCortexAiOpenRouterClient=E.createCortexAiOpenRouterClient;exports.createCortexAiOpenRouterProvider=E.createCortexAiOpenRouterProvider;exports.generateCortexAiText=E.generateCortexAiText;exports.getStoredCortexAiModelSelection=E.getStoredCortexAiModelSelection;exports.resolveCortexAiOpenRouterCredential=E.resolveCortexAiOpenRouterCredential;exports.CORTEX_AI_AGENT_SETTINGS_BOUNDS=t.CORTEX_AI_AGENT_SETTINGS_BOUNDS;exports.CORTEX_AI_AGENT_SETTINGS_DEFAULTS=t.CORTEX_AI_AGENT_SETTINGS_DEFAULTS;exports.CORTEX_AI_AGENT_SETTINGS_KEY=t.CORTEX_AI_AGENT_SETTINGS_KEY;exports.CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY=t.CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY;exports.CORTEX_AI_OPENROUTER_SETTING_KEY=t.CORTEX_AI_OPENROUTER_SETTING_KEY;exports.CORTEX_AI_PACKAGE_ID=t.CORTEX_AI_PACKAGE_ID;exports.CORTEX_AI_PACKAGE_NAME=t.CORTEX_AI_PACKAGE_NAME;exports.CORTEX_AI_PEXELS_SETTING_KEY=t.CORTEX_AI_PEXELS_SETTING_KEY;exports.CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY=t.CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY;exports.CORTEX_AI_UNSPLASH_SETTING_KEY=t.CORTEX_AI_UNSPLASH_SETTING_KEY;exports.decryptStoredOpenRouterApiKey=t.decryptStoredOpenRouterApiKey;exports.encryptStoredOpenRouterApiKey=t.encryptStoredOpenRouterApiKey;exports.getCortexAiEnvConfig=t.getCortexAiEnvConfig;exports.getEnvOpenRouterKeyStatus=t.getEnvOpenRouterKeyStatus;exports.getOpenRouterEnvApiKey=t.getOpenRouterEnvApiKey;exports.getPexelsEnvApiKey=t.getPexelsEnvApiKey;exports.getStoredOpenRouterKeyStatus=t.getStoredOpenRouterKeyStatus;exports.getUnsplashEnvApiKey=t.getUnsplashEnvApiKey;exports.normalizeCortexAiAgentSettings=t.normalizeCortexAiAgentSettings;exports.resolveCortexAiAgentSettings=t.resolveCortexAiAgentSettings;exports.generateCortexWidgetDefinition=S.generateCortexWidgetDefinition;exports.createCortexCustomBlockTools=n.createCortexCustomBlockTools;exports.createCustomBlockInputSchema=n.createCustomBlockInputSchema;exports.deleteCustomBlockInputSchema=n.deleteCustomBlockInputSchema;exports.executeCreateCustomBlock=n.executeCreateCustomBlock;exports.executeDeleteCustomBlock=n.executeDeleteCustomBlock;exports.executeListCustomBlocks=n.executeListCustomBlocks;exports.executeUpdateCustomBlock=n.executeUpdateCustomBlock;exports.listCustomBlocksInputSchema=n.listCustomBlocksInputSchema;exports.updateCustomBlockInputSchema=n.updateCustomBlockInputSchema;exports.createCortexDatabaseAgentTools=C.createCortexDatabaseAgentTools;exports.describeDatabaseSchemaInputSchema=C.describeDatabaseSchemaInputSchema;exports.executeDatabaseActionPlan=C.executeDatabaseActionPlan;exports.executeDatabaseActionPlanInputSchema=C.executeDatabaseActionPlanInputSchema;exports.executeDatabaseMutation=C.executeDatabaseMutation;exports.executeDatabaseMutationInputSchema=C.executeDatabaseMutationInputSchema;exports.executeDescribeDatabaseSchema=C.executeDescribeDatabaseSchema;exports.executeReadDatabaseRecords=C.executeReadDatabaseRecords;exports.readDatabaseRecordsInputSchema=C.readDatabaseRecordsInputSchema;exports.availableCortexAiBlockTypes=e.availableCortexAiBlockTypes;exports.buildVisibleContactIntroActionPlan=e.buildVisibleContactIntroActionPlan;exports.cortexAiPageContextSchema=e.cortexAiPageContextSchema;exports.createCmsPageInputSchema=e.createCmsPageInputSchema;exports.createCmsPostInputSchema=e.createCmsPostInputSchema;exports.createCmsProductInputSchema=e.createCmsProductInputSchema;exports.createCortexGlobalAgentTools=e.createCortexGlobalAgentTools;exports.deleteCmsItemInputSchema=e.deleteCmsItemInputSchema;exports.executeCmsActionPlan=e.executeCmsActionPlan;exports.executeCmsActionPlanInputSchema=e.executeCmsActionPlanInputSchema;exports.executeCreateCmsPage=e.executeCreateCmsPage;exports.executeCreateCmsPost=e.executeCreateCmsPost;exports.executeCreateCmsProduct=e.executeCreateCmsProduct;exports.executeDeleteCmsItem=e.executeDeleteCmsItem;exports.executeFetchEcommerceStats=e.executeFetchEcommerceStats;exports.executeFetchUrlContent=e.executeFetchUrlContent;exports.executeInsertContentBlock=e.executeInsertContentBlock;exports.executeManageProductVariants=e.executeManageProductVariants;exports.executePrepareDeleteCmsItem=e.executePrepareDeleteCmsItem;exports.executePublishContentDraft=e.executePublishContentDraft;exports.executeReadCurrentCmsItem=e.executeReadCurrentCmsItem;exports.executeRewritePageDraft=e.executeRewritePageDraft;exports.executeSearchDocumentation=e.executeSearchDocumentation;exports.executeSearchDocumentationWithTimeout=e.executeSearchDocumentationWithTimeout;exports.executeSearchStockPhotos=e.executeSearchStockPhotos;exports.executeSetContentImages=e.executeSetContentImages;exports.executeTranslateContentBulk=e.executeTranslateContentBulk;exports.executeTranslatePage=e.executeTranslatePage;exports.executeUpdateCmsItemField=e.executeUpdateCmsItemField;exports.executeUpdateContentBlock=e.executeUpdateContentBlock;exports.executeUpdateCurrentCmsFields=e.executeUpdateCurrentCmsFields;exports.executeUpdateFooter=e.executeUpdateFooter;exports.executeUpdateNavigationBar=e.executeUpdateNavigationBar;exports.executeUpdateSectionColumnBlock=e.executeUpdateSectionColumnBlock;exports.fetchEcommerceStatsInputSchema=e.fetchEcommerceStatsInputSchema;exports.fetchUrlContentInputSchema=e.fetchUrlContentInputSchema;exports.insertContentBlockInputSchema=e.insertContentBlockInputSchema;exports.isBlockedFetchHost=e.isBlockedFetchHost;exports.manageProductVariantsInputSchema=e.manageProductVariantsInputSchema;exports.maybeTriggerStockPhotoDownloads=e.maybeTriggerStockPhotoDownloads;exports.navigationItemInputSchema=e.navigationItemInputSchema;exports.prepareDeleteCmsItemInputSchema=e.prepareDeleteCmsItemInputSchema;exports.publishContentDraftInputSchema=e.publishContentDraftInputSchema;exports.readCurrentCmsItemInputSchema=e.readCurrentCmsItemInputSchema;exports.resolveCortexAiStockPhotoProvider=e.resolveCortexAiStockPhotoProvider;exports.resolveCortexAiStockPhotoProviders=e.resolveCortexAiStockPhotoProviders;exports.rewritePageDraftInputSchema=e.rewritePageDraftInputSchema;exports.searchDocumentationInputSchema=e.searchDocumentationInputSchema;exports.searchStockPhotosInputSchema=e.searchStockPhotosInputSchema;exports.setContentImagesInputSchema=e.setContentImagesInputSchema;exports.translateContentBulkInputSchema=e.translateContentBulkInputSchema;exports.translatePageInputSchema=e.translatePageInputSchema;exports.updateCmsItemFieldInputSchema=e.updateCmsItemFieldInputSchema;exports.updateContentBlockInputSchema=e.updateContentBlockInputSchema;exports.updateCurrentCmsFieldsInputSchema=e.updateCurrentCmsFieldsInputSchema;exports.updateFooterInputSchema=e.updateFooterInputSchema;exports.updateNavigationBarInputSchema=e.updateNavigationBarInputSchema;exports.updateSectionColumnBlockInputSchema=e.updateSectionColumnBlockInputSchema;exports.CORTEX_AI_KEY_ALGORITHM=u.CORTEX_AI_KEY_ALGORITHM;exports.CORTEX_AI_KEY_ENVELOPE_VERSION=u.CORTEX_AI_KEY_ENVELOPE_VERSION;exports.decryptOpenRouterApiKey=u.decryptOpenRouterApiKey;exports.encryptOpenRouterApiKey=u.encryptOpenRouterApiKey;exports.getMaskedOpenRouterKey=u.getMaskedOpenRouterKey;exports.getOpenRouterKeyEnvelopeStatus=u.getOpenRouterKeyEnvelopeStatus;exports.listCortexAiCompatibleOpenRouterModels=l.listCortexAiCompatibleOpenRouterModels;exports.CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY=o.CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY;exports.CORTEX_AI_MODEL_REGISTRY=o.CORTEX_AI_MODEL_REGISTRY;exports.CORTEX_AI_OPENROUTER_BASE_URL=o.CORTEX_AI_OPENROUTER_BASE_URL;exports.CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL=o.CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL;exports.CORTEX_AI_REQUIRED_MODEL_PARAMETERS=o.CORTEX_AI_REQUIRED_MODEL_PARAMETERS;exports.CortexAiRoutingError=o.CortexAiRoutingError;exports.buildCortexAiModelFallbackChain=o.buildCortexAiModelFallbackChain;exports.buildCortexAiRoutingPolicy=o.buildCortexAiRoutingPolicy;exports.createCortexAiStoredModelSelection=o.createCortexAiStoredModelSelection;exports.filterCortexAiCompatibleOpenRouterModels=o.filterCortexAiCompatibleOpenRouterModels;exports.getHttpStatusCode=o.getHttpStatusCode;exports.isCortexAiFreeModelId=o.isCortexAiFreeModelId;exports.isOpenRouterRateLimitError=o.isOpenRouterRateLimitError;exports.isOpenRouterRecoverableRoutingError=o.isOpenRouterRecoverableRoutingError;exports.omitUnsupportedCortexAiModelOptions=o.omitUnsupportedCortexAiModelOptions;exports.runWithCortexAiModelFallback=o.runWithCortexAiModelFallback;exports.safeParseCortexAiModelSelection=o.safeParseCortexAiModelSelection;exports.summarizeCortexAiRoutingError=o.summarizeCortexAiRoutingError;exports.CORTEX_WIDGET_DEFINITION_SELECT=s.CORTEX_WIDGET_DEFINITION_SELECT;exports.CortexWidgetRegistryInsertError=s.CortexWidgetRegistryInsertError;exports.buildCortexWidgetDefinitionInsertPayload=s.buildCortexWidgetDefinitionInsertPayload;exports.insertCortexWidgetDefinition=s.insertCortexWidgetDefinition;exports.CORTEX_WIDGET_ALLOWED_RELATION_TABLES=i.CORTEX_WIDGET_ALLOWED_RELATION_TABLES;exports.buildCortexProfileCardVerificationDefinition=i.buildCortexProfileCardVerificationDefinition;exports.buildCortexWidgetBuilderPrompt=i.buildCortexWidgetBuilderPrompt;exports.buildCortexWidgetBuilderSystemPrompt=i.buildCortexWidgetBuilderSystemPrompt;exports.cortexWidgetBuildRequestSchema=i.cortexWidgetBuildRequestSchema;exports.cortexWidgetDbRelationFieldSchema=i.cortexWidgetDbRelationFieldSchema;exports.cortexWidgetDefinitionSchema=i.cortexWidgetDefinitionSchema;exports.cortexWidgetFieldSchema=i.cortexWidgetFieldSchema;exports.cortexWidgetImageR2FieldSchema=i.cortexWidgetImageR2FieldSchema;exports.cortexWidgetLayoutNodeSchema=i.cortexWidgetLayoutNodeSchema;exports.cortexWidgetRichTextFieldSchema=i.cortexWidgetRichTextFieldSchema;exports.cortexWidgetTextFieldSchema=i.cortexWidgetTextFieldSchema;exports.validateCortexWidgetDefinitionOutput=i.validateCortexWidgetDefinitionOutput;exports.CORTEX_MCP_DEFAULT_PROTOCOL_VERSION=r.CORTEX_MCP_DEFAULT_PROTOCOL_VERSION;exports.CORTEX_MCP_LATEST_LEGACY_PROTOCOL_VERSION=r.CORTEX_MCP_LATEST_LEGACY_PROTOCOL_VERSION;exports.CORTEX_MCP_MODERN_PROTOCOL_VERSION=r.CORTEX_MCP_MODERN_PROTOCOL_VERSION;exports.CORTEX_MCP_SERVER_NAME=r.CORTEX_MCP_SERVER_NAME;exports.CORTEX_MCP_SERVER_TITLE=r.CORTEX_MCP_SERVER_TITLE;exports.CORTEX_MCP_SUPPORTED_PROTOCOL_VERSIONS=r.CORTEX_MCP_SUPPORTED_PROTOCOL_VERSIONS;exports.JSON_RPC_INTERNAL_ERROR=r.JSON_RPC_INTERNAL_ERROR;exports.JSON_RPC_INVALID_PARAMS=r.JSON_RPC_INVALID_PARAMS;exports.JSON_RPC_INVALID_REQUEST=r.JSON_RPC_INVALID_REQUEST;exports.JSON_RPC_METHOD_NOT_FOUND=r.JSON_RPC_METHOD_NOT_FOUND;exports.JSON_RPC_PARSE_ERROR=r.JSON_RPC_PARSE_ERROR;exports.handleCortexMcpMessage=r.handleCortexMcpMessage;exports.isJsonRpcNotification=r.isJsonRpcNotification;exports.isModernEraMessage=r.isModernEraMessage;exports.CORTEX_AI_MCP_SCOPES=a.CORTEX_AI_MCP_SCOPES;exports.CORTEX_AI_MCP_SETTINGS_DEFAULTS=a.CORTEX_AI_MCP_SETTINGS_DEFAULTS;exports.CORTEX_AI_MCP_SETTINGS_KEY=a.CORTEX_AI_MCP_SETTINGS_KEY;exports.CORTEX_AI_MCP_TOKENS_TABLE=a.CORTEX_AI_MCP_TOKENS_TABLE;exports.CORTEX_AI_MCP_TOKEN_PREFIX=a.CORTEX_AI_MCP_TOKEN_PREFIX;exports.hashCortexAiMcpToken=a.hashCortexAiMcpToken;exports.isLocalhostHost=a.isLocalhostHost;exports.mintCortexAiMcpToken=a.mintCortexAiMcpToken;exports.normalizeCortexAiMcpSettings=a.normalizeCortexAiMcpSettings;exports.parseBearerToken=a.parseBearerToken;exports.resolveCortexAiMcpSettings=a.resolveCortexAiMcpSettings;exports.shouldTrustLocalMcpRequest=a.shouldTrustLocalMcpRequest;exports.touchCortexAiMcpToken=a.touchCortexAiMcpToken;exports.verifyCortexAiMcpToken=a.verifyCortexAiMcpToken;exports.CORTEX_MCP_PROMPTS=c.CORTEX_MCP_PROMPTS;exports.CORTEX_MCP_RESOURCES=c.CORTEX_MCP_RESOURCES;exports.CORTEX_MCP_TOOL_ALIASES=c.CORTEX_MCP_TOOL_ALIASES;exports.CORTEX_MCP_TOOL_KINDS=c.CORTEX_MCP_TOOL_KINDS;exports.CortexMcpForbiddenToolError=c.CortexMcpForbiddenToolError;exports.CortexMcpUnknownToolError=c.CortexMcpUnknownToolError;exports.assertCortexMcpToolCoverage=c.assertCortexMcpToolCoverage;exports.buildCortexMcpToolDefinitions=c.buildCortexMcpToolDefinitions;exports.callCortexMcpTool=c.callCortexMcpTool;exports.cortexMcpScopesAllow=c.cortexMcpScopesAllow;exports.getCortexMcpPrompt=c.getCortexMcpPrompt;exports.getCortexMcpToolKind=c.getCortexMcpToolKind;exports.readCortexMcpResource=c.readCortexMcpResource;exports.resolveCortexMcpToolName=c.resolveCortexMcpToolName;Object.defineProperty(exports,"z",{enumerable:!0,get:()=>R.z});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("./lib/ai-block-generation.cjs.js"),s=require("./lib/ai-client.cjs.js"),t=require("./lib/ai-config.cjs.js"),l=require("./lib/ai-cortex-widget-builder.cjs.js"),c=require("./lib/ai-global-agent-custom-block-tools.cjs.js"),C=require("./lib/ai-global-agent-db-tools.cjs.js"),e=require("./lib/ai-global-agent-tools.cjs.js"),u=require("./lib/ai-key-crypto.cjs.js"),R=require("./lib/ai-model-catalog.cjs.js"),o=require("./lib/ai-model-registry.cjs.js"),E=require("./lib/ai-seo-metadata.cjs.js"),_=require("./lib/ai-vision.cjs.js"),T=require("./lib/cortex-widget-registry.cjs.js"),n=require("./lib/cortex-widget-schema.cjs.js"),r=require("./lib/mcp-server.cjs.js"),a=require("./lib/mcp-tokens.cjs.js"),i=require("./lib/mcp-tool-registry.cjs.js");require("./lib/zod-config.cjs.js");const A=require("zod");exports.INLINE_HTML_ASSISTANT_SYSTEM_PROMPT=S.INLINE_HTML_ASSISTANT_SYSTEM_PROMPT;exports.generateEditorBlocksRequestSchema=S.generateEditorBlocksRequestSchema;exports.generateEditorHtmlFragment=S.generateEditorHtmlFragment;exports.validateGeneratedEditorHtmlFragment=S.validateGeneratedEditorHtmlFragment;exports.createCortexAiOpenRouterClient=s.createCortexAiOpenRouterClient;exports.createCortexAiOpenRouterProvider=s.createCortexAiOpenRouterProvider;exports.generateCortexAiText=s.generateCortexAiText;exports.getStoredCortexAiModelSelection=s.getStoredCortexAiModelSelection;exports.resolveCortexAiOpenRouterCredential=s.resolveCortexAiOpenRouterCredential;exports.CORTEX_AI_AGENT_SETTINGS_BOUNDS=t.CORTEX_AI_AGENT_SETTINGS_BOUNDS;exports.CORTEX_AI_AGENT_SETTINGS_DEFAULTS=t.CORTEX_AI_AGENT_SETTINGS_DEFAULTS;exports.CORTEX_AI_AGENT_SETTINGS_KEY=t.CORTEX_AI_AGENT_SETTINGS_KEY;exports.CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY=t.CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY;exports.CORTEX_AI_OPENROUTER_SETTING_KEY=t.CORTEX_AI_OPENROUTER_SETTING_KEY;exports.CORTEX_AI_PACKAGE_ID=t.CORTEX_AI_PACKAGE_ID;exports.CORTEX_AI_PACKAGE_NAME=t.CORTEX_AI_PACKAGE_NAME;exports.CORTEX_AI_PEXELS_SETTING_KEY=t.CORTEX_AI_PEXELS_SETTING_KEY;exports.CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY=t.CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY;exports.CORTEX_AI_UNSPLASH_SETTING_KEY=t.CORTEX_AI_UNSPLASH_SETTING_KEY;exports.decryptStoredOpenRouterApiKey=t.decryptStoredOpenRouterApiKey;exports.encryptStoredOpenRouterApiKey=t.encryptStoredOpenRouterApiKey;exports.getCortexAiEnvConfig=t.getCortexAiEnvConfig;exports.getEnvOpenRouterKeyStatus=t.getEnvOpenRouterKeyStatus;exports.getOpenRouterEnvApiKey=t.getOpenRouterEnvApiKey;exports.getPexelsEnvApiKey=t.getPexelsEnvApiKey;exports.getStoredOpenRouterKeyStatus=t.getStoredOpenRouterKeyStatus;exports.getUnsplashEnvApiKey=t.getUnsplashEnvApiKey;exports.normalizeCortexAiAgentSettings=t.normalizeCortexAiAgentSettings;exports.resolveCortexAiAgentSettings=t.resolveCortexAiAgentSettings;exports.generateCortexWidgetDefinition=l.generateCortexWidgetDefinition;exports.createCortexCustomBlockTools=c.createCortexCustomBlockTools;exports.createCustomBlockInputSchema=c.createCustomBlockInputSchema;exports.deleteCustomBlockInputSchema=c.deleteCustomBlockInputSchema;exports.executeCreateCustomBlock=c.executeCreateCustomBlock;exports.executeDeleteCustomBlock=c.executeDeleteCustomBlock;exports.executeListCustomBlocks=c.executeListCustomBlocks;exports.executeUpdateCustomBlock=c.executeUpdateCustomBlock;exports.listCustomBlocksInputSchema=c.listCustomBlocksInputSchema;exports.updateCustomBlockInputSchema=c.updateCustomBlockInputSchema;exports.createCortexDatabaseAgentTools=C.createCortexDatabaseAgentTools;exports.describeDatabaseSchemaInputSchema=C.describeDatabaseSchemaInputSchema;exports.executeDatabaseActionPlan=C.executeDatabaseActionPlan;exports.executeDatabaseActionPlanInputSchema=C.executeDatabaseActionPlanInputSchema;exports.executeDatabaseMutation=C.executeDatabaseMutation;exports.executeDatabaseMutationInputSchema=C.executeDatabaseMutationInputSchema;exports.executeDescribeDatabaseSchema=C.executeDescribeDatabaseSchema;exports.executeReadDatabaseRecords=C.executeReadDatabaseRecords;exports.readDatabaseRecordsInputSchema=C.readDatabaseRecordsInputSchema;exports.availableCortexAiBlockTypes=e.availableCortexAiBlockTypes;exports.buildVisibleContactIntroActionPlan=e.buildVisibleContactIntroActionPlan;exports.cortexAiPageContextSchema=e.cortexAiPageContextSchema;exports.createCmsPageInputSchema=e.createCmsPageInputSchema;exports.createCmsPostInputSchema=e.createCmsPostInputSchema;exports.createCmsProductInputSchema=e.createCmsProductInputSchema;exports.createCortexGlobalAgentTools=e.createCortexGlobalAgentTools;exports.deleteCmsItemInputSchema=e.deleteCmsItemInputSchema;exports.executeCmsActionPlan=e.executeCmsActionPlan;exports.executeCmsActionPlanInputSchema=e.executeCmsActionPlanInputSchema;exports.executeCreateCmsPage=e.executeCreateCmsPage;exports.executeCreateCmsPost=e.executeCreateCmsPost;exports.executeCreateCmsProduct=e.executeCreateCmsProduct;exports.executeDeleteCmsItem=e.executeDeleteCmsItem;exports.executeFetchEcommerceStats=e.executeFetchEcommerceStats;exports.executeFetchUrlContent=e.executeFetchUrlContent;exports.executeInsertContentBlock=e.executeInsertContentBlock;exports.executeManageProductVariants=e.executeManageProductVariants;exports.executePrepareDeleteCmsItem=e.executePrepareDeleteCmsItem;exports.executePublishContentDraft=e.executePublishContentDraft;exports.executeReadCurrentCmsItem=e.executeReadCurrentCmsItem;exports.executeRewritePageDraft=e.executeRewritePageDraft;exports.executeSearchDocumentation=e.executeSearchDocumentation;exports.executeSearchDocumentationWithTimeout=e.executeSearchDocumentationWithTimeout;exports.executeSearchStockPhotos=e.executeSearchStockPhotos;exports.executeSetContentImages=e.executeSetContentImages;exports.executeTranslateContentBulk=e.executeTranslateContentBulk;exports.executeTranslatePage=e.executeTranslatePage;exports.executeUpdateCmsItemField=e.executeUpdateCmsItemField;exports.executeUpdateContentBlock=e.executeUpdateContentBlock;exports.executeUpdateCurrentCmsFields=e.executeUpdateCurrentCmsFields;exports.executeUpdateFooter=e.executeUpdateFooter;exports.executeUpdateNavigationBar=e.executeUpdateNavigationBar;exports.executeUpdateSectionColumnBlock=e.executeUpdateSectionColumnBlock;exports.fetchEcommerceStatsInputSchema=e.fetchEcommerceStatsInputSchema;exports.fetchUrlContentInputSchema=e.fetchUrlContentInputSchema;exports.insertContentBlockInputSchema=e.insertContentBlockInputSchema;exports.isBlockedFetchHost=e.isBlockedFetchHost;exports.manageProductVariantsInputSchema=e.manageProductVariantsInputSchema;exports.maybeTriggerStockPhotoDownloads=e.maybeTriggerStockPhotoDownloads;exports.navigationItemInputSchema=e.navigationItemInputSchema;exports.prepareDeleteCmsItemInputSchema=e.prepareDeleteCmsItemInputSchema;exports.publishContentDraftInputSchema=e.publishContentDraftInputSchema;exports.readCurrentCmsItemInputSchema=e.readCurrentCmsItemInputSchema;exports.resolveCortexAiStockPhotoProvider=e.resolveCortexAiStockPhotoProvider;exports.resolveCortexAiStockPhotoProviders=e.resolveCortexAiStockPhotoProviders;exports.rewritePageDraftInputSchema=e.rewritePageDraftInputSchema;exports.searchDocumentationInputSchema=e.searchDocumentationInputSchema;exports.searchStockPhotosInputSchema=e.searchStockPhotosInputSchema;exports.setContentImagesInputSchema=e.setContentImagesInputSchema;exports.translateContentBulkInputSchema=e.translateContentBulkInputSchema;exports.translatePageInputSchema=e.translatePageInputSchema;exports.updateCmsItemFieldInputSchema=e.updateCmsItemFieldInputSchema;exports.updateContentBlockInputSchema=e.updateContentBlockInputSchema;exports.updateCurrentCmsFieldsInputSchema=e.updateCurrentCmsFieldsInputSchema;exports.updateFooterInputSchema=e.updateFooterInputSchema;exports.updateNavigationBarInputSchema=e.updateNavigationBarInputSchema;exports.updateSectionColumnBlockInputSchema=e.updateSectionColumnBlockInputSchema;exports.CORTEX_AI_KEY_ALGORITHM=u.CORTEX_AI_KEY_ALGORITHM;exports.CORTEX_AI_KEY_ENVELOPE_VERSION=u.CORTEX_AI_KEY_ENVELOPE_VERSION;exports.decryptOpenRouterApiKey=u.decryptOpenRouterApiKey;exports.encryptOpenRouterApiKey=u.encryptOpenRouterApiKey;exports.getMaskedOpenRouterKey=u.getMaskedOpenRouterKey;exports.getOpenRouterKeyEnvelopeStatus=u.getOpenRouterKeyEnvelopeStatus;exports.listCortexAiCompatibleOpenRouterModels=R.listCortexAiCompatibleOpenRouterModels;exports.CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY=o.CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY;exports.CORTEX_AI_MODEL_REGISTRY=o.CORTEX_AI_MODEL_REGISTRY;exports.CORTEX_AI_OPENROUTER_BASE_URL=o.CORTEX_AI_OPENROUTER_BASE_URL;exports.CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL=o.CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL;exports.CORTEX_AI_REQUIRED_MODEL_PARAMETERS=o.CORTEX_AI_REQUIRED_MODEL_PARAMETERS;exports.CortexAiRoutingError=o.CortexAiRoutingError;exports.buildCortexAiModelFallbackChain=o.buildCortexAiModelFallbackChain;exports.buildCortexAiRoutingPolicy=o.buildCortexAiRoutingPolicy;exports.createCortexAiStoredModelSelection=o.createCortexAiStoredModelSelection;exports.filterCortexAiCompatibleOpenRouterModels=o.filterCortexAiCompatibleOpenRouterModels;exports.getHttpStatusCode=o.getHttpStatusCode;exports.isCortexAiFreeModelId=o.isCortexAiFreeModelId;exports.isOpenRouterRateLimitError=o.isOpenRouterRateLimitError;exports.isOpenRouterRecoverableRoutingError=o.isOpenRouterRecoverableRoutingError;exports.omitUnsupportedCortexAiModelOptions=o.omitUnsupportedCortexAiModelOptions;exports.runWithCortexAiModelFallback=o.runWithCortexAiModelFallback;exports.safeParseCortexAiModelSelection=o.safeParseCortexAiModelSelection;exports.summarizeCortexAiRoutingError=o.summarizeCortexAiRoutingError;exports.CORTEX_AI_SEO_METADATA_CONTENT_BUDGET=E.CORTEX_AI_SEO_METADATA_CONTENT_BUDGET;exports.CORTEX_AI_SEO_METADATA_LENGTH_BUDGETS=E.CORTEX_AI_SEO_METADATA_LENGTH_BUDGETS;exports.cortexAiSeoMetadataOutputSchema=E.cortexAiSeoMetadataOutputSchema;exports.extractJsonObject=E.extractJsonObject;exports.generateCortexAiSeoMetadata=E.generateCortexAiSeoMetadata;exports.truncateOnWordBoundary=E.truncateOnWordBoundary;exports.CORTEX_AI_DEFAULT_ALT_TEXT_MAX_LENGTH=_.CORTEX_AI_DEFAULT_ALT_TEXT_MAX_LENGTH;exports.CORTEX_AI_VISION_MODEL_FALLBACK_REGISTRY=_.CORTEX_AI_VISION_MODEL_FALLBACK_REGISTRY;exports.buildCortexAiVisionRoutingPolicy=_.buildCortexAiVisionRoutingPolicy;exports.generateCortexAiAltText=_.generateCortexAiAltText;exports.isKnownVisionCapableCortexAiModelId=_.isKnownVisionCapableCortexAiModelId;exports.normalizeGeneratedAltText=_.normalizeGeneratedAltText;exports.CORTEX_WIDGET_DEFINITION_SELECT=T.CORTEX_WIDGET_DEFINITION_SELECT;exports.CortexWidgetRegistryInsertError=T.CortexWidgetRegistryInsertError;exports.buildCortexWidgetDefinitionInsertPayload=T.buildCortexWidgetDefinitionInsertPayload;exports.insertCortexWidgetDefinition=T.insertCortexWidgetDefinition;exports.CORTEX_WIDGET_ALLOWED_RELATION_TABLES=n.CORTEX_WIDGET_ALLOWED_RELATION_TABLES;exports.buildCortexProfileCardVerificationDefinition=n.buildCortexProfileCardVerificationDefinition;exports.buildCortexWidgetBuilderPrompt=n.buildCortexWidgetBuilderPrompt;exports.buildCortexWidgetBuilderSystemPrompt=n.buildCortexWidgetBuilderSystemPrompt;exports.cortexWidgetBuildRequestSchema=n.cortexWidgetBuildRequestSchema;exports.cortexWidgetDbRelationFieldSchema=n.cortexWidgetDbRelationFieldSchema;exports.cortexWidgetDefinitionSchema=n.cortexWidgetDefinitionSchema;exports.cortexWidgetFieldSchema=n.cortexWidgetFieldSchema;exports.cortexWidgetImageR2FieldSchema=n.cortexWidgetImageR2FieldSchema;exports.cortexWidgetLayoutNodeSchema=n.cortexWidgetLayoutNodeSchema;exports.cortexWidgetRichTextFieldSchema=n.cortexWidgetRichTextFieldSchema;exports.cortexWidgetTextFieldSchema=n.cortexWidgetTextFieldSchema;exports.validateCortexWidgetDefinitionOutput=n.validateCortexWidgetDefinitionOutput;exports.CORTEX_MCP_DEFAULT_PROTOCOL_VERSION=r.CORTEX_MCP_DEFAULT_PROTOCOL_VERSION;exports.CORTEX_MCP_LATEST_LEGACY_PROTOCOL_VERSION=r.CORTEX_MCP_LATEST_LEGACY_PROTOCOL_VERSION;exports.CORTEX_MCP_MODERN_PROTOCOL_VERSION=r.CORTEX_MCP_MODERN_PROTOCOL_VERSION;exports.CORTEX_MCP_SERVER_NAME=r.CORTEX_MCP_SERVER_NAME;exports.CORTEX_MCP_SERVER_TITLE=r.CORTEX_MCP_SERVER_TITLE;exports.CORTEX_MCP_SUPPORTED_PROTOCOL_VERSIONS=r.CORTEX_MCP_SUPPORTED_PROTOCOL_VERSIONS;exports.JSON_RPC_INTERNAL_ERROR=r.JSON_RPC_INTERNAL_ERROR;exports.JSON_RPC_INVALID_PARAMS=r.JSON_RPC_INVALID_PARAMS;exports.JSON_RPC_INVALID_REQUEST=r.JSON_RPC_INVALID_REQUEST;exports.JSON_RPC_METHOD_NOT_FOUND=r.JSON_RPC_METHOD_NOT_FOUND;exports.JSON_RPC_PARSE_ERROR=r.JSON_RPC_PARSE_ERROR;exports.handleCortexMcpMessage=r.handleCortexMcpMessage;exports.isJsonRpcNotification=r.isJsonRpcNotification;exports.isModernEraMessage=r.isModernEraMessage;exports.CORTEX_AI_MCP_SCOPES=a.CORTEX_AI_MCP_SCOPES;exports.CORTEX_AI_MCP_SETTINGS_DEFAULTS=a.CORTEX_AI_MCP_SETTINGS_DEFAULTS;exports.CORTEX_AI_MCP_SETTINGS_KEY=a.CORTEX_AI_MCP_SETTINGS_KEY;exports.CORTEX_AI_MCP_TOKENS_TABLE=a.CORTEX_AI_MCP_TOKENS_TABLE;exports.CORTEX_AI_MCP_TOKEN_PREFIX=a.CORTEX_AI_MCP_TOKEN_PREFIX;exports.hashCortexAiMcpToken=a.hashCortexAiMcpToken;exports.isLocalhostHost=a.isLocalhostHost;exports.mintCortexAiMcpToken=a.mintCortexAiMcpToken;exports.normalizeCortexAiMcpSettings=a.normalizeCortexAiMcpSettings;exports.parseBearerToken=a.parseBearerToken;exports.resolveCortexAiMcpSettings=a.resolveCortexAiMcpSettings;exports.shouldTrustLocalMcpRequest=a.shouldTrustLocalMcpRequest;exports.touchCortexAiMcpToken=a.touchCortexAiMcpToken;exports.verifyCortexAiMcpToken=a.verifyCortexAiMcpToken;exports.CORTEX_MCP_PROMPTS=i.CORTEX_MCP_PROMPTS;exports.CORTEX_MCP_RESOURCES=i.CORTEX_MCP_RESOURCES;exports.CORTEX_MCP_TOOL_ALIASES=i.CORTEX_MCP_TOOL_ALIASES;exports.CORTEX_MCP_TOOL_KINDS=i.CORTEX_MCP_TOOL_KINDS;exports.CortexMcpForbiddenToolError=i.CortexMcpForbiddenToolError;exports.CortexMcpUnknownToolError=i.CortexMcpUnknownToolError;exports.assertCortexMcpToolCoverage=i.assertCortexMcpToolCoverage;exports.buildCortexMcpToolDefinitions=i.buildCortexMcpToolDefinitions;exports.callCortexMcpTool=i.callCortexMcpTool;exports.cortexMcpScopesAllow=i.cortexMcpScopesAllow;exports.getCortexMcpPrompt=i.getCortexMcpPrompt;exports.getCortexMcpToolKind=i.getCortexMcpToolKind;exports.readCortexMcpResource=i.readCortexMcpResource;exports.resolveCortexMcpToolName=i.resolveCortexMcpToolName;Object.defineProperty(exports,"z",{enumerable:!0,get:()=>A.z});
|
package/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './lib/ai-global-agent-tools';
|
|
|
8
8
|
export * from './lib/ai-key-crypto';
|
|
9
9
|
export * from './lib/ai-model-catalog';
|
|
10
10
|
export * from './lib/ai-model-registry';
|
|
11
|
+
export * from './lib/ai-seo-metadata';
|
|
12
|
+
export * from './lib/ai-vision';
|
|
11
13
|
export * from './lib/cortex-widget-registry';
|
|
12
14
|
export * from './lib/cortex-widget-schema';
|
|
13
15
|
export * from './lib/mcp-server';
|
package/index.es.js
CHANGED
|
@@ -1,210 +1,224 @@
|
|
|
1
|
-
import { INLINE_HTML_ASSISTANT_SYSTEM_PROMPT as r, generateEditorBlocksRequestSchema as a, generateEditorHtmlFragment as
|
|
2
|
-
import { createCortexAiOpenRouterClient as C, createCortexAiOpenRouterProvider as E, generateCortexAiText as
|
|
3
|
-
import { CORTEX_AI_AGENT_SETTINGS_BOUNDS as
|
|
4
|
-
import { generateCortexWidgetDefinition as
|
|
5
|
-
import { createCortexCustomBlockTools as
|
|
1
|
+
import { INLINE_HTML_ASSISTANT_SYSTEM_PROMPT as r, generateEditorBlocksRequestSchema as a, generateEditorHtmlFragment as n, validateGeneratedEditorHtmlFragment as c } from "./lib/ai-block-generation.es.js";
|
|
2
|
+
import { createCortexAiOpenRouterClient as C, createCortexAiOpenRouterProvider as E, generateCortexAiText as _, getStoredCortexAiModelSelection as u, resolveCortexAiOpenRouterCredential as S } from "./lib/ai-client.es.js";
|
|
3
|
+
import { CORTEX_AI_AGENT_SETTINGS_BOUNDS as s, CORTEX_AI_AGENT_SETTINGS_DEFAULTS as l, CORTEX_AI_AGENT_SETTINGS_KEY as m, CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY as R, CORTEX_AI_OPENROUTER_SETTING_KEY as p, CORTEX_AI_PACKAGE_ID as A, CORTEX_AI_PACKAGE_NAME as x, CORTEX_AI_PEXELS_SETTING_KEY as O, CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY as I, CORTEX_AI_UNSPLASH_SETTING_KEY as d, decryptStoredOpenRouterApiKey as P, encryptStoredOpenRouterApiKey as h, getCortexAiEnvConfig as M, getEnvOpenRouterKeyStatus as g, getOpenRouterEnvApiKey as N, getPexelsEnvApiKey as D, getStoredOpenRouterKeyStatus as L, getUnsplashEnvApiKey as X, normalizeCortexAiAgentSettings as f, resolveCortexAiAgentSettings as b } from "./lib/ai-config.es.js";
|
|
4
|
+
import { generateCortexWidgetDefinition as k } from "./lib/ai-cortex-widget-builder.es.js";
|
|
5
|
+
import { createCortexCustomBlockTools as F, createCustomBlockInputSchema as G, deleteCustomBlockInputSchema as K, executeCreateCustomBlock as y, executeDeleteCustomBlock as v, executeListCustomBlocks as W, executeUpdateCustomBlock as V, listCustomBlocksInputSchema as Y, updateCustomBlockInputSchema as H } from "./lib/ai-global-agent-custom-block-tools.es.js";
|
|
6
6
|
import { createCortexDatabaseAgentTools as w, describeDatabaseSchemaInputSchema as z, executeDatabaseActionPlan as q, executeDatabaseActionPlanInputSchema as Q, executeDatabaseMutation as j, executeDatabaseMutationInputSchema as Z, executeDescribeDatabaseSchema as $, executeReadDatabaseRecords as ee, readDatabaseRecordsInputSchema as te } from "./lib/ai-global-agent-db-tools.es.js";
|
|
7
|
-
import { availableCortexAiBlockTypes as re, buildVisibleContactIntroActionPlan as ae, cortexAiPageContextSchema as
|
|
8
|
-
import { CORTEX_AI_KEY_ALGORITHM as Ct, CORTEX_AI_KEY_ENVELOPE_VERSION as Et, decryptOpenRouterApiKey as
|
|
9
|
-
import { listCortexAiCompatibleOpenRouterModels as
|
|
10
|
-
import { CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY as Rt, CORTEX_AI_MODEL_REGISTRY as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
7
|
+
import { availableCortexAiBlockTypes as re, buildVisibleContactIntroActionPlan as ae, cortexAiPageContextSchema as ne, createCmsPageInputSchema as ce, createCmsPostInputSchema as ie, createCmsProductInputSchema as Ce, createCortexGlobalAgentTools as Ee, deleteCmsItemInputSchema as _e, executeCmsActionPlan as ue, executeCmsActionPlanInputSchema as Se, executeCreateCmsPage as Te, executeCreateCmsPost as se, executeCreateCmsProduct as le, executeDeleteCmsItem as me, executeFetchEcommerceStats as Re, executeFetchUrlContent as pe, executeInsertContentBlock as Ae, executeManageProductVariants as xe, executePrepareDeleteCmsItem as Oe, executePublishContentDraft as Ie, executeReadCurrentCmsItem as de, executeRewritePageDraft as Pe, executeSearchDocumentation as he, executeSearchDocumentationWithTimeout as Me, executeSearchStockPhotos as ge, executeSetContentImages as Ne, executeTranslateContentBulk as De, executeTranslatePage as Le, executeUpdateCmsItemField as Xe, executeUpdateContentBlock as fe, executeUpdateCurrentCmsFields as be, executeUpdateFooter as Be, executeUpdateNavigationBar as ke, executeUpdateSectionColumnBlock as Ue, fetchEcommerceStatsInputSchema as Fe, fetchUrlContentInputSchema as Ge, insertContentBlockInputSchema as Ke, isBlockedFetchHost as ye, manageProductVariantsInputSchema as ve, maybeTriggerStockPhotoDownloads as We, navigationItemInputSchema as Ve, prepareDeleteCmsItemInputSchema as Ye, publishContentDraftInputSchema as He, readCurrentCmsItemInputSchema as Je, resolveCortexAiStockPhotoProvider as we, resolveCortexAiStockPhotoProviders as ze, rewritePageDraftInputSchema as qe, searchDocumentationInputSchema as Qe, searchStockPhotosInputSchema as je, setContentImagesInputSchema as Ze, translateContentBulkInputSchema as $e, translatePageInputSchema as et, updateCmsItemFieldInputSchema as tt, updateContentBlockInputSchema as ot, updateCurrentCmsFieldsInputSchema as rt, updateFooterInputSchema as at, updateNavigationBarInputSchema as nt, updateSectionColumnBlockInputSchema as ct } from "./lib/ai-global-agent-tools.es.js";
|
|
8
|
+
import { CORTEX_AI_KEY_ALGORITHM as Ct, CORTEX_AI_KEY_ENVELOPE_VERSION as Et, decryptOpenRouterApiKey as _t, encryptOpenRouterApiKey as ut, getMaskedOpenRouterKey as St, getOpenRouterKeyEnvelopeStatus as Tt } from "./lib/ai-key-crypto.es.js";
|
|
9
|
+
import { listCortexAiCompatibleOpenRouterModels as lt } from "./lib/ai-model-catalog.es.js";
|
|
10
|
+
import { CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY as Rt, CORTEX_AI_MODEL_REGISTRY as pt, CORTEX_AI_OPENROUTER_BASE_URL as At, CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL as xt, CORTEX_AI_REQUIRED_MODEL_PARAMETERS as Ot, CortexAiRoutingError as It, buildCortexAiModelFallbackChain as dt, buildCortexAiRoutingPolicy as Pt, createCortexAiStoredModelSelection as ht, filterCortexAiCompatibleOpenRouterModels as Mt, getHttpStatusCode as gt, isCortexAiFreeModelId as Nt, isOpenRouterRateLimitError as Dt, isOpenRouterRecoverableRoutingError as Lt, omitUnsupportedCortexAiModelOptions as Xt, runWithCortexAiModelFallback as ft, safeParseCortexAiModelSelection as bt, summarizeCortexAiRoutingError as Bt } from "./lib/ai-model-registry.es.js";
|
|
11
|
+
import { CORTEX_AI_SEO_METADATA_CONTENT_BUDGET as Ut, CORTEX_AI_SEO_METADATA_LENGTH_BUDGETS as Ft, cortexAiSeoMetadataOutputSchema as Gt, extractJsonObject as Kt, generateCortexAiSeoMetadata as yt, truncateOnWordBoundary as vt } from "./lib/ai-seo-metadata.es.js";
|
|
12
|
+
import { CORTEX_AI_DEFAULT_ALT_TEXT_MAX_LENGTH as Vt, CORTEX_AI_VISION_MODEL_FALLBACK_REGISTRY as Yt, buildCortexAiVisionRoutingPolicy as Ht, generateCortexAiAltText as Jt, isKnownVisionCapableCortexAiModelId as wt, normalizeGeneratedAltText as zt } from "./lib/ai-vision.es.js";
|
|
13
|
+
import { CORTEX_WIDGET_DEFINITION_SELECT as Qt, CortexWidgetRegistryInsertError as jt, buildCortexWidgetDefinitionInsertPayload as Zt, insertCortexWidgetDefinition as $t } from "./lib/cortex-widget-registry.es.js";
|
|
14
|
+
import { CORTEX_WIDGET_ALLOWED_RELATION_TABLES as to, buildCortexProfileCardVerificationDefinition as oo, buildCortexWidgetBuilderPrompt as ro, buildCortexWidgetBuilderSystemPrompt as ao, cortexWidgetBuildRequestSchema as no, cortexWidgetDbRelationFieldSchema as co, cortexWidgetDefinitionSchema as io, cortexWidgetFieldSchema as Co, cortexWidgetImageR2FieldSchema as Eo, cortexWidgetLayoutNodeSchema as _o, cortexWidgetRichTextFieldSchema as uo, cortexWidgetTextFieldSchema as So, validateCortexWidgetDefinitionOutput as To } from "./lib/cortex-widget-schema.es.js";
|
|
15
|
+
import { CORTEX_MCP_DEFAULT_PROTOCOL_VERSION as lo, CORTEX_MCP_LATEST_LEGACY_PROTOCOL_VERSION as mo, CORTEX_MCP_MODERN_PROTOCOL_VERSION as Ro, CORTEX_MCP_SERVER_NAME as po, CORTEX_MCP_SERVER_TITLE as Ao, CORTEX_MCP_SUPPORTED_PROTOCOL_VERSIONS as xo, JSON_RPC_INTERNAL_ERROR as Oo, JSON_RPC_INVALID_PARAMS as Io, JSON_RPC_INVALID_REQUEST as Po, JSON_RPC_METHOD_NOT_FOUND as ho, JSON_RPC_PARSE_ERROR as Mo, handleCortexMcpMessage as go, isJsonRpcNotification as No, isModernEraMessage as Do } from "./lib/mcp-server.es.js";
|
|
16
|
+
import { CORTEX_AI_MCP_SCOPES as Xo, CORTEX_AI_MCP_SETTINGS_DEFAULTS as fo, CORTEX_AI_MCP_SETTINGS_KEY as bo, CORTEX_AI_MCP_TOKENS_TABLE as Bo, CORTEX_AI_MCP_TOKEN_PREFIX as ko, hashCortexAiMcpToken as Uo, isLocalhostHost as Fo, mintCortexAiMcpToken as Go, normalizeCortexAiMcpSettings as Ko, parseBearerToken as yo, resolveCortexAiMcpSettings as vo, shouldTrustLocalMcpRequest as Wo, touchCortexAiMcpToken as Vo, verifyCortexAiMcpToken as Yo } from "./lib/mcp-tokens.es.js";
|
|
17
|
+
import { CORTEX_MCP_PROMPTS as Jo, CORTEX_MCP_RESOURCES as wo, CORTEX_MCP_TOOL_ALIASES as zo, CORTEX_MCP_TOOL_KINDS as qo, CortexMcpForbiddenToolError as Qo, CortexMcpUnknownToolError as jo, assertCortexMcpToolCoverage as Zo, buildCortexMcpToolDefinitions as $o, callCortexMcpTool as er, cortexMcpScopesAllow as tr, getCortexMcpPrompt as or, getCortexMcpToolKind as rr, readCortexMcpResource as ar, resolveCortexMcpToolName as nr } from "./lib/mcp-tool-registry.es.js";
|
|
16
18
|
import "./lib/zod-config.es.js";
|
|
17
|
-
import { z as
|
|
19
|
+
import { z as ir } from "zod";
|
|
18
20
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
s as CORTEX_AI_AGENT_SETTINGS_BOUNDS,
|
|
22
|
+
l as CORTEX_AI_AGENT_SETTINGS_DEFAULTS,
|
|
23
|
+
m as CORTEX_AI_AGENT_SETTINGS_KEY,
|
|
24
|
+
Vt as CORTEX_AI_DEFAULT_ALT_TEXT_MAX_LENGTH,
|
|
22
25
|
Rt as CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY,
|
|
23
26
|
Ct as CORTEX_AI_KEY_ALGORITHM,
|
|
24
27
|
Et as CORTEX_AI_KEY_ENVELOPE_VERSION,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
Xo as CORTEX_AI_MCP_SCOPES,
|
|
29
|
+
fo as CORTEX_AI_MCP_SETTINGS_DEFAULTS,
|
|
30
|
+
bo as CORTEX_AI_MCP_SETTINGS_KEY,
|
|
31
|
+
Bo as CORTEX_AI_MCP_TOKENS_TABLE,
|
|
32
|
+
ko as CORTEX_AI_MCP_TOKEN_PREFIX,
|
|
33
|
+
pt as CORTEX_AI_MODEL_REGISTRY,
|
|
34
|
+
At as CORTEX_AI_OPENROUTER_BASE_URL,
|
|
35
|
+
xt as CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL,
|
|
33
36
|
R as CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
p as CORTEX_AI_OPENROUTER_SETTING_KEY,
|
|
38
|
+
A as CORTEX_AI_PACKAGE_ID,
|
|
39
|
+
x as CORTEX_AI_PACKAGE_NAME,
|
|
40
|
+
O as CORTEX_AI_PEXELS_SETTING_KEY,
|
|
41
|
+
Ot as CORTEX_AI_REQUIRED_MODEL_PARAMETERS,
|
|
42
|
+
Ut as CORTEX_AI_SEO_METADATA_CONTENT_BUDGET,
|
|
43
|
+
Ft as CORTEX_AI_SEO_METADATA_LENGTH_BUDGETS,
|
|
44
|
+
I as CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY,
|
|
40
45
|
d as CORTEX_AI_UNSPLASH_SETTING_KEY,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
Yt as CORTEX_AI_VISION_MODEL_FALLBACK_REGISTRY,
|
|
47
|
+
lo as CORTEX_MCP_DEFAULT_PROTOCOL_VERSION,
|
|
48
|
+
mo as CORTEX_MCP_LATEST_LEGACY_PROTOCOL_VERSION,
|
|
49
|
+
Ro as CORTEX_MCP_MODERN_PROTOCOL_VERSION,
|
|
50
|
+
Jo as CORTEX_MCP_PROMPTS,
|
|
51
|
+
wo as CORTEX_MCP_RESOURCES,
|
|
52
|
+
po as CORTEX_MCP_SERVER_NAME,
|
|
53
|
+
Ao as CORTEX_MCP_SERVER_TITLE,
|
|
54
|
+
xo as CORTEX_MCP_SUPPORTED_PROTOCOL_VERSIONS,
|
|
55
|
+
zo as CORTEX_MCP_TOOL_ALIASES,
|
|
56
|
+
qo as CORTEX_MCP_TOOL_KINDS,
|
|
57
|
+
to as CORTEX_WIDGET_ALLOWED_RELATION_TABLES,
|
|
58
|
+
Qt as CORTEX_WIDGET_DEFINITION_SELECT,
|
|
59
|
+
It as CortexAiRoutingError,
|
|
60
|
+
Qo as CortexMcpForbiddenToolError,
|
|
61
|
+
jo as CortexMcpUnknownToolError,
|
|
62
|
+
jt as CortexWidgetRegistryInsertError,
|
|
57
63
|
r as INLINE_HTML_ASSISTANT_SYSTEM_PROMPT,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
Oo as JSON_RPC_INTERNAL_ERROR,
|
|
65
|
+
Io as JSON_RPC_INVALID_PARAMS,
|
|
66
|
+
Po as JSON_RPC_INVALID_REQUEST,
|
|
67
|
+
ho as JSON_RPC_METHOD_NOT_FOUND,
|
|
68
|
+
Mo as JSON_RPC_PARSE_ERROR,
|
|
69
|
+
Zo as assertCortexMcpToolCoverage,
|
|
64
70
|
re as availableCortexAiBlockTypes,
|
|
65
71
|
dt as buildCortexAiModelFallbackChain,
|
|
66
72
|
Pt as buildCortexAiRoutingPolicy,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
Ht as buildCortexAiVisionRoutingPolicy,
|
|
74
|
+
$o as buildCortexMcpToolDefinitions,
|
|
75
|
+
oo as buildCortexProfileCardVerificationDefinition,
|
|
76
|
+
ro as buildCortexWidgetBuilderPrompt,
|
|
77
|
+
ao as buildCortexWidgetBuilderSystemPrompt,
|
|
78
|
+
Zt as buildCortexWidgetDefinitionInsertPayload,
|
|
72
79
|
ae as buildVisibleContactIntroActionPlan,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
er as callCortexMcpTool,
|
|
81
|
+
ne as cortexAiPageContextSchema,
|
|
82
|
+
Gt as cortexAiSeoMetadataOutputSchema,
|
|
83
|
+
tr as cortexMcpScopesAllow,
|
|
84
|
+
no as cortexWidgetBuildRequestSchema,
|
|
85
|
+
co as cortexWidgetDbRelationFieldSchema,
|
|
86
|
+
io as cortexWidgetDefinitionSchema,
|
|
87
|
+
Co as cortexWidgetFieldSchema,
|
|
88
|
+
Eo as cortexWidgetImageR2FieldSchema,
|
|
89
|
+
_o as cortexWidgetLayoutNodeSchema,
|
|
90
|
+
uo as cortexWidgetRichTextFieldSchema,
|
|
91
|
+
So as cortexWidgetTextFieldSchema,
|
|
92
|
+
ce as createCmsPageInputSchema,
|
|
85
93
|
ie as createCmsPostInputSchema,
|
|
86
94
|
Ce as createCmsProductInputSchema,
|
|
87
95
|
C as createCortexAiOpenRouterClient,
|
|
88
96
|
E as createCortexAiOpenRouterProvider,
|
|
89
97
|
ht as createCortexAiStoredModelSelection,
|
|
90
|
-
|
|
98
|
+
F as createCortexCustomBlockTools,
|
|
91
99
|
w as createCortexDatabaseAgentTools,
|
|
92
100
|
Ee as createCortexGlobalAgentTools,
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
G as createCustomBlockInputSchema,
|
|
102
|
+
_t as decryptOpenRouterApiKey,
|
|
95
103
|
P as decryptStoredOpenRouterApiKey,
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
_e as deleteCmsItemInputSchema,
|
|
105
|
+
K as deleteCustomBlockInputSchema,
|
|
98
106
|
z as describeDatabaseSchemaInputSchema,
|
|
99
|
-
|
|
107
|
+
ut as encryptOpenRouterApiKey,
|
|
100
108
|
h as encryptStoredOpenRouterApiKey,
|
|
101
|
-
|
|
109
|
+
ue as executeCmsActionPlan,
|
|
102
110
|
Se as executeCmsActionPlanInputSchema,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
Te as executeCreateCmsPage,
|
|
112
|
+
se as executeCreateCmsPost,
|
|
113
|
+
le as executeCreateCmsProduct,
|
|
106
114
|
y as executeCreateCustomBlock,
|
|
107
115
|
q as executeDatabaseActionPlan,
|
|
108
116
|
Q as executeDatabaseActionPlanInputSchema,
|
|
109
117
|
j as executeDatabaseMutation,
|
|
110
118
|
Z as executeDatabaseMutationInputSchema,
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
me as executeDeleteCmsItem,
|
|
120
|
+
v as executeDeleteCustomBlock,
|
|
113
121
|
$ as executeDescribeDatabaseSchema,
|
|
114
122
|
Re as executeFetchEcommerceStats,
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
pe as executeFetchUrlContent,
|
|
124
|
+
Ae as executeInsertContentBlock,
|
|
117
125
|
W as executeListCustomBlocks,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
xe as executeManageProductVariants,
|
|
127
|
+
Oe as executePrepareDeleteCmsItem,
|
|
128
|
+
Ie as executePublishContentDraft,
|
|
121
129
|
de as executeReadCurrentCmsItem,
|
|
122
130
|
ee as executeReadDatabaseRecords,
|
|
123
131
|
Pe as executeRewritePageDraft,
|
|
124
132
|
he as executeSearchDocumentation,
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
Me as executeSearchDocumentationWithTimeout,
|
|
134
|
+
ge as executeSearchStockPhotos,
|
|
127
135
|
Ne as executeSetContentImages,
|
|
128
136
|
De as executeTranslateContentBulk,
|
|
129
137
|
Le as executeTranslatePage,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
138
|
+
Xe as executeUpdateCmsItemField,
|
|
139
|
+
fe as executeUpdateContentBlock,
|
|
140
|
+
be as executeUpdateCurrentCmsFields,
|
|
133
141
|
V as executeUpdateCustomBlock,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
Be as executeUpdateFooter,
|
|
143
|
+
ke as executeUpdateNavigationBar,
|
|
144
|
+
Ue as executeUpdateSectionColumnBlock,
|
|
145
|
+
Kt as extractJsonObject,
|
|
146
|
+
Fe as fetchEcommerceStatsInputSchema,
|
|
147
|
+
Ge as fetchUrlContentInputSchema,
|
|
148
|
+
Mt as filterCortexAiCompatibleOpenRouterModels,
|
|
149
|
+
Jt as generateCortexAiAltText,
|
|
150
|
+
yt as generateCortexAiSeoMetadata,
|
|
151
|
+
_ as generateCortexAiText,
|
|
152
|
+
k as generateCortexWidgetDefinition,
|
|
142
153
|
a as generateEditorBlocksRequestSchema,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
n as generateEditorHtmlFragment,
|
|
155
|
+
M as getCortexAiEnvConfig,
|
|
156
|
+
or as getCortexMcpPrompt,
|
|
157
|
+
rr as getCortexMcpToolKind,
|
|
158
|
+
g as getEnvOpenRouterKeyStatus,
|
|
159
|
+
gt as getHttpStatusCode,
|
|
149
160
|
St as getMaskedOpenRouterKey,
|
|
150
161
|
N as getOpenRouterEnvApiKey,
|
|
151
|
-
|
|
162
|
+
Tt as getOpenRouterKeyEnvelopeStatus,
|
|
152
163
|
D as getPexelsEnvApiKey,
|
|
153
|
-
|
|
164
|
+
u as getStoredCortexAiModelSelection,
|
|
154
165
|
L as getStoredOpenRouterKeyStatus,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
166
|
+
X as getUnsplashEnvApiKey,
|
|
167
|
+
go as handleCortexMcpMessage,
|
|
168
|
+
Uo as hashCortexAiMcpToken,
|
|
169
|
+
Ke as insertContentBlockInputSchema,
|
|
170
|
+
$t as insertCortexWidgetDefinition,
|
|
160
171
|
ye as isBlockedFetchHost,
|
|
161
172
|
Nt as isCortexAiFreeModelId,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
173
|
+
No as isJsonRpcNotification,
|
|
174
|
+
wt as isKnownVisionCapableCortexAiModelId,
|
|
175
|
+
Fo as isLocalhostHost,
|
|
176
|
+
Do as isModernEraMessage,
|
|
165
177
|
Dt as isOpenRouterRateLimitError,
|
|
166
178
|
Lt as isOpenRouterRecoverableRoutingError,
|
|
167
|
-
|
|
179
|
+
lt as listCortexAiCompatibleOpenRouterModels,
|
|
168
180
|
Y as listCustomBlocksInputSchema,
|
|
169
|
-
|
|
181
|
+
ve as manageProductVariantsInputSchema,
|
|
170
182
|
We as maybeTriggerStockPhotoDownloads,
|
|
171
|
-
|
|
183
|
+
Go as mintCortexAiMcpToken,
|
|
172
184
|
Ve as navigationItemInputSchema,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
185
|
+
f as normalizeCortexAiAgentSettings,
|
|
186
|
+
Ko as normalizeCortexAiMcpSettings,
|
|
187
|
+
zt as normalizeGeneratedAltText,
|
|
188
|
+
Xt as omitUnsupportedCortexAiModelOptions,
|
|
189
|
+
yo as parseBearerToken,
|
|
177
190
|
Ye as prepareDeleteCmsItemInputSchema,
|
|
178
191
|
He as publishContentDraftInputSchema,
|
|
179
|
-
|
|
192
|
+
ar as readCortexMcpResource,
|
|
180
193
|
Je as readCurrentCmsItemInputSchema,
|
|
181
194
|
te as readDatabaseRecordsInputSchema,
|
|
182
|
-
|
|
183
|
-
|
|
195
|
+
b as resolveCortexAiAgentSettings,
|
|
196
|
+
vo as resolveCortexAiMcpSettings,
|
|
184
197
|
S as resolveCortexAiOpenRouterCredential,
|
|
185
198
|
we as resolveCortexAiStockPhotoProvider,
|
|
186
199
|
ze as resolveCortexAiStockPhotoProviders,
|
|
187
|
-
|
|
200
|
+
nr as resolveCortexMcpToolName,
|
|
188
201
|
qe as rewritePageDraftInputSchema,
|
|
189
|
-
|
|
190
|
-
|
|
202
|
+
ft as runWithCortexAiModelFallback,
|
|
203
|
+
bt as safeParseCortexAiModelSelection,
|
|
191
204
|
Qe as searchDocumentationInputSchema,
|
|
192
205
|
je as searchStockPhotosInputSchema,
|
|
193
206
|
Ze as setContentImagesInputSchema,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
207
|
+
Wo as shouldTrustLocalMcpRequest,
|
|
208
|
+
Bt as summarizeCortexAiRoutingError,
|
|
209
|
+
Vo as touchCortexAiMcpToken,
|
|
197
210
|
$e as translateContentBulkInputSchema,
|
|
198
211
|
et as translatePageInputSchema,
|
|
212
|
+
vt as truncateOnWordBoundary,
|
|
199
213
|
tt as updateCmsItemFieldInputSchema,
|
|
200
214
|
ot as updateContentBlockInputSchema,
|
|
201
215
|
rt as updateCurrentCmsFieldsInputSchema,
|
|
202
216
|
H as updateCustomBlockInputSchema,
|
|
203
217
|
at as updateFooterInputSchema,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
218
|
+
nt as updateNavigationBarInputSchema,
|
|
219
|
+
ct as updateSectionColumnBlockInputSchema,
|
|
220
|
+
To as validateCortexWidgetDefinitionOutput,
|
|
221
|
+
c as validateGeneratedEditorHtmlFragment,
|
|
222
|
+
Yo as verifyCortexAiMcpToken,
|
|
223
|
+
ir as z
|
|
210
224
|
};
|
package/lib/ai-client.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var C=Object.create;var
|
|
1
|
+
"use strict";var C=Object.create;var R=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var x=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of S(t))!y.call(e,n)&&n!==o&&R(e,n,{get:()=>t[n],enumerable:!(i=m(t,n))||i.enumerable});return e};var d=(e,t,o)=>(o=e!=null?C(T(e)):{},x(t||!e||!e.__esModule?R(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@ai-sdk/openai-compatible"),f=require("ai"),a=require("./ai-config.cjs.js"),r=require("./ai-model-registry.cjs.js"),g=require("./ai-model-catalog.cjs.js"),M="Cortex AI OpenRouter client can only be imported from server-side code.";function l(){if(!(typeof window>"u"))throw new Error(M)}function b(){return l(),{"HTTP-Referer":process.env.NEXT_PUBLIC_URL?.trim()||"https://nextblock.dev","X-Title":a.CORTEX_AI_PACKAGE_NAME}}function E(e){return l(),I.createOpenAICompatible({apiKey:e.apiKey,baseURL:r.CORTEX_AI_OPENROUTER_BASE_URL,fetch:e.fetch,headers:b(),includeUsage:!0,name:"openrouter",supportsStructuredOutputs:!0})}async function K(){l();const{getServiceRoleSupabaseClient:e}=await import("@nextblock-cms/db/server"),t=e(),{data:o,error:i}=await t.from("site_settings").select("value").eq("key",a.CORTEX_AI_OPENROUTER_SETTING_KEY).maybeSingle();if(i)throw new Error(`Failed to load stored Cortex AI OpenRouter key: ${i.message}`);return o?.value?a.decryptStoredOpenRouterApiKey(o.value):null}async function O(){l();const{getServiceRoleSupabaseClient:e}=await import("@nextblock-cms/db/server"),t=e(),{data:o,error:i}=await t.from("site_settings").select("value").eq("key",a.CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY).maybeSingle();if(i)throw new Error(`Failed to load Cortex AI OpenRouter model selection: ${i.message}`);return r.safeParseCortexAiModelSelection(o?.value)}async function p(e){l();const t=e?.apiKey?.trim();if(t)return{apiKey:t,source:"manual"};const o=await K();if(o)return{apiKey:o,source:"stored"};const i=a.getOpenRouterEnvApiKey();return i?{apiKey:i,source:"env"}:{apiKey:null,source:"none"}}async function A(e){l();const t=await p({apiKey:e?.apiKey});if(!t.apiKey||t.source==="none")throw new Error("Cortex AI requires OPENROUTER_API_KEY or an encrypted OpenRouter BYOK in site settings.");const o=E({apiKey:t.apiKey,fetch:e?.fetch}),i=e?.modelSelection!==void 0?e.modelSelection:t.source==="stored"?await O():null;return{credentialSource:t.source,model:n=>o.chatModel(n||"openrouter/free"),modelSelection:i}}async function v({apiKey:e,fallbackModelIds:t,modelId:o,...i}){l();const n=await A({apiKey:e,modelSelection:i.modelSelection}),c=r.buildCortexAiRoutingPolicy({credentialSource:n.credentialSource,fallbackModelIds:t,requestedModelId:o,selectedModel:n.modelSelection}),u=await r.runWithCortexAiModelFallback({modelIds:c.modelIds,execute:s=>{const _=r.omitUnsupportedCortexAiModelOptions({...i,maxRetries:0},{modelId:s,modelSelection:c.modelSelection});return f.generateText({..._,model:n.model(s)})}});return{attempts:u.attempts,credentialSource:n.credentialSource,modelId:u.modelId,result:u.result}}exports.CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY=r.CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY;exports.CORTEX_AI_MODEL_REGISTRY=r.CORTEX_AI_MODEL_REGISTRY;exports.CORTEX_AI_OPENROUTER_BASE_URL=r.CORTEX_AI_OPENROUTER_BASE_URL;exports.CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL=r.CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL;exports.CORTEX_AI_REQUIRED_MODEL_PARAMETERS=r.CORTEX_AI_REQUIRED_MODEL_PARAMETERS;exports.CortexAiRoutingError=r.CortexAiRoutingError;exports.buildCortexAiModelFallbackChain=r.buildCortexAiModelFallbackChain;exports.buildCortexAiRoutingPolicy=r.buildCortexAiRoutingPolicy;exports.isOpenRouterRateLimitError=r.isOpenRouterRateLimitError;exports.isOpenRouterRecoverableRoutingError=r.isOpenRouterRecoverableRoutingError;exports.omitUnsupportedCortexAiModelOptions=r.omitUnsupportedCortexAiModelOptions;exports.runWithCortexAiModelFallback=r.runWithCortexAiModelFallback;exports.summarizeCortexAiRoutingError=r.summarizeCortexAiRoutingError;exports.listCortexAiCompatibleOpenRouterModels=g.listCortexAiCompatibleOpenRouterModels;exports.createCortexAiOpenRouterClient=A;exports.createCortexAiOpenRouterProvider=E;exports.generateCortexAiText=v;exports.getStoredCortexAiModelSelection=O;exports.resolveCortexAiOpenRouterCredential=p;
|
package/lib/ai-client.es.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { createOpenAICompatible as s } from "@ai-sdk/openai-compatible";
|
|
2
2
|
import { generateText as d } from "ai";
|
|
3
|
-
import { CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY as R, getOpenRouterEnvApiKey as
|
|
4
|
-
import { CORTEX_AI_OPENROUTER_BASE_URL as _, buildCortexAiRoutingPolicy as A, runWithCortexAiModelFallback as
|
|
3
|
+
import { CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY as R, getOpenRouterEnvApiKey as p, CORTEX_AI_PACKAGE_NAME as E, CORTEX_AI_OPENROUTER_SETTING_KEY as m, decryptStoredOpenRouterApiKey as O } from "./ai-config.es.js";
|
|
4
|
+
import { CORTEX_AI_OPENROUTER_BASE_URL as _, buildCortexAiRoutingPolicy as A, runWithCortexAiModelFallback as f, omitUnsupportedCortexAiModelOptions as C, safeParseCortexAiModelSelection as S } from "./ai-model-registry.es.js";
|
|
5
5
|
import { CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY as N, CORTEX_AI_MODEL_REGISTRY as X, CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL as F, CORTEX_AI_REQUIRED_MODEL_PARAMETERS as Y, CortexAiRoutingError as k, buildCortexAiModelFallbackChain as D, isOpenRouterRateLimitError as G, isOpenRouterRecoverableRoutingError as q, summarizeCortexAiRoutingError as B } from "./ai-model-registry.es.js";
|
|
6
|
-
|
|
6
|
+
import { listCortexAiCompatibleOpenRouterModels as $ } from "./ai-model-catalog.es.js";
|
|
7
|
+
const y = "Cortex AI OpenRouter client can only be imported from server-side code.";
|
|
7
8
|
function n() {
|
|
8
9
|
if (!(typeof window > "u"))
|
|
9
|
-
throw new Error(
|
|
10
|
+
throw new Error(y);
|
|
10
11
|
}
|
|
11
12
|
function T() {
|
|
12
13
|
return n(), {
|
|
13
14
|
"HTTP-Referer": process.env.NEXT_PUBLIC_URL?.trim() || "https://nextblock.dev",
|
|
14
|
-
"X-Title":
|
|
15
|
+
"X-Title": E
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
function I(e) {
|
|
@@ -25,19 +26,19 @@ function I(e) {
|
|
|
25
26
|
supportsStructuredOutputs: !0
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
|
-
async function
|
|
29
|
+
async function x() {
|
|
29
30
|
n();
|
|
30
|
-
const { getServiceRoleSupabaseClient: e } = await import("@nextblock-cms/db/server"), t = e(), { data: o, error: r } = await t.from("site_settings").select("value").eq("key",
|
|
31
|
+
const { getServiceRoleSupabaseClient: e } = await import("@nextblock-cms/db/server"), t = e(), { data: o, error: r } = await t.from("site_settings").select("value").eq("key", m).maybeSingle();
|
|
31
32
|
if (r)
|
|
32
33
|
throw new Error(`Failed to load stored Cortex AI OpenRouter key: ${r.message}`);
|
|
33
|
-
return o?.value ?
|
|
34
|
+
return o?.value ? O(o.value) : null;
|
|
34
35
|
}
|
|
35
|
-
async function
|
|
36
|
+
async function K() {
|
|
36
37
|
n();
|
|
37
38
|
const { getServiceRoleSupabaseClient: e } = await import("@nextblock-cms/db/server"), t = e(), { data: o, error: r } = await t.from("site_settings").select("value").eq("key", R).maybeSingle();
|
|
38
39
|
if (r)
|
|
39
40
|
throw new Error(`Failed to load Cortex AI OpenRouter model selection: ${r.message}`);
|
|
40
|
-
return
|
|
41
|
+
return S(o?.value);
|
|
41
42
|
}
|
|
42
43
|
async function g(e) {
|
|
43
44
|
n();
|
|
@@ -47,13 +48,13 @@ async function g(e) {
|
|
|
47
48
|
apiKey: t,
|
|
48
49
|
source: "manual"
|
|
49
50
|
};
|
|
50
|
-
const o = await
|
|
51
|
+
const o = await x();
|
|
51
52
|
if (o)
|
|
52
53
|
return {
|
|
53
54
|
apiKey: o,
|
|
54
55
|
source: "stored"
|
|
55
56
|
};
|
|
56
|
-
const r =
|
|
57
|
+
const r = p();
|
|
57
58
|
return r ? {
|
|
58
59
|
apiKey: r,
|
|
59
60
|
source: "env"
|
|
@@ -74,7 +75,7 @@ async function v(e) {
|
|
|
74
75
|
const o = I({
|
|
75
76
|
apiKey: t.apiKey,
|
|
76
77
|
fetch: e?.fetch
|
|
77
|
-
}), r = e?.modelSelection !== void 0 ? e.modelSelection : t.source === "stored" ? await
|
|
78
|
+
}), r = e?.modelSelection !== void 0 ? e.modelSelection : t.source === "stored" ? await K() : null;
|
|
78
79
|
return {
|
|
79
80
|
credentialSource: t.source,
|
|
80
81
|
model: (i) => o.chatModel(i || "openrouter/free"),
|
|
@@ -93,10 +94,10 @@ async function P({
|
|
|
93
94
|
fallbackModelIds: t,
|
|
94
95
|
requestedModelId: o,
|
|
95
96
|
selectedModel: i.modelSelection
|
|
96
|
-
}), a = await
|
|
97
|
+
}), a = await f({
|
|
97
98
|
modelIds: l.modelIds,
|
|
98
99
|
execute: (c) => {
|
|
99
|
-
const u =
|
|
100
|
+
const u = C(
|
|
100
101
|
{
|
|
101
102
|
...r,
|
|
102
103
|
maxRetries: 0
|
|
@@ -131,11 +132,12 @@ export {
|
|
|
131
132
|
v as createCortexAiOpenRouterClient,
|
|
132
133
|
I as createCortexAiOpenRouterProvider,
|
|
133
134
|
P as generateCortexAiText,
|
|
134
|
-
|
|
135
|
+
K as getStoredCortexAiModelSelection,
|
|
135
136
|
G as isOpenRouterRateLimitError,
|
|
136
137
|
q as isOpenRouterRecoverableRoutingError,
|
|
137
|
-
|
|
138
|
+
$ as listCortexAiCompatibleOpenRouterModels,
|
|
139
|
+
C as omitUnsupportedCortexAiModelOptions,
|
|
138
140
|
g as resolveCortexAiOpenRouterCredential,
|
|
139
|
-
|
|
141
|
+
f as runWithCortexAiModelFallback,
|
|
140
142
|
B as summarizeCortexAiRoutingError
|
|
141
143
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("ai"),d=require("./ai-model-registry.cjs.js");require("./zod-config.cjs.js");const u=require("zod"),y="Cortex AI SEO metadata generation can only be imported from server-side code.";function O(){if(!(typeof window>"u"))throw new Error(y)}const g=u.z.strictObject({metaDescription:u.z.string().trim().min(1),metaTitle:u.z.string().trim().min(1),ogDescription:u.z.string().trim().min(1),ogTitle:u.z.string().trim().min(1)}),l={metaDescription:160,metaTitle:60,ogDescription:200,ogTitle:88},T=6e3,A=6e4,b=/[\s.,;:!?‐-―\-/\\|&+*_"'([{·•]+$/;function c(e,t){const n=e.trim();if(t<=0)return"";if(n.length<=t)return n;const o=n.slice(0,t),i=o.search(/\s\S*$/);return(i>0?o.slice(0,i):o).replace(b,"").trim()}function f(e){const t=e.replace(/```[a-zA-Z0-9]*/g,""),n=t.indexOf("{");if(n===-1)return null;let o=0,i=!1,r=!1;for(let s=n;s<t.length;s++){const a=t[s];if(i){r?r=!1:a==="\\"?r=!0:a==='"'&&(i=!1);continue}if(a==='"'){i=!0;continue}if(a==="{"){o++;continue}if(a==="}"&&(o--,o===0))return t.slice(n,s+1)}return null}function _(){const e=l;return["You are NextBlock Cortex AI, an SEO metadata writer for a content management system.","Return ONLY a single JSON object. No markdown fences, no commentary, no explanation, no trailing prose.",'The object must have exactly these four keys, all strings, all non-empty: "metaDescription", "metaTitle", "ogDescription", "ogTitle".',"Do not add any other key.",`metaTitle must be at most ${e.metaTitle} characters and read as a search-result headline for this specific page.`,`metaDescription must be at most ${e.metaDescription} characters, summarise what the page actually delivers, and end as a complete thought.`,`ogTitle must be at most ${e.ogTitle} characters and may be slightly more conversational than metaTitle, because it is read on a social card rather than in a results list.`,`ogDescription must be at most ${e.ogDescription} characters and should invite a click without over-promising.`,"Write plain text. No emoji, no surrounding quotation marks, no HTML, no markdown.","Describe only what the supplied content actually contains. Never invent statistics, prices, dates, awards, or claims that are not in the content.","Never keyword-stuff, never repeat the focus keyword more than twice across all four fields, and never pad a field to reach its character budget."].join(" ")}function w(e){return["Write SEO metadata for the following page.",e.title?`Page title: ${e.title}`:null,e.siteTitle?`Site name: ${e.siteTitle}. Do not append the site name to metaTitle; the site appends it separately.`:null,e.focusKeyword?`Focus keyword: ${e.focusKeyword}. Use it naturally in metaTitle and metaDescription, at most once each.`:null,e.locale?`Write every field in this locale: ${e.locale}. Match its conventions for capitalisation and punctuation.`:null,`Page content:
|
|
2
|
+
${e.content}`].filter(Boolean).join(`
|
|
3
|
+
|
|
4
|
+
`)}function D(e){const t=f(e);if(!t)throw new Error("Cortex AI returned no JSON object for the SEO metadata request.");let n;try{n=JSON.parse(t)}catch(i){throw new Error(`Cortex AI returned invalid JSON for the SEO metadata request: ${i instanceof Error?i.message:String(i)}`)}const o=g.parse(n);return{metaDescription:c(o.metaDescription,l.metaDescription),metaTitle:c(o.metaTitle,l.metaTitle),ogDescription:c(o.ogDescription,l.ogDescription),ogTitle:c(o.ogTitle,l.ogTitle)}}function v(e){const t=d.getHttpStatusCode(e);if(t===401||t===402||t===403)return!1;if(d.isOpenRouterRecoverableRoutingError(e)||t&&t>=500)return!0;const n=e instanceof Error?e.message:String(e);return/NoContentGenerated|No content generated|Provider returned error|no JSON object|invalid JSON|invalid_type|too_small|unrecognized_keys|Invalid input|aborted|abort|timeout|timed out/i.test(n)}async function x(e){O();const t=c(e.content,T);if(!t)throw new Error("Cortex AI SEO metadata generation requires non-empty page content.");const{createCortexAiOpenRouterClient:n}=await Promise.resolve().then(()=>require("./ai-client.cjs.js")),o=await n({apiKey:e.apiKey||void 0}),i=d.buildCortexAiRoutingPolicy({credentialSource:o.credentialSource,requestedModelId:e.modelId,selectedModel:o.modelSelection}),r=await d.runWithCortexAiModelFallback({modelIds:i.modelIds,shouldRetry:v,execute:async s=>{const a=new AbortController,p=setTimeout(()=>a.abort(),A),m=()=>a.abort();e.abortSignal?.addEventListener("abort",m,{once:!0}),e.abortSignal?.aborted&&a.abort();try{const S=d.omitUnsupportedCortexAiModelOptions({abortSignal:a.signal,maxOutputTokens:700,maxRetries:0,prompt:w({content:t,focusKeyword:e.focusKeyword?.trim()||null,locale:e.locale?.trim()||null,siteTitle:e.siteTitle?.trim()||null,title:e.title?.trim()||null}),system:_(),temperature:.3},{modelId:s,modelSelection:i.modelSelection}),h=await E.generateText({...S,model:o.model(s)});return D(h.text)}finally{clearTimeout(p),e.abortSignal?.removeEventListener("abort",m)}}});return{attempts:r.attempts.length,credentialSource:o.credentialSource,metaDescription:r.result.metaDescription,metaTitle:r.result.metaTitle,modelId:r.modelId,ogDescription:r.result.ogDescription,ogTitle:r.result.ogTitle}}exports.CORTEX_AI_SEO_METADATA_CONTENT_BUDGET=T;exports.CORTEX_AI_SEO_METADATA_LENGTH_BUDGETS=l;exports.cortexAiSeoMetadataOutputSchema=g;exports.extractJsonObject=f;exports.generateCortexAiSeoMetadata=x;exports.truncateOnWordBoundary=c;
|