@nextblock-cms/cortex 0.13.1 → 0.13.2
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.es.js +149 -127
- package/lib/ai-config.cjs.js +1 -1
- package/lib/ai-config.d.ts +37 -0
- package/lib/ai-config.es.js +91 -40
- package/lib/ai-global-agent-db-tools.d.ts +8 -8
- package/lib/ai-global-agent-tools.cjs.js +2 -2
- package/lib/ai-global-agent-tools.d.ts +398 -4
- package/lib/ai-global-agent-tools.es.js +2224 -1453
- package/package.json +4 -4
package/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./lib/ai-block-generation.cjs.js"),n=require("./lib/ai-client.cjs.js"),r=require("./lib/ai-config.cjs.js"),C=require("./lib/ai-cortex-widget-builder.cjs.js"),a=require("./lib/ai-global-agent-custom-block-tools.cjs.js"),i=require("./lib/ai-global-agent-db-tools.cjs.js"),e=require("./lib/ai-global-agent-tools.cjs.js"),c=require("./lib/ai-key-crypto.cjs.js"),m=require("./lib/ai-model-catalog.cjs.js"),t=require("./lib/ai-model-registry.cjs.js"),l=require("./lib/cortex-widget-registry.cjs.js"),o=require("./lib/cortex-widget-schema.cjs.js");require("./lib/zod-config.cjs.js");const d=require("zod");exports.INLINE_HTML_ASSISTANT_SYSTEM_PROMPT=u.INLINE_HTML_ASSISTANT_SYSTEM_PROMPT;exports.generateEditorBlocksRequestSchema=u.generateEditorBlocksRequestSchema;exports.generateEditorHtmlFragment=u.generateEditorHtmlFragment;exports.validateGeneratedEditorHtmlFragment=u.validateGeneratedEditorHtmlFragment;exports.createCortexAiOpenRouterClient=n.createCortexAiOpenRouterClient;exports.createCortexAiOpenRouterProvider=n.createCortexAiOpenRouterProvider;exports.generateCortexAiText=n.generateCortexAiText;exports.getStoredCortexAiModelSelection=n.getStoredCortexAiModelSelection;exports.resolveCortexAiOpenRouterCredential=n.resolveCortexAiOpenRouterCredential;exports.CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY=r.CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY;exports.CORTEX_AI_OPENROUTER_SETTING_KEY=r.CORTEX_AI_OPENROUTER_SETTING_KEY;exports.CORTEX_AI_PACKAGE_ID=r.CORTEX_AI_PACKAGE_ID;exports.CORTEX_AI_PACKAGE_NAME=r.CORTEX_AI_PACKAGE_NAME;exports.decryptStoredOpenRouterApiKey=r.decryptStoredOpenRouterApiKey;exports.encryptStoredOpenRouterApiKey=r.encryptStoredOpenRouterApiKey;exports.getCortexAiEnvConfig=r.getCortexAiEnvConfig;exports.getEnvOpenRouterKeyStatus=r.getEnvOpenRouterKeyStatus;exports.getOpenRouterEnvApiKey=r.getOpenRouterEnvApiKey;exports.getStoredOpenRouterKeyStatus=r.getStoredOpenRouterKeyStatus;exports.generateCortexWidgetDefinition=C.generateCortexWidgetDefinition;exports.createCortexCustomBlockTools=a.createCortexCustomBlockTools;exports.createCustomBlockInputSchema=a.createCustomBlockInputSchema;exports.deleteCustomBlockInputSchema=a.deleteCustomBlockInputSchema;exports.executeCreateCustomBlock=a.executeCreateCustomBlock;exports.executeDeleteCustomBlock=a.executeDeleteCustomBlock;exports.executeListCustomBlocks=a.executeListCustomBlocks;exports.executeUpdateCustomBlock=a.executeUpdateCustomBlock;exports.listCustomBlocksInputSchema=a.listCustomBlocksInputSchema;exports.updateCustomBlockInputSchema=a.updateCustomBlockInputSchema;exports.createCortexDatabaseAgentTools=i.createCortexDatabaseAgentTools;exports.describeDatabaseSchemaInputSchema=i.describeDatabaseSchemaInputSchema;exports.executeDatabaseActionPlan=i.executeDatabaseActionPlan;exports.executeDatabaseActionPlanInputSchema=i.executeDatabaseActionPlanInputSchema;exports.executeDatabaseMutation=i.executeDatabaseMutation;exports.executeDatabaseMutationInputSchema=i.executeDatabaseMutationInputSchema;exports.executeDescribeDatabaseSchema=i.executeDescribeDatabaseSchema;exports.executeReadDatabaseRecords=i.executeReadDatabaseRecords;exports.readDatabaseRecordsInputSchema=i.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.executeInsertContentBlock=e.executeInsertContentBlock;exports.executePrepareDeleteCmsItem=e.executePrepareDeleteCmsItem;exports.executeReadCurrentCmsItem=e.executeReadCurrentCmsItem;exports.executeSearchDocumentation=e.executeSearchDocumentation;exports.executeSearchDocumentationWithTimeout=e.executeSearchDocumentationWithTimeout;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.insertContentBlockInputSchema=e.insertContentBlockInputSchema;exports.navigationItemInputSchema=e.navigationItemInputSchema;exports.prepareDeleteCmsItemInputSchema=e.prepareDeleteCmsItemInputSchema;exports.readCurrentCmsItemInputSchema=e.readCurrentCmsItemInputSchema;exports.searchDocumentationInputSchema=e.searchDocumentationInputSchema;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=c.CORTEX_AI_KEY_ALGORITHM;exports.CORTEX_AI_KEY_ENVELOPE_VERSION=c.CORTEX_AI_KEY_ENVELOPE_VERSION;exports.decryptOpenRouterApiKey=c.decryptOpenRouterApiKey;exports.encryptOpenRouterApiKey=c.encryptOpenRouterApiKey;exports.getMaskedOpenRouterKey=c.getMaskedOpenRouterKey;exports.getOpenRouterKeyEnvelopeStatus=c.getOpenRouterKeyEnvelopeStatus;exports.listCortexAiCompatibleOpenRouterModels=m.listCortexAiCompatibleOpenRouterModels;exports.CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY=t.CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY;exports.CORTEX_AI_MODEL_REGISTRY=t.CORTEX_AI_MODEL_REGISTRY;exports.CORTEX_AI_OPENROUTER_BASE_URL=t.CORTEX_AI_OPENROUTER_BASE_URL;exports.CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL=t.CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL;exports.CORTEX_AI_REQUIRED_MODEL_PARAMETERS=t.CORTEX_AI_REQUIRED_MODEL_PARAMETERS;exports.CortexAiRoutingError=t.CortexAiRoutingError;exports.buildCortexAiModelFallbackChain=t.buildCortexAiModelFallbackChain;exports.buildCortexAiRoutingPolicy=t.buildCortexAiRoutingPolicy;exports.createCortexAiStoredModelSelection=t.createCortexAiStoredModelSelection;exports.filterCortexAiCompatibleOpenRouterModels=t.filterCortexAiCompatibleOpenRouterModels;exports.getHttpStatusCode=t.getHttpStatusCode;exports.isCortexAiFreeModelId=t.isCortexAiFreeModelId;exports.isOpenRouterRateLimitError=t.isOpenRouterRateLimitError;exports.isOpenRouterRecoverableRoutingError=t.isOpenRouterRecoverableRoutingError;exports.omitUnsupportedCortexAiModelOptions=t.omitUnsupportedCortexAiModelOptions;exports.runWithCortexAiModelFallback=t.runWithCortexAiModelFallback;exports.safeParseCortexAiModelSelection=t.safeParseCortexAiModelSelection;exports.summarizeCortexAiRoutingError=t.summarizeCortexAiRoutingError;exports.CORTEX_WIDGET_DEFINITION_SELECT=l.CORTEX_WIDGET_DEFINITION_SELECT;exports.CortexWidgetRegistryInsertError=l.CortexWidgetRegistryInsertError;exports.buildCortexWidgetDefinitionInsertPayload=l.buildCortexWidgetDefinitionInsertPayload;exports.insertCortexWidgetDefinition=l.insertCortexWidgetDefinition;exports.CORTEX_WIDGET_ALLOWED_RELATION_TABLES=o.CORTEX_WIDGET_ALLOWED_RELATION_TABLES;exports.buildCortexProfileCardVerificationDefinition=o.buildCortexProfileCardVerificationDefinition;exports.buildCortexWidgetBuilderPrompt=o.buildCortexWidgetBuilderPrompt;exports.buildCortexWidgetBuilderSystemPrompt=o.buildCortexWidgetBuilderSystemPrompt;exports.cortexWidgetBuildRequestSchema=o.cortexWidgetBuildRequestSchema;exports.cortexWidgetDbRelationFieldSchema=o.cortexWidgetDbRelationFieldSchema;exports.cortexWidgetDefinitionSchema=o.cortexWidgetDefinitionSchema;exports.cortexWidgetFieldSchema=o.cortexWidgetFieldSchema;exports.cortexWidgetImageR2FieldSchema=o.cortexWidgetImageR2FieldSchema;exports.cortexWidgetLayoutNodeSchema=o.cortexWidgetLayoutNodeSchema;exports.cortexWidgetRichTextFieldSchema=o.cortexWidgetRichTextFieldSchema;exports.cortexWidgetTextFieldSchema=o.cortexWidgetTextFieldSchema;exports.validateCortexWidgetDefinitionOutput=o.validateCortexWidgetDefinitionOutput;Object.defineProperty(exports,"z",{enumerable:!0,get:()=>d.z});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./lib/ai-block-generation.cjs.js"),n=require("./lib/ai-client.cjs.js"),t=require("./lib/ai-config.cjs.js"),l=require("./lib/ai-cortex-widget-builder.cjs.js"),a=require("./lib/ai-global-agent-custom-block-tools.cjs.js"),i=require("./lib/ai-global-agent-db-tools.cjs.js"),e=require("./lib/ai-global-agent-tools.cjs.js"),c=require("./lib/ai-key-crypto.cjs.js"),s=require("./lib/ai-model-catalog.cjs.js"),o=require("./lib/ai-model-registry.cjs.js"),C=require("./lib/cortex-widget-registry.cjs.js"),r=require("./lib/cortex-widget-schema.cjs.js");require("./lib/zod-config.cjs.js");const m=require("zod");exports.INLINE_HTML_ASSISTANT_SYSTEM_PROMPT=u.INLINE_HTML_ASSISTANT_SYSTEM_PROMPT;exports.generateEditorBlocksRequestSchema=u.generateEditorBlocksRequestSchema;exports.generateEditorHtmlFragment=u.generateEditorHtmlFragment;exports.validateGeneratedEditorHtmlFragment=u.validateGeneratedEditorHtmlFragment;exports.createCortexAiOpenRouterClient=n.createCortexAiOpenRouterClient;exports.createCortexAiOpenRouterProvider=n.createCortexAiOpenRouterProvider;exports.generateCortexAiText=n.generateCortexAiText;exports.getStoredCortexAiModelSelection=n.getStoredCortexAiModelSelection;exports.resolveCortexAiOpenRouterCredential=n.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=a.createCortexCustomBlockTools;exports.createCustomBlockInputSchema=a.createCustomBlockInputSchema;exports.deleteCustomBlockInputSchema=a.deleteCustomBlockInputSchema;exports.executeCreateCustomBlock=a.executeCreateCustomBlock;exports.executeDeleteCustomBlock=a.executeDeleteCustomBlock;exports.executeListCustomBlocks=a.executeListCustomBlocks;exports.executeUpdateCustomBlock=a.executeUpdateCustomBlock;exports.listCustomBlocksInputSchema=a.listCustomBlocksInputSchema;exports.updateCustomBlockInputSchema=a.updateCustomBlockInputSchema;exports.createCortexDatabaseAgentTools=i.createCortexDatabaseAgentTools;exports.describeDatabaseSchemaInputSchema=i.describeDatabaseSchemaInputSchema;exports.executeDatabaseActionPlan=i.executeDatabaseActionPlan;exports.executeDatabaseActionPlanInputSchema=i.executeDatabaseActionPlanInputSchema;exports.executeDatabaseMutation=i.executeDatabaseMutation;exports.executeDatabaseMutationInputSchema=i.executeDatabaseMutationInputSchema;exports.executeDescribeDatabaseSchema=i.executeDescribeDatabaseSchema;exports.executeReadDatabaseRecords=i.executeReadDatabaseRecords;exports.readDatabaseRecordsInputSchema=i.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.executePrepareDeleteCmsItem=e.executePrepareDeleteCmsItem;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.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.maybeTriggerStockPhotoDownloads=e.maybeTriggerStockPhotoDownloads;exports.navigationItemInputSchema=e.navigationItemInputSchema;exports.prepareDeleteCmsItemInputSchema=e.prepareDeleteCmsItemInputSchema;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.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=c.CORTEX_AI_KEY_ALGORITHM;exports.CORTEX_AI_KEY_ENVELOPE_VERSION=c.CORTEX_AI_KEY_ENVELOPE_VERSION;exports.decryptOpenRouterApiKey=c.decryptOpenRouterApiKey;exports.encryptOpenRouterApiKey=c.encryptOpenRouterApiKey;exports.getMaskedOpenRouterKey=c.getMaskedOpenRouterKey;exports.getOpenRouterKeyEnvelopeStatus=c.getOpenRouterKeyEnvelopeStatus;exports.listCortexAiCompatibleOpenRouterModels=s.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=C.CORTEX_WIDGET_DEFINITION_SELECT;exports.CortexWidgetRegistryInsertError=C.CortexWidgetRegistryInsertError;exports.buildCortexWidgetDefinitionInsertPayload=C.buildCortexWidgetDefinitionInsertPayload;exports.insertCortexWidgetDefinition=C.insertCortexWidgetDefinition;exports.CORTEX_WIDGET_ALLOWED_RELATION_TABLES=r.CORTEX_WIDGET_ALLOWED_RELATION_TABLES;exports.buildCortexProfileCardVerificationDefinition=r.buildCortexProfileCardVerificationDefinition;exports.buildCortexWidgetBuilderPrompt=r.buildCortexWidgetBuilderPrompt;exports.buildCortexWidgetBuilderSystemPrompt=r.buildCortexWidgetBuilderSystemPrompt;exports.cortexWidgetBuildRequestSchema=r.cortexWidgetBuildRequestSchema;exports.cortexWidgetDbRelationFieldSchema=r.cortexWidgetDbRelationFieldSchema;exports.cortexWidgetDefinitionSchema=r.cortexWidgetDefinitionSchema;exports.cortexWidgetFieldSchema=r.cortexWidgetFieldSchema;exports.cortexWidgetImageR2FieldSchema=r.cortexWidgetImageR2FieldSchema;exports.cortexWidgetLayoutNodeSchema=r.cortexWidgetLayoutNodeSchema;exports.cortexWidgetRichTextFieldSchema=r.cortexWidgetRichTextFieldSchema;exports.cortexWidgetTextFieldSchema=r.cortexWidgetTextFieldSchema;exports.validateCortexWidgetDefinitionOutput=r.validateCortexWidgetDefinitionOutput;Object.defineProperty(exports,"z",{enumerable:!0,get:()=>m.z});
|
package/index.es.js
CHANGED
|
@@ -1,135 +1,157 @@
|
|
|
1
|
-
import { INLINE_HTML_ASSISTANT_SYSTEM_PROMPT as r, generateEditorBlocksRequestSchema as a, generateEditorHtmlFragment as
|
|
2
|
-
import { createCortexAiOpenRouterClient as u, createCortexAiOpenRouterProvider as m, generateCortexAiText as C, getStoredCortexAiModelSelection as
|
|
3
|
-
import {
|
|
4
|
-
import { generateCortexWidgetDefinition as
|
|
5
|
-
import { createCortexCustomBlockTools as
|
|
6
|
-
import { createCortexDatabaseAgentTools as
|
|
7
|
-
import { availableCortexAiBlockTypes as
|
|
8
|
-
import { CORTEX_AI_KEY_ALGORITHM as
|
|
9
|
-
import { listCortexAiCompatibleOpenRouterModels as
|
|
10
|
-
import { CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY as
|
|
11
|
-
import { CORTEX_WIDGET_DEFINITION_SELECT as
|
|
12
|
-
import { CORTEX_WIDGET_ALLOWED_RELATION_TABLES as
|
|
1
|
+
import { INLINE_HTML_ASSISTANT_SYSTEM_PROMPT as r, generateEditorBlocksRequestSchema as a, generateEditorHtmlFragment as c, validateGeneratedEditorHtmlFragment as i } from "./lib/ai-block-generation.es.js";
|
|
2
|
+
import { createCortexAiOpenRouterClient as u, createCortexAiOpenRouterProvider as m, generateCortexAiText as C, getStoredCortexAiModelSelection as l, resolveCortexAiOpenRouterCredential as E } from "./lib/ai-client.es.js";
|
|
3
|
+
import { CORTEX_AI_AGENT_SETTINGS_BOUNDS as p, CORTEX_AI_AGENT_SETTINGS_DEFAULTS as s, CORTEX_AI_AGENT_SETTINGS_KEY as d, CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY as x, CORTEX_AI_OPENROUTER_SETTING_KEY as I, CORTEX_AI_PACKAGE_ID as _, CORTEX_AI_PACKAGE_NAME as A, CORTEX_AI_PEXELS_SETTING_KEY as R, CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY as T, CORTEX_AI_UNSPLASH_SETTING_KEY as h, decryptStoredOpenRouterApiKey as O, encryptStoredOpenRouterApiKey as g, getCortexAiEnvConfig as P, getEnvOpenRouterKeyStatus as D, getOpenRouterEnvApiKey as N, getPexelsEnvApiKey as b, getStoredOpenRouterKeyStatus as f, getUnsplashEnvApiKey as B, normalizeCortexAiAgentSettings as k, resolveCortexAiAgentSettings as L } from "./lib/ai-config.es.js";
|
|
4
|
+
import { generateCortexWidgetDefinition as F } from "./lib/ai-cortex-widget-builder.es.js";
|
|
5
|
+
import { createCortexCustomBlockTools as K, createCustomBlockInputSchema as U, deleteCustomBlockInputSchema as v, executeCreateCustomBlock as G, executeDeleteCustomBlock as W, executeListCustomBlocks as X, executeUpdateCustomBlock as Y, listCustomBlocksInputSchema as H, updateCustomBlockInputSchema as V } from "./lib/ai-global-agent-custom-block-tools.es.js";
|
|
6
|
+
import { createCortexDatabaseAgentTools as z, describeDatabaseSchemaInputSchema as q, executeDatabaseActionPlan as Q, executeDatabaseActionPlanInputSchema as j, 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 ce, createCmsPageInputSchema as ie, createCmsPostInputSchema as ne, createCmsProductInputSchema as ue, createCortexGlobalAgentTools as me, deleteCmsItemInputSchema as Ce, executeCmsActionPlan as le, executeCmsActionPlanInputSchema as Ee, executeCreateCmsPage as Se, executeCreateCmsPost as pe, executeCreateCmsProduct as se, executeDeleteCmsItem as de, executeFetchEcommerceStats as xe, executeFetchUrlContent as Ie, executeInsertContentBlock as _e, executePrepareDeleteCmsItem as Ae, executeReadCurrentCmsItem as Re, executeRewritePageDraft as Te, executeSearchDocumentation as he, executeSearchDocumentationWithTimeout as Oe, executeSearchStockPhotos as ge, executeSetContentImages as Pe, executeTranslatePage as De, executeUpdateCmsItemField as Ne, executeUpdateContentBlock as be, executeUpdateCurrentCmsFields as fe, executeUpdateFooter as Be, executeUpdateNavigationBar as ke, executeUpdateSectionColumnBlock as Le, fetchEcommerceStatsInputSchema as Me, fetchUrlContentInputSchema as Fe, insertContentBlockInputSchema as ye, maybeTriggerStockPhotoDownloads as Ke, navigationItemInputSchema as Ue, prepareDeleteCmsItemInputSchema as ve, readCurrentCmsItemInputSchema as Ge, resolveCortexAiStockPhotoProvider as We, resolveCortexAiStockPhotoProviders as Xe, rewritePageDraftInputSchema as Ye, searchDocumentationInputSchema as He, searchStockPhotosInputSchema as Ve, translatePageInputSchema as we, updateCmsItemFieldInputSchema as ze, updateContentBlockInputSchema as qe, updateCurrentCmsFieldsInputSchema as Qe, updateFooterInputSchema as je, updateNavigationBarInputSchema as Je, updateSectionColumnBlockInputSchema as Ze } from "./lib/ai-global-agent-tools.es.js";
|
|
8
|
+
import { CORTEX_AI_KEY_ALGORITHM as et, CORTEX_AI_KEY_ENVELOPE_VERSION as tt, decryptOpenRouterApiKey as ot, encryptOpenRouterApiKey as rt, getMaskedOpenRouterKey as at, getOpenRouterKeyEnvelopeStatus as ct } from "./lib/ai-key-crypto.es.js";
|
|
9
|
+
import { listCortexAiCompatibleOpenRouterModels as nt } from "./lib/ai-model-catalog.es.js";
|
|
10
|
+
import { CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY as mt, CORTEX_AI_MODEL_REGISTRY as Ct, CORTEX_AI_OPENROUTER_BASE_URL as lt, CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL as Et, CORTEX_AI_REQUIRED_MODEL_PARAMETERS as St, CortexAiRoutingError as pt, buildCortexAiModelFallbackChain as st, buildCortexAiRoutingPolicy as dt, createCortexAiStoredModelSelection as xt, filterCortexAiCompatibleOpenRouterModels as It, getHttpStatusCode as _t, isCortexAiFreeModelId as At, isOpenRouterRateLimitError as Rt, isOpenRouterRecoverableRoutingError as Tt, omitUnsupportedCortexAiModelOptions as ht, runWithCortexAiModelFallback as Ot, safeParseCortexAiModelSelection as gt, summarizeCortexAiRoutingError as Pt } from "./lib/ai-model-registry.es.js";
|
|
11
|
+
import { CORTEX_WIDGET_DEFINITION_SELECT as Nt, CortexWidgetRegistryInsertError as bt, buildCortexWidgetDefinitionInsertPayload as ft, insertCortexWidgetDefinition as Bt } from "./lib/cortex-widget-registry.es.js";
|
|
12
|
+
import { CORTEX_WIDGET_ALLOWED_RELATION_TABLES as Lt, buildCortexProfileCardVerificationDefinition as Mt, buildCortexWidgetBuilderPrompt as Ft, buildCortexWidgetBuilderSystemPrompt as yt, cortexWidgetBuildRequestSchema as Kt, cortexWidgetDbRelationFieldSchema as Ut, cortexWidgetDefinitionSchema as vt, cortexWidgetFieldSchema as Gt, cortexWidgetImageR2FieldSchema as Wt, cortexWidgetLayoutNodeSchema as Xt, cortexWidgetRichTextFieldSchema as Yt, cortexWidgetTextFieldSchema as Ht, validateCortexWidgetDefinitionOutput as Vt } from "./lib/cortex-widget-schema.es.js";
|
|
13
13
|
import "./lib/zod-config.es.js";
|
|
14
|
-
import { z as
|
|
14
|
+
import { z as zt } from "zod";
|
|
15
15
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
p as CORTEX_AI_AGENT_SETTINGS_BOUNDS,
|
|
17
|
+
s as CORTEX_AI_AGENT_SETTINGS_DEFAULTS,
|
|
18
|
+
d as CORTEX_AI_AGENT_SETTINGS_KEY,
|
|
19
|
+
mt as CORTEX_AI_FREE_MODEL_FALLBACK_REGISTRY,
|
|
20
|
+
et as CORTEX_AI_KEY_ALGORITHM,
|
|
21
|
+
tt as CORTEX_AI_KEY_ENVELOPE_VERSION,
|
|
22
|
+
Ct as CORTEX_AI_MODEL_REGISTRY,
|
|
23
|
+
lt as CORTEX_AI_OPENROUTER_BASE_URL,
|
|
24
|
+
Et as CORTEX_AI_OPENROUTER_FREE_ROUTER_MODEL,
|
|
25
|
+
x as CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY,
|
|
26
|
+
I as CORTEX_AI_OPENROUTER_SETTING_KEY,
|
|
27
|
+
_ as CORTEX_AI_PACKAGE_ID,
|
|
28
|
+
A as CORTEX_AI_PACKAGE_NAME,
|
|
29
|
+
R as CORTEX_AI_PEXELS_SETTING_KEY,
|
|
30
|
+
St as CORTEX_AI_REQUIRED_MODEL_PARAMETERS,
|
|
31
|
+
T as CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY,
|
|
32
|
+
h as CORTEX_AI_UNSPLASH_SETTING_KEY,
|
|
33
|
+
Lt as CORTEX_WIDGET_ALLOWED_RELATION_TABLES,
|
|
34
|
+
Nt as CORTEX_WIDGET_DEFINITION_SELECT,
|
|
35
|
+
pt as CortexAiRoutingError,
|
|
36
|
+
bt as CortexWidgetRegistryInsertError,
|
|
31
37
|
r as INLINE_HTML_ASSISTANT_SYSTEM_PROMPT,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
re as availableCortexAiBlockTypes,
|
|
39
|
+
st as buildCortexAiModelFallbackChain,
|
|
40
|
+
dt as buildCortexAiRoutingPolicy,
|
|
41
|
+
Mt as buildCortexProfileCardVerificationDefinition,
|
|
42
|
+
Ft as buildCortexWidgetBuilderPrompt,
|
|
43
|
+
yt as buildCortexWidgetBuilderSystemPrompt,
|
|
44
|
+
ft as buildCortexWidgetDefinitionInsertPayload,
|
|
45
|
+
ae as buildVisibleContactIntroActionPlan,
|
|
46
|
+
ce as cortexAiPageContextSchema,
|
|
47
|
+
Kt as cortexWidgetBuildRequestSchema,
|
|
48
|
+
Ut as cortexWidgetDbRelationFieldSchema,
|
|
49
|
+
vt as cortexWidgetDefinitionSchema,
|
|
50
|
+
Gt as cortexWidgetFieldSchema,
|
|
51
|
+
Wt as cortexWidgetImageR2FieldSchema,
|
|
52
|
+
Xt as cortexWidgetLayoutNodeSchema,
|
|
53
|
+
Yt as cortexWidgetRichTextFieldSchema,
|
|
54
|
+
Ht as cortexWidgetTextFieldSchema,
|
|
55
|
+
ie as createCmsPageInputSchema,
|
|
56
|
+
ne as createCmsPostInputSchema,
|
|
57
|
+
ue as createCmsProductInputSchema,
|
|
52
58
|
u as createCortexAiOpenRouterClient,
|
|
53
59
|
m as createCortexAiOpenRouterProvider,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
60
|
+
xt as createCortexAiStoredModelSelection,
|
|
61
|
+
K as createCortexCustomBlockTools,
|
|
62
|
+
z as createCortexDatabaseAgentTools,
|
|
63
|
+
me as createCortexGlobalAgentTools,
|
|
64
|
+
U as createCustomBlockInputSchema,
|
|
65
|
+
ot as decryptOpenRouterApiKey,
|
|
66
|
+
O as decryptStoredOpenRouterApiKey,
|
|
67
|
+
Ce as deleteCmsItemInputSchema,
|
|
68
|
+
v as deleteCustomBlockInputSchema,
|
|
69
|
+
q as describeDatabaseSchemaInputSchema,
|
|
70
|
+
rt as encryptOpenRouterApiKey,
|
|
71
|
+
g as encryptStoredOpenRouterApiKey,
|
|
72
|
+
le as executeCmsActionPlan,
|
|
73
|
+
Ee as executeCmsActionPlanInputSchema,
|
|
74
|
+
Se as executeCreateCmsPage,
|
|
75
|
+
pe as executeCreateCmsPost,
|
|
76
|
+
se as executeCreateCmsProduct,
|
|
77
|
+
G as executeCreateCustomBlock,
|
|
78
|
+
Q as executeDatabaseActionPlan,
|
|
79
|
+
j as executeDatabaseActionPlanInputSchema,
|
|
80
|
+
J as executeDatabaseMutation,
|
|
81
|
+
Z as executeDatabaseMutationInputSchema,
|
|
82
|
+
de as executeDeleteCmsItem,
|
|
83
|
+
W as executeDeleteCustomBlock,
|
|
84
|
+
$ as executeDescribeDatabaseSchema,
|
|
85
|
+
xe as executeFetchEcommerceStats,
|
|
86
|
+
Ie as executeFetchUrlContent,
|
|
87
|
+
_e as executeInsertContentBlock,
|
|
88
|
+
X as executeListCustomBlocks,
|
|
89
|
+
Ae as executePrepareDeleteCmsItem,
|
|
90
|
+
Re as executeReadCurrentCmsItem,
|
|
91
|
+
ee as executeReadDatabaseRecords,
|
|
92
|
+
Te as executeRewritePageDraft,
|
|
93
|
+
he as executeSearchDocumentation,
|
|
94
|
+
Oe as executeSearchDocumentationWithTimeout,
|
|
95
|
+
ge as executeSearchStockPhotos,
|
|
96
|
+
Pe as executeSetContentImages,
|
|
97
|
+
De as executeTranslatePage,
|
|
98
|
+
Ne as executeUpdateCmsItemField,
|
|
99
|
+
be as executeUpdateContentBlock,
|
|
100
|
+
fe as executeUpdateCurrentCmsFields,
|
|
101
|
+
Y as executeUpdateCustomBlock,
|
|
102
|
+
Be as executeUpdateFooter,
|
|
103
|
+
ke as executeUpdateNavigationBar,
|
|
104
|
+
Le as executeUpdateSectionColumnBlock,
|
|
105
|
+
Me as fetchEcommerceStatsInputSchema,
|
|
106
|
+
Fe as fetchUrlContentInputSchema,
|
|
107
|
+
It as filterCortexAiCompatibleOpenRouterModels,
|
|
96
108
|
C as generateCortexAiText,
|
|
97
|
-
|
|
109
|
+
F as generateCortexWidgetDefinition,
|
|
98
110
|
a as generateEditorBlocksRequestSchema,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
111
|
+
c as generateEditorHtmlFragment,
|
|
112
|
+
P as getCortexAiEnvConfig,
|
|
113
|
+
D as getEnvOpenRouterKeyStatus,
|
|
114
|
+
_t as getHttpStatusCode,
|
|
115
|
+
at as getMaskedOpenRouterKey,
|
|
116
|
+
N as getOpenRouterEnvApiKey,
|
|
117
|
+
ct as getOpenRouterKeyEnvelopeStatus,
|
|
118
|
+
b as getPexelsEnvApiKey,
|
|
119
|
+
l as getStoredCortexAiModelSelection,
|
|
120
|
+
f as getStoredOpenRouterKeyStatus,
|
|
121
|
+
B as getUnsplashEnvApiKey,
|
|
122
|
+
ye as insertContentBlockInputSchema,
|
|
123
|
+
Bt as insertCortexWidgetDefinition,
|
|
124
|
+
At as isCortexAiFreeModelId,
|
|
125
|
+
Rt as isOpenRouterRateLimitError,
|
|
126
|
+
Tt as isOpenRouterRecoverableRoutingError,
|
|
127
|
+
nt as listCortexAiCompatibleOpenRouterModels,
|
|
128
|
+
H as listCustomBlocksInputSchema,
|
|
129
|
+
Ke as maybeTriggerStockPhotoDownloads,
|
|
130
|
+
Ue as navigationItemInputSchema,
|
|
131
|
+
k as normalizeCortexAiAgentSettings,
|
|
132
|
+
ht as omitUnsupportedCortexAiModelOptions,
|
|
133
|
+
ve as prepareDeleteCmsItemInputSchema,
|
|
134
|
+
Ge as readCurrentCmsItemInputSchema,
|
|
135
|
+
te as readDatabaseRecordsInputSchema,
|
|
136
|
+
L as resolveCortexAiAgentSettings,
|
|
137
|
+
E as resolveCortexAiOpenRouterCredential,
|
|
138
|
+
We as resolveCortexAiStockPhotoProvider,
|
|
139
|
+
Xe as resolveCortexAiStockPhotoProviders,
|
|
140
|
+
Ye as rewritePageDraftInputSchema,
|
|
141
|
+
Ot as runWithCortexAiModelFallback,
|
|
142
|
+
gt as safeParseCortexAiModelSelection,
|
|
143
|
+
He as searchDocumentationInputSchema,
|
|
144
|
+
Ve as searchStockPhotosInputSchema,
|
|
145
|
+
Pt as summarizeCortexAiRoutingError,
|
|
146
|
+
we as translatePageInputSchema,
|
|
147
|
+
ze as updateCmsItemFieldInputSchema,
|
|
148
|
+
qe as updateContentBlockInputSchema,
|
|
149
|
+
Qe as updateCurrentCmsFieldsInputSchema,
|
|
150
|
+
V as updateCustomBlockInputSchema,
|
|
151
|
+
je as updateFooterInputSchema,
|
|
152
|
+
Je as updateNavigationBarInputSchema,
|
|
153
|
+
Ze as updateSectionColumnBlockInputSchema,
|
|
154
|
+
Vt as validateCortexWidgetDefinitionOutput,
|
|
155
|
+
i as validateGeneratedEditorHtmlFragment,
|
|
156
|
+
zt as z
|
|
135
157
|
};
|
package/lib/ai-config.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./ai-key-crypto.cjs.js"),i=require("@nextblock-cms/db/secrets"),O="Cortex AI configuration can only be imported from server-side code.";function o(){if(!(typeof window>"u"))throw new Error(O)}const y="cortex-ai",m="NextBlock Cortex AI",R="cortex_ai_openrouter_api_key",K="cortex_ai_openrouter_model_selection",N="cortex_ai_pexels_api_key",I="cortex_ai_unsplash_access_key",l="cortex_ai_unsplash_app_name",a="cortex_ai_agent_settings",p={maxOutputTokens:16e3,maxSteps:8,responseTimeoutMs:12e4,temperature:.1},T={maxOutputTokens:{max:2e5,min:256},maxSteps:{max:100,min:2},responseTimeoutMs:{max:6e5,min:15e3},temperature:{max:2,min:0}};function s(e,t,n,E){const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Math.min(n,Math.max(t,r)):E}function c(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=T,E=p,r=t.maxOutputTokens;return{maxOutputTokens:r===null||r==="unlimited"||r===""?null:s(r,n.maxOutputTokens.min,n.maxOutputTokens.max,E.maxOutputTokens??16e3),maxSteps:Math.round(s(t.maxSteps,n.maxSteps.min,n.maxSteps.max,E.maxSteps)),responseTimeoutMs:Math.round(s(t.responseTimeoutMs,n.responseTimeoutMs.min,n.responseTimeoutMs.max,E.responseTimeoutMs)),temperature:s(t.temperature,n.temperature.min,n.temperature.max,E.temperature)}}async function x(e){if(e)try{const{data:t}=await e.from("site_settings").select("value").eq("key",a).maybeSingle();if(t?.value)return c(t.value)}catch{}return{...p}}function _(e){return process.env[e]?.trim()||null}function C(){return o(),_("PEXELS_API_KEY")}function d(){return o(),_("UNSPLASH_ACCESS_KEY")}function A(){return o(),_("OPENROUTER_API_KEY")}function S(){o();const e=A();return{encryptionKey:_("CORTEX_AI_ENCRYPTION_KEY"),freemiusSandboxKey:_("FREEMIUS_AI_SANDBOX_KEY"),hasEncryptionKey:i.hasSecretEncryptionKey(),hasOpenRouterEnvKey:!!e,openRouterEnvKeyLast4:e?e.slice(-4):null}}function f(){o();const e=i.resolveSecretEncryptionKey();if(!e)throw new Error("An encryption key (NEXTBLOCK_ENCRYPTION_KEY, CORTEX_AI_ENCRYPTION_KEY, or a Supabase service-role key) is required to manage stored OpenRouter keys.");return e}function g(e){return u.encryptOpenRouterApiKey({apiKey:e,encryptionSecret:f()})}function v(e){o();const t=i.tryDecryptWithEnvKey(e);if(t===null)throw new Error("Failed to decrypt stored OpenRouter key.");return t}function P(e){return u.getOpenRouterKeyEnvelopeStatus(e)}function G(){o();const e=S();return{hasEnvOpenRouterKey:e.hasOpenRouterEnvKey,maskedEnvOpenRouterKey:e.openRouterEnvKeyLast4?u.getMaskedOpenRouterKey(e.openRouterEnvKeyLast4):null}}exports.CORTEX_AI_AGENT_SETTINGS_BOUNDS=T;exports.CORTEX_AI_AGENT_SETTINGS_DEFAULTS=p;exports.CORTEX_AI_AGENT_SETTINGS_KEY=a;exports.CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY=K;exports.CORTEX_AI_OPENROUTER_SETTING_KEY=R;exports.CORTEX_AI_PACKAGE_ID=y;exports.CORTEX_AI_PACKAGE_NAME=m;exports.CORTEX_AI_PEXELS_SETTING_KEY=N;exports.CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY=l;exports.CORTEX_AI_UNSPLASH_SETTING_KEY=I;exports.decryptStoredOpenRouterApiKey=v;exports.encryptStoredOpenRouterApiKey=g;exports.getCortexAiEnvConfig=S;exports.getEnvOpenRouterKeyStatus=G;exports.getOpenRouterEnvApiKey=A;exports.getPexelsEnvApiKey=C;exports.getStoredOpenRouterKeyStatus=P;exports.getUnsplashEnvApiKey=d;exports.normalizeCortexAiAgentSettings=c;exports.resolveCortexAiAgentSettings=x;
|
package/lib/ai-config.d.ts
CHANGED
|
@@ -3,6 +3,43 @@ export declare const CORTEX_AI_PACKAGE_ID = "cortex-ai";
|
|
|
3
3
|
export declare const CORTEX_AI_PACKAGE_NAME = "NextBlock Cortex AI";
|
|
4
4
|
export declare const CORTEX_AI_OPENROUTER_SETTING_KEY = "cortex_ai_openrouter_api_key";
|
|
5
5
|
export declare const CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY = "cortex_ai_openrouter_model_selection";
|
|
6
|
+
export declare const CORTEX_AI_PEXELS_SETTING_KEY = "cortex_ai_pexels_api_key";
|
|
7
|
+
export declare const CORTEX_AI_UNSPLASH_SETTING_KEY = "cortex_ai_unsplash_access_key";
|
|
8
|
+
export declare const CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY = "cortex_ai_unsplash_app_name";
|
|
9
|
+
export declare const CORTEX_AI_AGENT_SETTINGS_KEY = "cortex_ai_agent_settings";
|
|
10
|
+
export type CortexAiAgentSettings = {
|
|
11
|
+
maxOutputTokens: number | null;
|
|
12
|
+
maxSteps: number;
|
|
13
|
+
temperature: number;
|
|
14
|
+
responseTimeoutMs: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const CORTEX_AI_AGENT_SETTINGS_DEFAULTS: CortexAiAgentSettings;
|
|
17
|
+
export declare const CORTEX_AI_AGENT_SETTINGS_BOUNDS: {
|
|
18
|
+
maxOutputTokens: {
|
|
19
|
+
max: number;
|
|
20
|
+
min: number;
|
|
21
|
+
};
|
|
22
|
+
maxSteps: {
|
|
23
|
+
max: number;
|
|
24
|
+
min: number;
|
|
25
|
+
};
|
|
26
|
+
responseTimeoutMs: {
|
|
27
|
+
max: number;
|
|
28
|
+
min: number;
|
|
29
|
+
};
|
|
30
|
+
temperature: {
|
|
31
|
+
max: number;
|
|
32
|
+
min: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/** Merge stored overrides onto the defaults, clamping every value to safe bounds. */
|
|
36
|
+
export declare function normalizeCortexAiAgentSettings(raw: unknown): CortexAiAgentSettings;
|
|
37
|
+
/** Read the admin-tuned agent settings from site_settings, falling back to defaults. */
|
|
38
|
+
export declare function resolveCortexAiAgentSettings(supabase?: {
|
|
39
|
+
from: (table: string) => any;
|
|
40
|
+
} | null): Promise<CortexAiAgentSettings>;
|
|
41
|
+
export declare function getPexelsEnvApiKey(): string | null;
|
|
42
|
+
export declare function getUnsplashEnvApiKey(): string | null;
|
|
6
43
|
export declare function getOpenRouterEnvApiKey(): string | null;
|
|
7
44
|
export declare function getCortexAiEnvConfig(): {
|
|
8
45
|
encryptionKey: string | null;
|
package/lib/ai-config.es.js
CHANGED
|
@@ -1,32 +1,73 @@
|
|
|
1
|
-
import { encryptOpenRouterApiKey as
|
|
2
|
-
import { tryDecryptWithEnvKey as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import { encryptOpenRouterApiKey as a, getMaskedOpenRouterKey as E, getOpenRouterKeyEnvelopeStatus as _ } from "./ai-key-crypto.es.js";
|
|
2
|
+
import { tryDecryptWithEnvKey as c, hasSecretEncryptionKey as m, resolveSecretEncryptionKey as y } from "@nextblock-cms/db/secrets";
|
|
3
|
+
const T = "Cortex AI configuration can only be imported from server-side code.";
|
|
4
|
+
function o() {
|
|
5
5
|
if (!(typeof window > "u"))
|
|
6
|
-
throw new Error(
|
|
6
|
+
throw new Error(T);
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const I = "cortex-ai", d = "NextBlock Cortex AI", C = "cortex_ai_openrouter_api_key", v = "cortex_ai_openrouter_model_selection", g = "cortex_ai_pexels_api_key", k = "cortex_ai_unsplash_access_key", M = "cortex_ai_unsplash_app_name", O = "cortex_ai_agent_settings", p = {
|
|
9
|
+
maxOutputTokens: 16e3,
|
|
10
|
+
maxSteps: 8,
|
|
11
|
+
responseTimeoutMs: 12e4,
|
|
12
|
+
temperature: 0.1
|
|
13
|
+
}, S = {
|
|
14
|
+
maxOutputTokens: { max: 2e5, min: 256 },
|
|
15
|
+
maxSteps: { max: 100, min: 2 },
|
|
16
|
+
responseTimeoutMs: { max: 6e5, min: 15e3 },
|
|
17
|
+
temperature: { max: 2, min: 0 }
|
|
18
|
+
};
|
|
19
|
+
function i(e, t, n, s) {
|
|
20
|
+
const r = typeof e == "number" ? e : Number(e);
|
|
21
|
+
return Number.isFinite(r) ? Math.min(n, Math.max(t, r)) : s;
|
|
22
|
+
}
|
|
23
|
+
function A(e) {
|
|
24
|
+
const t = e && typeof e == "object" && !Array.isArray(e) ? e : {}, n = S, s = p, r = t.maxOutputTokens;
|
|
25
|
+
return {
|
|
26
|
+
maxOutputTokens: r === null || r === "unlimited" || r === "" ? null : i(r, n.maxOutputTokens.min, n.maxOutputTokens.max, s.maxOutputTokens ?? 16e3),
|
|
27
|
+
maxSteps: Math.round(i(t.maxSteps, n.maxSteps.min, n.maxSteps.max, s.maxSteps)),
|
|
28
|
+
responseTimeoutMs: Math.round(
|
|
29
|
+
i(t.responseTimeoutMs, n.responseTimeoutMs.min, n.responseTimeoutMs.max, s.responseTimeoutMs)
|
|
30
|
+
),
|
|
31
|
+
temperature: i(t.temperature, n.temperature.min, n.temperature.max, s.temperature)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function P(e) {
|
|
35
|
+
if (e)
|
|
36
|
+
try {
|
|
37
|
+
const { data: t } = await e.from("site_settings").select("value").eq("key", O).maybeSingle();
|
|
38
|
+
if (t?.value)
|
|
39
|
+
return A(t.value);
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
return { ...p };
|
|
43
|
+
}
|
|
44
|
+
function u(e) {
|
|
10
45
|
return process.env[e]?.trim() || null;
|
|
11
46
|
}
|
|
12
|
-
function
|
|
13
|
-
return
|
|
47
|
+
function h() {
|
|
48
|
+
return o(), u("PEXELS_API_KEY");
|
|
49
|
+
}
|
|
50
|
+
function Y() {
|
|
51
|
+
return o(), u("UNSPLASH_ACCESS_KEY");
|
|
14
52
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
53
|
+
function R() {
|
|
54
|
+
return o(), u("OPENROUTER_API_KEY");
|
|
55
|
+
}
|
|
56
|
+
function x() {
|
|
57
|
+
o();
|
|
58
|
+
const e = R();
|
|
18
59
|
return {
|
|
19
|
-
encryptionKey:
|
|
20
|
-
freemiusSandboxKey:
|
|
60
|
+
encryptionKey: u("CORTEX_AI_ENCRYPTION_KEY"),
|
|
61
|
+
freemiusSandboxKey: u("FREEMIUS_AI_SANDBOX_KEY"),
|
|
21
62
|
// True when ANY usable key exists: an explicit env key OR the service-role-derived
|
|
22
63
|
// fallback — so BYOK works on a one-click Vercel deploy with no extra env var.
|
|
23
|
-
hasEncryptionKey:
|
|
64
|
+
hasEncryptionKey: m(),
|
|
24
65
|
hasOpenRouterEnvKey: !!e,
|
|
25
66
|
openRouterEnvKeyLast4: e ? e.slice(-4) : null
|
|
26
67
|
};
|
|
27
68
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
69
|
+
function K() {
|
|
70
|
+
o();
|
|
30
71
|
const e = y();
|
|
31
72
|
if (!e)
|
|
32
73
|
throw new Error(
|
|
@@ -34,39 +75,49 @@ function R() {
|
|
|
34
75
|
);
|
|
35
76
|
return e;
|
|
36
77
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
78
|
+
function X(e) {
|
|
79
|
+
return a({
|
|
39
80
|
apiKey: e,
|
|
40
|
-
encryptionSecret:
|
|
81
|
+
encryptionSecret: K()
|
|
41
82
|
});
|
|
42
83
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
84
|
+
function G(e) {
|
|
85
|
+
o();
|
|
86
|
+
const t = c(e);
|
|
87
|
+
if (t === null)
|
|
47
88
|
throw new Error("Failed to decrypt stored OpenRouter key.");
|
|
48
|
-
return
|
|
89
|
+
return t;
|
|
49
90
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
91
|
+
function L(e) {
|
|
92
|
+
return _(e);
|
|
52
93
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
const e =
|
|
94
|
+
function U() {
|
|
95
|
+
o();
|
|
96
|
+
const e = x();
|
|
56
97
|
return {
|
|
57
98
|
hasEnvOpenRouterKey: e.hasOpenRouterEnvKey,
|
|
58
99
|
maskedEnvOpenRouterKey: e.openRouterEnvKeyLast4 ? E(e.openRouterEnvKeyLast4) : null
|
|
59
100
|
};
|
|
60
101
|
}
|
|
61
102
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
103
|
+
S as CORTEX_AI_AGENT_SETTINGS_BOUNDS,
|
|
104
|
+
p as CORTEX_AI_AGENT_SETTINGS_DEFAULTS,
|
|
105
|
+
O as CORTEX_AI_AGENT_SETTINGS_KEY,
|
|
106
|
+
v as CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY,
|
|
107
|
+
C as CORTEX_AI_OPENROUTER_SETTING_KEY,
|
|
108
|
+
I as CORTEX_AI_PACKAGE_ID,
|
|
109
|
+
d as CORTEX_AI_PACKAGE_NAME,
|
|
110
|
+
g as CORTEX_AI_PEXELS_SETTING_KEY,
|
|
111
|
+
M as CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY,
|
|
112
|
+
k as CORTEX_AI_UNSPLASH_SETTING_KEY,
|
|
113
|
+
G as decryptStoredOpenRouterApiKey,
|
|
114
|
+
X as encryptStoredOpenRouterApiKey,
|
|
115
|
+
x as getCortexAiEnvConfig,
|
|
116
|
+
U as getEnvOpenRouterKeyStatus,
|
|
117
|
+
R as getOpenRouterEnvApiKey,
|
|
118
|
+
h as getPexelsEnvApiKey,
|
|
119
|
+
L as getStoredOpenRouterKeyStatus,
|
|
120
|
+
Y as getUnsplashEnvApiKey,
|
|
121
|
+
A as normalizeCortexAiAgentSettings,
|
|
122
|
+
P as resolveCortexAiAgentSettings
|
|
72
123
|
};
|