@agent-native/core 0.111.3 → 0.112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +18 -0
- package/corpus/core/package.json +3 -1
- package/corpus/core/src/cli/code-agent-executor.ts +17 -5
- package/corpus/core/src/cli/code-agent-runs.ts +43 -2
- package/corpus/core/src/cli/migration-codemod.ts +59 -9
- package/corpus/core/src/cli/multi-frontier-runs.ts +841 -0
- package/corpus/core/src/coding-tools/index.ts +27 -8
- package/corpus/core/src/embeddings/index.ts +233 -0
- package/corpus/core/src/index.ts +2 -0
- package/corpus/core/src/search/index.ts +413 -0
- package/corpus/templates/brain/.agents/skills/brain/RUNBOOK.md +48 -5
- package/corpus/templates/brain/.agents/skills/brain/SKILL.md +46 -14
- package/corpus/templates/brain/README.md +34 -3
- package/corpus/templates/brain/actions/approve-proposal.ts +2 -0
- package/corpus/templates/brain/actions/claim-distillation.ts +24 -27
- package/corpus/templates/brain/actions/create-source.ts +1 -1
- package/corpus/templates/brain/actions/get-knowledge.ts +6 -2
- package/corpus/templates/brain/actions/get-pilot-report.ts +44 -8
- package/corpus/templates/brain/actions/import-capture.ts +21 -9
- package/corpus/templates/brain/actions/import-transcript.ts +42 -14
- package/corpus/templates/brain/actions/list-captures.ts +10 -1
- package/corpus/templates/brain/actions/list-distillation-queue.ts +39 -14
- package/corpus/templates/brain/actions/list-projects.ts +51 -0
- package/corpus/templates/brain/actions/list-proposals.ts +80 -4
- package/corpus/templates/brain/actions/list-sources.ts +17 -3
- package/corpus/templates/brain/actions/manage-project.ts +118 -0
- package/corpus/templates/brain/actions/mark-capture-distilled.ts +68 -20
- package/corpus/templates/brain/actions/navigate.ts +1 -0
- package/corpus/templates/brain/actions/reject-proposal.ts +6 -1
- package/corpus/templates/brain/actions/resanitize-captures.ts +159 -33
- package/corpus/templates/brain/actions/review-proposal.ts +2 -0
- package/corpus/templates/brain/actions/search-everything.ts +10 -1
- package/corpus/templates/brain/actions/search-knowledge.ts +1 -1
- package/corpus/templates/brain/actions/set-settings.ts +36 -1
- package/corpus/templates/brain/actions/update-proposal.ts +2 -0
- package/corpus/templates/brain/app/hooks/use-distillation-bridge.ts +18 -9
- package/corpus/templates/brain/app/hooks/use-navigation-state.ts +3 -0
- package/corpus/templates/brain/app/i18n-data.ts +731 -2
- package/corpus/templates/brain/app/lib/brain.ts +33 -1
- package/corpus/templates/brain/app/routes/ops.tsx +47 -0
- package/corpus/templates/brain/app/routes/review.tsx +41 -2
- package/corpus/templates/brain/app/routes/search.tsx +33 -2
- package/corpus/templates/brain/app/routes/settings.tsx +158 -0
- package/corpus/templates/brain/app/routes/sources.tsx +31 -0
- package/corpus/templates/brain/changelog/2026-07-19-added-private-source-safe-semantic-search.md +6 -0
- package/corpus/templates/brain/jobs/process-ingest-queue.ts +270 -36
- package/corpus/templates/brain/package.json +1 -0
- package/corpus/templates/brain/server/db/index.ts +18 -0
- package/corpus/templates/brain/server/db/schema.ts +197 -1
- package/corpus/templates/brain/server/jobs/distillation-queue.ts +12 -5
- package/corpus/templates/brain/server/lib/audiences.ts +708 -0
- package/corpus/templates/brain/server/lib/brain-health.ts +251 -38
- package/corpus/templates/brain/server/lib/brain.ts +877 -50
- package/corpus/templates/brain/server/lib/capture-sanitization.ts +217 -53
- package/corpus/templates/brain/server/lib/connectors.ts +556 -70
- package/corpus/templates/brain/server/lib/demo.ts +17 -4
- package/corpus/templates/brain/server/lib/hybrid-search.ts +363 -0
- package/corpus/templates/brain/server/lib/ingest-queue.ts +104 -0
- package/corpus/templates/brain/server/lib/privacy-readiness.ts +24 -0
- package/corpus/templates/brain/server/lib/search-index-contracts.ts +72 -0
- package/corpus/templates/brain/server/lib/search-index.ts +714 -0
- package/corpus/templates/brain/server/lib/search.ts +120 -4
- package/corpus/templates/brain/server/lib/sensitivity-policy.ts +174 -0
- package/corpus/templates/brain/server/lib/slack-events.ts +281 -0
- package/corpus/templates/brain/server/onboarding.ts +29 -0
- package/corpus/templates/brain/server/plugins/db.ts +204 -0
- package/corpus/templates/brain/server/register-secrets.ts +46 -0
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +36 -16
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/slack-events.post.ts +28 -0
- package/corpus/templates/brain/shared/types.ts +10 -0
- package/dist/cli/code-agent-executor.d.ts +8 -9
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +9 -3
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.d.ts +5 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +33 -2
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/cli/migration-codemod.d.ts.map +1 -1
- package/dist/cli/migration-codemod.js +48 -10
- package/dist/cli/migration-codemod.js.map +1 -1
- package/dist/cli/multi-frontier-runs.d.ts +131 -0
- package/dist/cli/multi-frontier-runs.d.ts.map +1 -0
- package/dist/cli/multi-frontier-runs.js +529 -0
- package/dist/cli/multi-frontier-runs.js.map +1 -0
- package/dist/coding-tools/index.d.ts +1 -0
- package/dist/coding-tools/index.d.ts.map +1 -1
- package/dist/coding-tools/index.js +25 -7
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/embeddings/index.d.ts +24 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +172 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/search/index.d.ts +88 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +267 -0
- package/dist/search/index.js.map +1 -0
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/package.json +3 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,+CAA+C;AAE/C,0BAA0B;AAC1B,OAAO,EACL,4BAA4B,EAU5B,aAAa;AACb,6DAA6D;AAC7D,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EAOtB,oBAAoB,EACpB,iBAAiB,EACjB,6BAA6B,GAQ9B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,iCAAiC,GAElC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,UAAU,GAKX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAClC,mCAAmC,EACnC,wCAAwC,GAEzC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,GAe1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,GAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,sBAAsB,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ent":["// Framework for agent-native apps.\n// Import everything from \"@agent-native/core\".\n\n// Agent (production mode)\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n DEFAULT_MODEL,\n // In-loop processors (observers/guardrails for runAgentLoop)\n TripWire,\n type Processor,\n type ProcessorState,\n type ProcessorAbort,\n} from \"./agent/index.js\";\nexport {\n defineAction,\n AgentActionStopError,\n isAgentActionStopError,\n type ActionDefinition,\n type ActionHttpConfig,\n type AgentActionStopOptions,\n type PublicAgentActionConfig,\n type ActionDeepLink,\n type ActionLinkBuilder,\n MCP_APP_EXTENSION_ID,\n MCP_APP_MIME_TYPE,\n MCP_APP_RESOURCE_URI_META_KEY,\n type ActionMcpAppConfig,\n type ActionMcpAppCsp,\n type ActionMcpAppCspBuilder,\n type ActionMcpAppHtmlBuilder,\n type ActionMcpAppPermissions,\n type ActionMcpAppResourceConfig,\n type ActionMcpAppResourceMeta,\n} from \"./action.js\";\nexport {\n embedApp,\n MCP_APP_REQUEST_ORIGIN_CSP_SOURCE,\n type EmbedAppOptions,\n} from \"./mcp/embed-app.js\";\nexport {\n embedRoute,\n type EmbedRouteContext,\n type EmbedRouteOptions,\n type EmbedRoutePathBuilder,\n type EmbedRouteResult,\n} from \"./mcp/embed-route.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER,\n type ActionChatUIConfig,\n} from \"./action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./data-widgets/index.js\";\nexport { createDevScriptRegistry } from \"./scripts/dev/index.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./server/agent-chat-plugin.js\";\nexport {\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./server/embedded.js\";\nexport {\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type AutomationCapabilities,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"./integrations/catalog.js\";\nexport {\n AutomationConnectorError,\n createAutomationCallbackHandler,\n createAutomationRuntime,\n createInvokeAutomationWorkflowAction,\n type AutomationCallbackAuthentication,\n type AutomationCallbackInput,\n type AutomationCallbackResult,\n type AutomationInboundDefinition,\n type AutomationInvocation,\n type AutomationInvocationResult,\n type AutomationInvocationStatus,\n type AutomationOutboundDefinition,\n type AutomationResponseMode,\n type AutomationRetryPolicy,\n type AutomationRuntime,\n type AutomationRuntimeOptions,\n type AutomationWorkflowCapabilities,\n type AutomationWorkflowDefinition,\n type JsonSchema,\n} from \"./automation/index.js\";\nexport {\n createFeatureFlagsPlugin,\n defineFeatureFlag,\n defineFeatureFlags,\n evaluateFeatureFlag,\n getFeatureFlagDefinition,\n getFeatureFlagRules,\n isFeatureFlagEnabled,\n listFeatureFlags,\n registerFeatureFlags,\n type FeatureFlagDefinition,\n type FeatureFlagMode,\n type FeatureFlagRules,\n type FeatureFlagScope,\n} from \"./feature-flags/index.js\";\n\n// Server\nexport {\n createServer,\n createSSEHandler,\n defineNitroPlugin,\n autoMountAuth,\n getSession,\n type CreateServerOptions,\n type SSEHandlerOptions,\n type AuthSession,\n type AuthOptions,\n} from \"./server/index.js\";\n\n// Client\n//\n// IMPORTANT: this top-level entry (the package `default`/Node condition) must\n// stay server-safe. It is what `import { defineAction } from \"@agent-native/core\"`\n// resolves to in a headless / Node / SSR context, where React, react-router, and\n// @tanstack/react-query are NOT installed. The React client surface therefore\n// lives behind the `@agent-native/core/client` subpath instead of being\n// re-exported here — re-exporting \"./client/index.js\" from this module would\n// eagerly pull route-state.ts → \"@tanstack/react-query\" into the load graph and\n// crash any headless app at module load.\n//\n// Browser bundlers resolve \"@agent-native/core\" to the `browser` condition\n// (./index.browser.ts), which re-exports the client surface, so UI code that\n// imports client helpers from the bare specifier keeps working in the browser.\n// Code that runs through the Node entry (SSR, scripts, headless) must import\n// client helpers explicitly:\n//\n// import { useDbSync, cn } from \"@agent-native/core/client\";\n\n// Shared (isomorphic)\nexport {\n agentChat,\n type AgentChatCallOptions,\n type AgentChatResponse,\n} from \"./shared/index.js\";\nexport {\n EMBED_MODE_QUERY_PARAM,\n EMBED_SESSION_COOKIE,\n EMBED_START_PATH,\n EMBED_TOKEN_QUERY_PARAM,\n} from \"./shared/embed-auth.js\";\n\n// Agent Web surfaces\nexport {\n AGENT_WEB_CRAWLER_CATEGORIES,\n AGENT_WEB_CRAWLER_USER_AGENTS,\n DEFAULT_AGENT_WEB_CRAWLER_POLICY,\n absoluteUrl,\n agentWebConfigFromPackageJson,\n buildAgentWebStaticFiles,\n buildBaseJsonLd,\n buildLlmsFullTxt,\n buildLlmsTxt,\n buildMarkdownResponseHeaders,\n buildPageJsonLd,\n buildRobotsTxt,\n buildSitemapXml,\n deriveAgentWebPublicRoutes,\n estimateMarkdownTokens,\n markdownFilePathForPage,\n markdownUrlForPage,\n normalizeAgentWebConfig,\n pathPatternMatches,\n resolveAgentWebCrawlerPolicy,\n type AgentWebConfig,\n type AgentWebCrawlerCategory,\n type AgentWebCrawlerDecision,\n type AgentWebCrawlerOverrides,\n type AgentWebCrawlerPolicy,\n type AgentWebInputConfig,\n type AgentWebPage,\n type AgentWebStaticFile,\n type BuildAgentWebStaticFilesOptions,\n type DeriveAgentWebPublicRoutesOptions,\n type MarkdownResponseHeadersOptions,\n} from \"./agent-web/index.js\";\n\n// Token usage tracking\nexport {\n recordUsage,\n getUsageSummary,\n getUserUsageCents,\n calculateCost,\n usageBillingForEngine,\n builderCreditsFromCostCents,\n BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER,\n BUILDER_AGENT_CREDITS_PER_USD,\n BUILDER_CREDIT_USAGE_BILLING,\n USD_USAGE_BILLING,\n type UsageRecord,\n type UsageCostSource,\n type UsageCostAggregate,\n type UsageSummary,\n type UsageBillingMode,\n type UsageBillingUnit,\n type UsageBucket,\n type DailyBucket,\n type UsageRecentEntry,\n} from \"./usage/store.js\";\n\n// Workspace-scoped third-party connection metadata\nexport {\n deleteWorkspaceConnection,\n getWorkspaceConnectionAppAccess,\n getWorkspaceConnection,\n getWorkspaceConnectionGrant,\n listWorkspaceConnectionProviderCatalogForApp,\n listWorkspaceConnectionGrants,\n listWorkspaceConnections,\n resolveWorkspaceConnectionCredentialForApp,\n resolveWorkspaceConnectionCredentialsForApp,\n revokeWorkspaceConnectionGrant,\n serializeWorkspaceConnectionGrant,\n serializeWorkspaceConnection,\n summarizeWorkspaceConnectionProviderForApp,\n summarizeWorkspaceConnectionProviderReadiness,\n upsertWorkspaceConnectionGrant,\n upsertWorkspaceConnection,\n type ListWorkspaceConnectionProviderCatalogForAppOptions,\n type ListWorkspaceConnectionGrantsOptions,\n type ListWorkspaceConnectionsOptions,\n type ResolveWorkspaceConnectionCredentialForAppOptions,\n type ResolveWorkspaceConnectionCredentialsForAppOptions,\n type SerializedWorkspaceConnectionGrant,\n type SerializedWorkspaceConnection,\n type SummarizeWorkspaceConnectionProviderForAppOptions,\n type SummarizeWorkspaceConnectionProviderReadinessOptions,\n type UpsertWorkspaceConnectionGrantInput,\n type UpsertWorkspaceConnectionInput,\n type WorkspaceConnectionAppAccess,\n type WorkspaceConnectionAppAccessMode,\n type WorkspaceConnection,\n type WorkspaceConnectionCredentialBackend,\n type WorkspaceConnectionCredentialProvenance,\n type WorkspaceConnectionCredentialRef,\n type WorkspaceConnectionCredentialResolution,\n type WorkspaceConnectionCredentialResolutionCheck,\n type WorkspaceConnectionCredentialResolutionStatus,\n type WorkspaceConnectionCredentialsResolution,\n type WorkspaceConnectionExplicitGrantSummary,\n type WorkspaceConnectionForAppSummary,\n type WorkspaceConnectionGrant,\n type WorkspaceConnectionGrantAvailability,\n type WorkspaceConnectionGrantState,\n type WorkspaceConnectionProviderAppSummary,\n type WorkspaceConnectionProviderLike,\n type WorkspaceConnectionProviderCatalogForApp,\n type WorkspaceConnectionProviderCatalogForAppItem,\n type WorkspaceConnectionProviderReadiness,\n type WorkspaceConnectionProviderReadinessStatus,\n type WorkspaceConnectionPublicCredentialRef,\n type WorkspaceConnectionStatus,\n workspaceConnectionIsAvailableToApp,\n registerWorkspaceConnectionLifecycleListener,\n type WorkspaceConnectionLifecycleEvent,\n type WorkspaceConnectionLifecycleListener,\n} from \"./workspace-connections/index.js\";\n\n// Reusable workspace connection provider catalog\nexport {\n PROVIDER_READERS,\n ProviderReaderRuntimeError,\n WORKSPACE_CONNECTION_PROVIDERS,\n createProviderReaderRuntime,\n defineProviderReader,\n defineProviderReaderImplementation,\n defineWorkspaceConnectionProvider,\n getProviderReader,\n getWorkspaceConnectionProvider,\n isWorkspaceConnectionProviderId,\n listProviderReaders,\n listWorkspaceConnectionProviders,\n listWorkspaceConnectionProvidersForCapability,\n listWorkspaceConnectionProvidersForTemplate,\n providerReaderSupports,\n workspaceConnectionProviderSupports,\n type ListWorkspaceConnectionProvidersOptions,\n type ListProviderReadersOptions,\n type ProviderReaderCapability,\n type ProviderReaderCredentialRequirement,\n type ProviderReaderDefinition,\n type ProviderReaderImplementationStatus,\n type ProviderReaderOperation,\n type ProviderReaderOperationDescriptor,\n type ProviderReaderOperationParameter,\n type ProviderReaderRequest,\n type ProviderReaderRuntime,\n type ProviderReaderRuntimeConnection,\n type ProviderReaderRuntimeConnectionResolverOptions,\n type ProviderReaderRuntimeContext,\n type ProviderReaderRuntimeCredentialsResolverOptions,\n type ProviderReaderRuntimeErrorCode,\n type ProviderReaderRuntimeHandler,\n type ProviderReaderRuntimeImplementation,\n type ProviderReaderRuntimeItem,\n type ProviderReaderRuntimeOptions,\n type ProviderReaderRuntimeResponse,\n type WorkspaceConnectionCapability,\n type WorkspaceConnectionCredentialKey,\n type WorkspaceConnectionProvider,\n type WorkspaceConnectionProviderId,\n type WorkspaceConnectionTemplateUse,\n} from \"./connections/index.js\";\n\n// Scripts\nexport {\n runScript,\n loadEnv,\n parseArgs,\n camelCaseArgs,\n isValidPath,\n isValidProjectPath,\n ensureDir,\n fail,\n} from \"./scripts/index.js\";\n\n// Secrets registry — import from \"@agent-native/core/secrets\" when possible\n// (the subpath keeps the top-level entry point lean), but re-export the\n// public API here for convenience.\nexport {\n registerRequiredSecret,\n listRequiredSecrets,\n getRequiredSecret,\n readAppSecret,\n writeAppSecret,\n deleteAppSecret,\n type RegisteredSecret,\n type SecretScope,\n type SecretKind,\n type SecretValidator,\n type SecretRef,\n} from \"./secrets/index.js\";\n\nexport * from \"./history/index.js\";\nexport * from \"./review/index.js\";\nexport * from \"./org-team/index.js\";\nexport * from \"./navigation/index.js\";\nexport * from \"./command-navigation/index.js\";\nexport {\n registerWorkspaceConnectionOnboardingStep,\n type RegisterWorkspaceConnectionOnboardingStepOptions,\n} from \"./setup-connections/index.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,+CAA+C;AAE/C,0BAA0B;AAC1B,OAAO,EACL,4BAA4B,EAU5B,aAAa;AACb,6DAA6D;AAC7D,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EAOtB,oBAAoB,EACpB,iBAAiB,EACjB,6BAA6B,GAQ9B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,iCAAiC,GAElC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,UAAU,GAKX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAClC,mCAAmC,EACnC,wCAAwC,GAEzC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,GAe1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,GAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,sBAA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tC,OAAO,EACL,yCAAyC,GAE1C,MAAM,8BAA8B,CAAC","sourcesContent":["// Framework for agent-native apps.\n// Import everything from \"@agent-native/core\".\n\n// Agent (production mode)\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n DEFAULT_MODEL,\n // In-loop processors (observers/guardrails for runAgentLoop)\n TripWire,\n type Processor,\n type ProcessorState,\n type ProcessorAbort,\n} from \"./agent/index.js\";\nexport {\n defineAction,\n AgentActionStopError,\n isAgentActionStopError,\n type ActionDefinition,\n type ActionHttpConfig,\n type AgentActionStopOptions,\n type PublicAgentActionConfig,\n type ActionDeepLink,\n type ActionLinkBuilder,\n MCP_APP_EXTENSION_ID,\n MCP_APP_MIME_TYPE,\n MCP_APP_RESOURCE_URI_META_KEY,\n type ActionMcpAppConfig,\n type ActionMcpAppCsp,\n type ActionMcpAppCspBuilder,\n type ActionMcpAppHtmlBuilder,\n type ActionMcpAppPermissions,\n type ActionMcpAppResourceConfig,\n type ActionMcpAppResourceMeta,\n} from \"./action.js\";\nexport {\n embedApp,\n MCP_APP_REQUEST_ORIGIN_CSP_SOURCE,\n type EmbedAppOptions,\n} from \"./mcp/embed-app.js\";\nexport {\n embedRoute,\n type EmbedRouteContext,\n type EmbedRouteOptions,\n type EmbedRoutePathBuilder,\n type EmbedRouteResult,\n} from \"./mcp/embed-route.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER,\n type ActionChatUIConfig,\n} from \"./action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./data-widgets/index.js\";\nexport { createDevScriptRegistry } from \"./scripts/dev/index.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./server/agent-chat-plugin.js\";\nexport {\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./server/embedded.js\";\nexport {\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type AutomationCapabilities,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"./integrations/catalog.js\";\nexport {\n AutomationConnectorError,\n createAutomationCallbackHandler,\n createAutomationRuntime,\n createInvokeAutomationWorkflowAction,\n type AutomationCallbackAuthentication,\n type AutomationCallbackInput,\n type AutomationCallbackResult,\n type AutomationInboundDefinition,\n type AutomationInvocation,\n type AutomationInvocationResult,\n type AutomationInvocationStatus,\n type AutomationOutboundDefinition,\n type AutomationResponseMode,\n type AutomationRetryPolicy,\n type AutomationRuntime,\n type AutomationRuntimeOptions,\n type AutomationWorkflowCapabilities,\n type AutomationWorkflowDefinition,\n type JsonSchema,\n} from \"./automation/index.js\";\nexport {\n createFeatureFlagsPlugin,\n defineFeatureFlag,\n defineFeatureFlags,\n evaluateFeatureFlag,\n getFeatureFlagDefinition,\n getFeatureFlagRules,\n isFeatureFlagEnabled,\n listFeatureFlags,\n registerFeatureFlags,\n type FeatureFlagDefinition,\n type FeatureFlagMode,\n type FeatureFlagRules,\n type FeatureFlagScope,\n} from \"./feature-flags/index.js\";\n\n// Server\nexport {\n createServer,\n createSSEHandler,\n defineNitroPlugin,\n autoMountAuth,\n getSession,\n type CreateServerOptions,\n type SSEHandlerOptions,\n type AuthSession,\n type AuthOptions,\n} from \"./server/index.js\";\n\n// Client\n//\n// IMPORTANT: this top-level entry (the package `default`/Node condition) must\n// stay server-safe. It is what `import { defineAction } from \"@agent-native/core\"`\n// resolves to in a headless / Node / SSR context, where React, react-router, and\n// @tanstack/react-query are NOT installed. The React client surface therefore\n// lives behind the `@agent-native/core/client` subpath instead of being\n// re-exported here — re-exporting \"./client/index.js\" from this module would\n// eagerly pull route-state.ts → \"@tanstack/react-query\" into the load graph and\n// crash any headless app at module load.\n//\n// Browser bundlers resolve \"@agent-native/core\" to the `browser` condition\n// (./index.browser.ts), which re-exports the client surface, so UI code that\n// imports client helpers from the bare specifier keeps working in the browser.\n// Code that runs through the Node entry (SSR, scripts, headless) must import\n// client helpers explicitly:\n//\n// import { useDbSync, cn } from \"@agent-native/core/client\";\n\n// Shared (isomorphic)\nexport {\n agentChat,\n type AgentChatCallOptions,\n type AgentChatResponse,\n} from \"./shared/index.js\";\nexport {\n EMBED_MODE_QUERY_PARAM,\n EMBED_SESSION_COOKIE,\n EMBED_START_PATH,\n EMBED_TOKEN_QUERY_PARAM,\n} from \"./shared/embed-auth.js\";\n\n// Agent Web surfaces\nexport {\n AGENT_WEB_CRAWLER_CATEGORIES,\n AGENT_WEB_CRAWLER_USER_AGENTS,\n DEFAULT_AGENT_WEB_CRAWLER_POLICY,\n absoluteUrl,\n agentWebConfigFromPackageJson,\n buildAgentWebStaticFiles,\n buildBaseJsonLd,\n buildLlmsFullTxt,\n buildLlmsTxt,\n buildMarkdownResponseHeaders,\n buildPageJsonLd,\n buildRobotsTxt,\n buildSitemapXml,\n deriveAgentWebPublicRoutes,\n estimateMarkdownTokens,\n markdownFilePathForPage,\n markdownUrlForPage,\n normalizeAgentWebConfig,\n pathPatternMatches,\n resolveAgentWebCrawlerPolicy,\n type AgentWebConfig,\n type AgentWebCrawlerCategory,\n type AgentWebCrawlerDecision,\n type AgentWebCrawlerOverrides,\n type AgentWebCrawlerPolicy,\n type AgentWebInputConfig,\n type AgentWebPage,\n type AgentWebStaticFile,\n type BuildAgentWebStaticFilesOptions,\n type DeriveAgentWebPublicRoutesOptions,\n type MarkdownResponseHeadersOptions,\n} from \"./agent-web/index.js\";\n\n// Token usage tracking\nexport {\n recordUsage,\n getUsageSummary,\n getUserUsageCents,\n calculateCost,\n usageBillingForEngine,\n builderCreditsFromCostCents,\n BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER,\n BUILDER_AGENT_CREDITS_PER_USD,\n BUILDER_CREDIT_USAGE_BILLING,\n USD_USAGE_BILLING,\n type UsageRecord,\n type UsageCostSource,\n type UsageCostAggregate,\n type UsageSummary,\n type UsageBillingMode,\n type UsageBillingUnit,\n type UsageBucket,\n type DailyBucket,\n type UsageRecentEntry,\n} from \"./usage/store.js\";\n\n// Workspace-scoped third-party connection metadata\nexport {\n deleteWorkspaceConnection,\n getWorkspaceConnectionAppAccess,\n getWorkspaceConnection,\n getWorkspaceConnectionGrant,\n listWorkspaceConnectionProviderCatalogForApp,\n listWorkspaceConnectionGrants,\n listWorkspaceConnections,\n resolveWorkspaceConnectionCredentialForApp,\n resolveWorkspaceConnectionCredentialsForApp,\n revokeWorkspaceConnectionGrant,\n serializeWorkspaceConnectionGrant,\n serializeWorkspaceConnection,\n summarizeWorkspaceConnectionProviderForApp,\n summarizeWorkspaceConnectionProviderReadiness,\n upsertWorkspaceConnectionGrant,\n upsertWorkspaceConnection,\n type ListWorkspaceConnectionProviderCatalogForAppOptions,\n type ListWorkspaceConnectionGrantsOptions,\n type ListWorkspaceConnectionsOptions,\n type ResolveWorkspaceConnectionCredentialForAppOptions,\n type ResolveWorkspaceConnectionCredentialsForAppOptions,\n type SerializedWorkspaceConnectionGrant,\n type SerializedWorkspaceConnection,\n type SummarizeWorkspaceConnectionProviderForAppOptions,\n type SummarizeWorkspaceConnectionProviderReadinessOptions,\n type UpsertWorkspaceConnectionGrantInput,\n type UpsertWorkspaceConnectionInput,\n type WorkspaceConnectionAppAccess,\n type WorkspaceConnectionAppAccessMode,\n type WorkspaceConnection,\n type WorkspaceConnectionCredentialBackend,\n type WorkspaceConnectionCredentialProvenance,\n type WorkspaceConnectionCredentialRef,\n type WorkspaceConnectionCredentialResolution,\n type WorkspaceConnectionCredentialResolutionCheck,\n type WorkspaceConnectionCredentialResolutionStatus,\n type WorkspaceConnectionCredentialsResolution,\n type WorkspaceConnectionExplicitGrantSummary,\n type WorkspaceConnectionForAppSummary,\n type WorkspaceConnectionGrant,\n type WorkspaceConnectionGrantAvailability,\n type WorkspaceConnectionGrantState,\n type WorkspaceConnectionProviderAppSummary,\n type WorkspaceConnectionProviderLike,\n type WorkspaceConnectionProviderCatalogForApp,\n type WorkspaceConnectionProviderCatalogForAppItem,\n type WorkspaceConnectionProviderReadiness,\n type WorkspaceConnectionProviderReadinessStatus,\n type WorkspaceConnectionPublicCredentialRef,\n type WorkspaceConnectionStatus,\n workspaceConnectionIsAvailableToApp,\n registerWorkspaceConnectionLifecycleListener,\n type WorkspaceConnectionLifecycleEvent,\n type WorkspaceConnectionLifecycleListener,\n} from \"./workspace-connections/index.js\";\n\n// Reusable workspace connection provider catalog\nexport {\n PROVIDER_READERS,\n ProviderReaderRuntimeError,\n WORKSPACE_CONNECTION_PROVIDERS,\n createProviderReaderRuntime,\n defineProviderReader,\n defineProviderReaderImplementation,\n defineWorkspaceConnectionProvider,\n getProviderReader,\n getWorkspaceConnectionProvider,\n isWorkspaceConnectionProviderId,\n listProviderReaders,\n listWorkspaceConnectionProviders,\n listWorkspaceConnectionProvidersForCapability,\n listWorkspaceConnectionProvidersForTemplate,\n providerReaderSupports,\n workspaceConnectionProviderSupports,\n type ListWorkspaceConnectionProvidersOptions,\n type ListProviderReadersOptions,\n type ProviderReaderCapability,\n type ProviderReaderCredentialRequirement,\n type ProviderReaderDefinition,\n type ProviderReaderImplementationStatus,\n type ProviderReaderOperation,\n type ProviderReaderOperationDescriptor,\n type ProviderReaderOperationParameter,\n type ProviderReaderRequest,\n type ProviderReaderRuntime,\n type ProviderReaderRuntimeConnection,\n type ProviderReaderRuntimeConnectionResolverOptions,\n type ProviderReaderRuntimeContext,\n type ProviderReaderRuntimeCredentialsResolverOptions,\n type ProviderReaderRuntimeErrorCode,\n type ProviderReaderRuntimeHandler,\n type ProviderReaderRuntimeImplementation,\n type ProviderReaderRuntimeItem,\n type ProviderReaderRuntimeOptions,\n type ProviderReaderRuntimeResponse,\n type WorkspaceConnectionCapability,\n type WorkspaceConnectionCredentialKey,\n type WorkspaceConnectionProvider,\n type WorkspaceConnectionProviderId,\n type WorkspaceConnectionTemplateUse,\n} from \"./connections/index.js\";\n\n// Scripts\nexport {\n runScript,\n loadEnv,\n parseArgs,\n camelCaseArgs,\n isValidPath,\n isValidProjectPath,\n ensureDir,\n fail,\n} from \"./scripts/index.js\";\n\n// Secrets registry — import from \"@agent-native/core/secrets\" when possible\n// (the subpath keeps the top-level entry point lean), but re-export the\n// public API here for convenience.\nexport {\n registerRequiredSecret,\n listRequiredSecrets,\n getRequiredSecret,\n readAppSecret,\n writeAppSecret,\n deleteAppSecret,\n type RegisteredSecret,\n type SecretScope,\n type SecretKind,\n type SecretValidator,\n type SecretRef,\n} from \"./secrets/index.js\";\n\nexport * from \"./history/index.js\";\nexport * from \"./review/index.js\";\nexport * from \"./org-team/index.js\";\nexport * from \"./navigation/index.js\";\nexport * from \"./command-navigation/index.js\";\nexport * from \"./search/index.js\";\nexport * from \"./embeddings/index.js\";\nexport {\n registerWorkspaceConnectionOnboardingStep,\n type RegisterWorkspaceConnectionOnboardingStepOptions,\n} from \"./setup-connections/index.js\";\n"]}
|
|
@@ -11,24 +11,24 @@
|
|
|
11
11
|
* DELETE /_agent-native/notifications/:id — delete
|
|
12
12
|
*/
|
|
13
13
|
export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
|
|
14
|
+
error?: undefined;
|
|
14
15
|
count: number;
|
|
15
16
|
updated?: undefined;
|
|
16
17
|
ok?: undefined;
|
|
17
|
-
error?: undefined;
|
|
18
18
|
} | {
|
|
19
|
+
error?: undefined;
|
|
19
20
|
count?: undefined;
|
|
20
21
|
updated: number;
|
|
21
22
|
ok?: undefined;
|
|
22
|
-
error?: undefined;
|
|
23
23
|
} | {
|
|
24
24
|
count?: undefined;
|
|
25
25
|
updated?: undefined;
|
|
26
26
|
error: string;
|
|
27
27
|
ok?: undefined;
|
|
28
28
|
} | {
|
|
29
|
+
error?: undefined;
|
|
29
30
|
count?: undefined;
|
|
30
31
|
updated?: undefined;
|
|
31
32
|
ok: boolean;
|
|
32
|
-
error?: undefined;
|
|
33
33
|
}>>;
|
|
34
34
|
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -49,8 +49,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
|
|
|
49
49
|
}>;
|
|
50
50
|
/** DELETE /_agent-native/resources/:id — delete a resource */
|
|
51
51
|
export declare function handleDeleteResource(event: any): Promise<{
|
|
52
|
-
ok?: undefined;
|
|
53
52
|
error: string;
|
|
53
|
+
ok?: undefined;
|
|
54
54
|
} | {
|
|
55
55
|
error?: undefined;
|
|
56
56
|
ok: boolean;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { DbExec } from "../db/index.js";
|
|
2
|
+
export declare const DEFAULT_SEARCH_NAMESPACE = "creative_context";
|
|
3
|
+
export declare const PGVECTOR_REQUIRED_MESSAGE = "Vector search requires Postgres with the pgvector extension in the configured DATABASE_URL database.";
|
|
4
|
+
export interface SearchNamespaceIdentifiers {
|
|
5
|
+
namespace: string;
|
|
6
|
+
ftsTable: string;
|
|
7
|
+
ftsIndex: string;
|
|
8
|
+
ftsAudienceIndex: string;
|
|
9
|
+
vectorTable: string;
|
|
10
|
+
vectorIndex: string;
|
|
11
|
+
vectorAudienceIndex: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PgVectorHit {
|
|
14
|
+
vectorKey: string;
|
|
15
|
+
embeddingSetId: string;
|
|
16
|
+
score: number;
|
|
17
|
+
}
|
|
18
|
+
export interface PostgresFtsHit {
|
|
19
|
+
chunkId: string;
|
|
20
|
+
itemVersionId: string;
|
|
21
|
+
score: number;
|
|
22
|
+
}
|
|
23
|
+
export interface RankedCandidate<T> {
|
|
24
|
+
key: string;
|
|
25
|
+
value: T;
|
|
26
|
+
score: number;
|
|
27
|
+
reason?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface FusedCandidate<T> extends RankedCandidate<T> {
|
|
30
|
+
laneRanks: Record<string, number>;
|
|
31
|
+
reasons: string[];
|
|
32
|
+
}
|
|
33
|
+
type PgVectorOptions = boolean | {
|
|
34
|
+
namespace?: string;
|
|
35
|
+
postgres?: boolean;
|
|
36
|
+
/** The caller has already provisioned this namespace and dimension. */
|
|
37
|
+
indexInitialized?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export declare function searchNamespaceIdentifiers(namespace?: string, dimensions?: number): SearchNamespaceIdentifiers;
|
|
40
|
+
export declare function assertPgVectorAvailable(postgres?: boolean): void;
|
|
41
|
+
export declare function ensurePgVectorIndex(db: DbExec, dimensions: number, options?: PgVectorOptions): Promise<void>;
|
|
42
|
+
export declare function upsertPgVector(db: DbExec, input: {
|
|
43
|
+
vectorKey: string;
|
|
44
|
+
embeddingSetId: string;
|
|
45
|
+
dimensions: number;
|
|
46
|
+
vector: readonly number[];
|
|
47
|
+
audienceIds?: readonly string[];
|
|
48
|
+
updatedAt?: string;
|
|
49
|
+
}, options?: PgVectorOptions): Promise<void>;
|
|
50
|
+
export declare function deletePgVectors(db: DbExec, input: {
|
|
51
|
+
dimensions: number;
|
|
52
|
+
vectorKeys: readonly string[];
|
|
53
|
+
namespace?: string;
|
|
54
|
+
}, postgres?: boolean): Promise<number>;
|
|
55
|
+
export declare function queryPgVectorIndex(db: DbExec, input: {
|
|
56
|
+
embeddingSetId: string;
|
|
57
|
+
dimensions: number;
|
|
58
|
+
vector: readonly number[];
|
|
59
|
+
limit?: number;
|
|
60
|
+
allowedVectorKeys?: readonly string[];
|
|
61
|
+
allowedAudienceIds?: readonly string[];
|
|
62
|
+
namespace?: string;
|
|
63
|
+
}, postgres?: boolean): Promise<PgVectorHit[]>;
|
|
64
|
+
export declare function ensurePostgresFts(db: DbExec, namespace?: string): Promise<boolean>;
|
|
65
|
+
export declare function upsertPostgresFtsDocument(db: DbExec, input: {
|
|
66
|
+
chunkId: string;
|
|
67
|
+
itemVersionId: string;
|
|
68
|
+
title: string;
|
|
69
|
+
summary?: string | null;
|
|
70
|
+
body: string;
|
|
71
|
+
audienceIds?: readonly string[];
|
|
72
|
+
updatedAt?: string;
|
|
73
|
+
namespace?: string;
|
|
74
|
+
}): Promise<boolean>;
|
|
75
|
+
export declare function queryPostgresFts(db: DbExec, input: {
|
|
76
|
+
query: string;
|
|
77
|
+
allowedChunkIds?: readonly string[];
|
|
78
|
+
allowedAudienceIds?: readonly string[];
|
|
79
|
+
limit?: number;
|
|
80
|
+
namespace?: string;
|
|
81
|
+
}): Promise<PostgresFtsHit[]>;
|
|
82
|
+
export declare function deletePostgresFtsDocuments(db: DbExec, chunkIds: readonly string[], namespace?: string): Promise<number>;
|
|
83
|
+
export declare function reciprocalRankFusion<T>(lanes: Readonly<Record<string, readonly RankedCandidate<T>[]>>, options?: {
|
|
84
|
+
rankConstant?: number;
|
|
85
|
+
limit?: number;
|
|
86
|
+
}): FusedCandidate<T>[];
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG7C,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,yGACkE,CAAC;AAEzG,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IAC3D,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,KAAK,eAAe,GAChB,OAAO,GACP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AAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9D,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GACtD,cAAc,CAAC,CAAC,CAAC,EAAE,CAsBrB"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { isPostgres } from "../db/index.js";
|
|
2
|
+
export const DEFAULT_SEARCH_NAMESPACE = "creative_context";
|
|
3
|
+
export const PGVECTOR_REQUIRED_MESSAGE = "Vector search requires Postgres with the pgvector extension in the configured DATABASE_URL database.";
|
|
4
|
+
function pgVectorOptions(options) {
|
|
5
|
+
return typeof options === "boolean" ? { postgres: options } : (options ?? {});
|
|
6
|
+
}
|
|
7
|
+
export function searchNamespaceIdentifiers(namespace = DEFAULT_SEARCH_NAMESPACE, dimensions) {
|
|
8
|
+
if (!/^[a-z][a-z0-9_]{0,62}$/.test(namespace)) {
|
|
9
|
+
throw new Error("Search namespace must start with a lowercase letter and contain only lowercase letters, numbers, and underscores.");
|
|
10
|
+
}
|
|
11
|
+
const suffix = dimensions === undefined ? "" : `_${checkedDimensions(dimensions)}`;
|
|
12
|
+
return {
|
|
13
|
+
namespace,
|
|
14
|
+
ftsTable: `${namespace}_search_documents`,
|
|
15
|
+
ftsIndex: `${namespace}_search_documents_gin`,
|
|
16
|
+
ftsAudienceIndex: `${namespace}_search_documents_audience_gin`,
|
|
17
|
+
vectorTable: `${namespace}_vectors${suffix}`,
|
|
18
|
+
vectorIndex: `${namespace}_vectors${suffix}_hnsw`,
|
|
19
|
+
vectorAudienceIndex: `${namespace}_vectors${suffix}_audience_gin`,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function checkedDimensions(value) {
|
|
23
|
+
if (!Number.isInteger(value) || value < 1 || value > 16_000) {
|
|
24
|
+
throw new Error("Embedding dimensions must be an integer from 1 to 16000.");
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
function vectorLiteral(vector, dimensions) {
|
|
29
|
+
if (vector.length !== dimensions) {
|
|
30
|
+
throw new Error(`Embedding has ${vector.length} values; expected ${dimensions}.`);
|
|
31
|
+
}
|
|
32
|
+
for (const value of vector) {
|
|
33
|
+
if (!Number.isFinite(value)) {
|
|
34
|
+
throw new Error("Embedding vectors may contain only finite numbers.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return `[${vector.join(",")}]`;
|
|
38
|
+
}
|
|
39
|
+
function audienceClause(audienceIds, column = "audience_ids") {
|
|
40
|
+
if (!audienceIds?.length)
|
|
41
|
+
return { sql: "", args: [] };
|
|
42
|
+
return {
|
|
43
|
+
sql: ` AND ${column} && ARRAY[${audienceIds.map(() => "?").join(", ")}]::TEXT[]`,
|
|
44
|
+
args: [...audienceIds],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function assertPgVectorAvailable(postgres = isPostgres()) {
|
|
48
|
+
if (!postgres)
|
|
49
|
+
throw new Error(PGVECTOR_REQUIRED_MESSAGE);
|
|
50
|
+
}
|
|
51
|
+
export async function ensurePgVectorIndex(db, dimensions, options) {
|
|
52
|
+
const resolved = pgVectorOptions(options);
|
|
53
|
+
const names = searchNamespaceIdentifiers(resolved.namespace, dimensions);
|
|
54
|
+
assertPgVectorAvailable(resolved.postgres);
|
|
55
|
+
try {
|
|
56
|
+
await db.execute("CREATE EXTENSION IF NOT EXISTS vector");
|
|
57
|
+
await db.execute(`
|
|
58
|
+
CREATE TABLE IF NOT EXISTS ${names.vectorTable} (
|
|
59
|
+
vector_key TEXT PRIMARY KEY,
|
|
60
|
+
embedding_set_id TEXT NOT NULL,
|
|
61
|
+
audience_ids TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[],
|
|
62
|
+
embedding vector(${checkedDimensions(dimensions)}) NOT NULL,
|
|
63
|
+
updated_at TEXT NOT NULL
|
|
64
|
+
)
|
|
65
|
+
`);
|
|
66
|
+
await db.execute(`ALTER TABLE ${names.vectorTable} ADD COLUMN IF NOT EXISTS audience_ids TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[]`);
|
|
67
|
+
await db.execute(`CREATE INDEX IF NOT EXISTS ${names.vectorIndex} ON ${names.vectorTable} USING hnsw (embedding vector_cosine_ops)`);
|
|
68
|
+
await db.execute(`CREATE INDEX IF NOT EXISTS ${names.vectorAudienceIndex} ON ${names.vectorTable} USING GIN (audience_ids)`);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
throw new Error(PGVECTOR_REQUIRED_MESSAGE, { cause: error });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export async function upsertPgVector(db, input, options) {
|
|
75
|
+
const resolved = pgVectorOptions(options);
|
|
76
|
+
const names = searchNamespaceIdentifiers(resolved.namespace, input.dimensions);
|
|
77
|
+
assertPgVectorAvailable(resolved.postgres);
|
|
78
|
+
if (!resolved.indexInitialized) {
|
|
79
|
+
await ensurePgVectorIndex(db, input.dimensions, resolved);
|
|
80
|
+
}
|
|
81
|
+
await db.execute({
|
|
82
|
+
sql: `
|
|
83
|
+
INSERT INTO ${names.vectorTable} (vector_key, embedding_set_id, audience_ids, embedding, updated_at)
|
|
84
|
+
VALUES (?, ?, ARRAY[${(input.audienceIds ?? []).map(() => "?").join(", ")}]::TEXT[], ?::vector, ?)
|
|
85
|
+
ON CONFLICT (vector_key) DO UPDATE SET
|
|
86
|
+
embedding_set_id = EXCLUDED.embedding_set_id,
|
|
87
|
+
audience_ids = EXCLUDED.audience_ids,
|
|
88
|
+
embedding = EXCLUDED.embedding,
|
|
89
|
+
updated_at = EXCLUDED.updated_at
|
|
90
|
+
`,
|
|
91
|
+
args: [
|
|
92
|
+
input.vectorKey,
|
|
93
|
+
input.embeddingSetId,
|
|
94
|
+
...(input.audienceIds ?? []),
|
|
95
|
+
vectorLiteral(input.vector, input.dimensions),
|
|
96
|
+
input.updatedAt ?? new Date().toISOString(),
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export async function deletePgVectors(db, input, postgres = isPostgres()) {
|
|
101
|
+
const names = searchNamespaceIdentifiers(input.namespace, input.dimensions);
|
|
102
|
+
assertPgVectorAvailable(postgres);
|
|
103
|
+
if (!input.vectorKeys.length)
|
|
104
|
+
return 0;
|
|
105
|
+
const result = await db.execute({
|
|
106
|
+
sql: `DELETE FROM ${names.vectorTable} WHERE vector_key IN (${input.vectorKeys.map(() => "?").join(", ")})`,
|
|
107
|
+
args: [...input.vectorKeys],
|
|
108
|
+
});
|
|
109
|
+
return result.rowsAffected;
|
|
110
|
+
}
|
|
111
|
+
export async function queryPgVectorIndex(db, input, postgres = isPostgres()) {
|
|
112
|
+
const names = searchNamespaceIdentifiers(input.namespace, input.dimensions);
|
|
113
|
+
assertPgVectorAvailable(postgres);
|
|
114
|
+
if (input.allowedVectorKeys?.length === 0 ||
|
|
115
|
+
input.allowedAudienceIds?.length === 0)
|
|
116
|
+
return [];
|
|
117
|
+
const limit = Math.max(1, Math.min(200, Math.floor(input.limit ?? 40)));
|
|
118
|
+
const literal = vectorLiteral(input.vector, input.dimensions);
|
|
119
|
+
const keySql = input.allowedVectorKeys?.length
|
|
120
|
+
? ` AND vector_key IN (${input.allowedVectorKeys.map(() => "?").join(", ")})`
|
|
121
|
+
: "";
|
|
122
|
+
const audiences = audienceClause(input.allowedAudienceIds);
|
|
123
|
+
try {
|
|
124
|
+
await db.execute("SET hnsw.iterative_scan = strict_order");
|
|
125
|
+
}
|
|
126
|
+
catch { }
|
|
127
|
+
const result = await db.execute({
|
|
128
|
+
sql: `
|
|
129
|
+
SELECT vector_key, embedding_set_id, 1 - (embedding <=> ?::vector) AS score
|
|
130
|
+
FROM ${names.vectorTable}
|
|
131
|
+
WHERE embedding_set_id = ?${keySql}${audiences.sql}
|
|
132
|
+
ORDER BY embedding <=> ?::vector
|
|
133
|
+
LIMIT ?
|
|
134
|
+
`,
|
|
135
|
+
args: [
|
|
136
|
+
literal,
|
|
137
|
+
input.embeddingSetId,
|
|
138
|
+
...(input.allowedVectorKeys ?? []),
|
|
139
|
+
...audiences.args,
|
|
140
|
+
literal,
|
|
141
|
+
limit,
|
|
142
|
+
],
|
|
143
|
+
});
|
|
144
|
+
return result.rows.map((row) => ({
|
|
145
|
+
vectorKey: String(row.vector_key),
|
|
146
|
+
embeddingSetId: String(row.embedding_set_id),
|
|
147
|
+
score: Number(row.score),
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
export async function ensurePostgresFts(db, namespace = DEFAULT_SEARCH_NAMESPACE) {
|
|
151
|
+
const names = searchNamespaceIdentifiers(namespace);
|
|
152
|
+
if (!isPostgres())
|
|
153
|
+
return false;
|
|
154
|
+
await db.execute(`
|
|
155
|
+
CREATE TABLE IF NOT EXISTS ${names.ftsTable} (
|
|
156
|
+
chunk_id TEXT PRIMARY KEY,
|
|
157
|
+
item_version_id TEXT NOT NULL,
|
|
158
|
+
audience_ids TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[],
|
|
159
|
+
document TSVECTOR NOT NULL,
|
|
160
|
+
updated_at TEXT NOT NULL
|
|
161
|
+
)
|
|
162
|
+
`);
|
|
163
|
+
await db.execute(`ALTER TABLE ${names.ftsTable} ADD COLUMN IF NOT EXISTS audience_ids TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[]`);
|
|
164
|
+
await db.execute(`CREATE INDEX IF NOT EXISTS ${names.ftsIndex} ON ${names.ftsTable} USING GIN (document)`);
|
|
165
|
+
await db.execute(`CREATE INDEX IF NOT EXISTS ${names.ftsAudienceIndex} ON ${names.ftsTable} USING GIN (audience_ids)`);
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
export async function upsertPostgresFtsDocument(db, input) {
|
|
169
|
+
const namespace = input.namespace ?? DEFAULT_SEARCH_NAMESPACE;
|
|
170
|
+
if (!(await ensurePostgresFts(db, namespace)))
|
|
171
|
+
return false;
|
|
172
|
+
const names = searchNamespaceIdentifiers(namespace);
|
|
173
|
+
await db.execute({
|
|
174
|
+
sql: `
|
|
175
|
+
INSERT INTO ${names.ftsTable} (chunk_id, item_version_id, audience_ids, document, updated_at)
|
|
176
|
+
VALUES (?, ?, ARRAY[${(input.audienceIds ?? []).map(() => "?").join(", ")}]::TEXT[], setweight(to_tsvector('simple', ?), 'A') || setweight(to_tsvector('simple', ?), 'B') || setweight(to_tsvector('simple', ?), 'C'), ?)
|
|
177
|
+
ON CONFLICT (chunk_id) DO UPDATE SET item_version_id = EXCLUDED.item_version_id, audience_ids = EXCLUDED.audience_ids, document = EXCLUDED.document, updated_at = EXCLUDED.updated_at
|
|
178
|
+
`,
|
|
179
|
+
args: [
|
|
180
|
+
input.chunkId,
|
|
181
|
+
input.itemVersionId,
|
|
182
|
+
...(input.audienceIds ?? []),
|
|
183
|
+
input.title,
|
|
184
|
+
input.summary ?? "",
|
|
185
|
+
input.body,
|
|
186
|
+
input.updatedAt ?? new Date().toISOString(),
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
export async function queryPostgresFts(db, input) {
|
|
192
|
+
const namespace = input.namespace ?? DEFAULT_SEARCH_NAMESPACE;
|
|
193
|
+
const names = searchNamespaceIdentifiers(namespace);
|
|
194
|
+
if (!isPostgres() ||
|
|
195
|
+
input.allowedChunkIds?.length === 0 ||
|
|
196
|
+
input.allowedAudienceIds?.length === 0)
|
|
197
|
+
return [];
|
|
198
|
+
const keys = input.allowedChunkIds?.length
|
|
199
|
+
? `chunk_id IN (${input.allowedChunkIds.map(() => "?").join(", ")}) AND`
|
|
200
|
+
: "";
|
|
201
|
+
const audiences = audienceClause(input.allowedAudienceIds);
|
|
202
|
+
const limit = Math.max(1, Math.min(200, Math.floor(input.limit ?? 40)));
|
|
203
|
+
try {
|
|
204
|
+
const result = await db.execute({
|
|
205
|
+
sql: `SELECT chunk_id, item_version_id, ts_rank_cd(document, websearch_to_tsquery('simple', ?)) AS score FROM ${names.ftsTable} WHERE ${keys} document @@ websearch_to_tsquery('simple', ?)${audiences.sql} ORDER BY score DESC, chunk_id ASC LIMIT ?`,
|
|
206
|
+
args: [
|
|
207
|
+
input.query,
|
|
208
|
+
...(input.allowedChunkIds ?? []),
|
|
209
|
+
input.query,
|
|
210
|
+
...audiences.args,
|
|
211
|
+
limit,
|
|
212
|
+
],
|
|
213
|
+
});
|
|
214
|
+
return result.rows.map((row) => ({
|
|
215
|
+
chunkId: String(row.chunk_id),
|
|
216
|
+
itemVersionId: String(row.item_version_id),
|
|
217
|
+
score: Number(row.score),
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
// A read can race the first write for a tenant-specific namespace. Writers
|
|
222
|
+
// provision it; an absent lane simply contributes no candidates.
|
|
223
|
+
if (isMissingPostgresRelation(error))
|
|
224
|
+
return [];
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function isMissingPostgresRelation(error) {
|
|
229
|
+
if (!error || typeof error !== "object")
|
|
230
|
+
return false;
|
|
231
|
+
return error.code === "42P01";
|
|
232
|
+
}
|
|
233
|
+
export async function deletePostgresFtsDocuments(db, chunkIds, namespace = DEFAULT_SEARCH_NAMESPACE) {
|
|
234
|
+
const names = searchNamespaceIdentifiers(namespace);
|
|
235
|
+
if (!isPostgres() || !chunkIds.length)
|
|
236
|
+
return 0;
|
|
237
|
+
await ensurePostgresFts(db, namespace);
|
|
238
|
+
const result = await db.execute({
|
|
239
|
+
sql: `DELETE FROM ${names.ftsTable} WHERE chunk_id IN (${chunkIds.map(() => "?").join(", ")})`,
|
|
240
|
+
args: [...chunkIds],
|
|
241
|
+
});
|
|
242
|
+
return result.rowsAffected;
|
|
243
|
+
}
|
|
244
|
+
export function reciprocalRankFusion(lanes, options = {}) {
|
|
245
|
+
const rankConstant = Math.max(1, options.rankConstant ?? 60);
|
|
246
|
+
const fused = new Map();
|
|
247
|
+
for (const [lane, candidates] of Object.entries(lanes)) {
|
|
248
|
+
candidates.forEach((candidate, index) => {
|
|
249
|
+
const rank = index + 1;
|
|
250
|
+
const current = fused.get(candidate.key) ?? {
|
|
251
|
+
...candidate,
|
|
252
|
+
score: 0,
|
|
253
|
+
laneRanks: {},
|
|
254
|
+
reasons: [],
|
|
255
|
+
};
|
|
256
|
+
current.score += 1 / (rankConstant + rank);
|
|
257
|
+
current.laneRanks[lane] = rank;
|
|
258
|
+
if (candidate.reason && !current.reasons.includes(candidate.reason))
|
|
259
|
+
current.reasons.push(candidate.reason);
|
|
260
|
+
fused.set(candidate.key, current);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
return [...fused.values()]
|
|
264
|
+
.sort((a, b) => b.score - a.score || a.key.localeCompare(b.key))
|
|
265
|
+
.slice(0, Math.max(1, options.limit ?? 40));
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GACpC,sGAAsG,CAAC;AA6CzG,SAAS,eAAe,CAAC,OAAoC;IAC3D,OAAO,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,SAAS,GAAG,wBAAwB,EACpC,UAAmB;IAEnB,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,mHAAmH,CACpH,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GACV,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC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EAAE,EAAE;YACtC,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;YACvB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI;gBAC1C,GAAG,SAAS;gBACZ,KAAK,EAAE,CAAC;gBACR,SAAS,EAAE,EAAE;gBACb,OAAO,EAAE,EAAE;aACZ,CAAC;YACF,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;YAC3C,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;YAC/B,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC;gBACjE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACzC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;SACvB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SAC/D,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { DbExec } from \"../db/index.js\";\nimport { isPostgres } from \"../db/index.js\";\n\nexport const DEFAULT_SEARCH_NAMESPACE = \"creative_context\";\nexport const PGVECTOR_REQUIRED_MESSAGE =\n \"Vector search requires Postgres with the pgvector extension in the configured DATABASE_URL database.\";\n\nexport interface SearchNamespaceIdentifiers {\n namespace: string;\n ftsTable: string;\n ftsIndex: string;\n ftsAudienceIndex: string;\n vectorTable: string;\n vectorIndex: string;\n vectorAudienceIndex: string;\n}\n\nexport interface PgVectorHit {\n vectorKey: string;\n embeddingSetId: string;\n score: number;\n}\n\nexport interface PostgresFtsHit {\n chunkId: string;\n itemVersionId: string;\n score: number;\n}\n\nexport interface RankedCandidate<T> {\n key: string;\n value: T;\n score: number;\n reason?: string;\n}\n\nexport interface FusedCandidate<T> extends RankedCandidate<T> {\n laneRanks: Record<string, number>;\n reasons: string[];\n}\n\ntype PgVectorOptions =\n | boolean\n | {\n namespace?: string;\n postgres?: boolean;\n /** The caller has already provisioned this namespace and dimension. */\n indexInitialized?: boolean;\n };\n\nfunction pgVectorOptions(options: PgVectorOptions | undefined) {\n return typeof options === \"boolean\" ? { postgres: options } : (options ?? {});\n}\n\nexport function searchNamespaceIdentifiers(\n namespace = DEFAULT_SEARCH_NAMESPACE,\n dimensions?: number,\n): SearchNamespaceIdentifiers {\n if (!/^[a-z][a-z0-9_]{0,62}$/.test(namespace)) {\n throw new Error(\n \"Search namespace must start with a lowercase letter and contain only lowercase letters, numbers, and underscores.\",\n );\n }\n const suffix =\n dimensions === undefined ? \"\" : `_${checkedDimensions(dimensions)}`;\n return {\n namespace,\n ftsTable: `${namespace}_search_documents`,\n ftsIndex: `${namespace}_search_documents_gin`,\n ftsAudienceIndex: `${namespace}_search_documents_audience_gin`,\n vectorTable: `${namespace}_vectors${suffix}`,\n vectorIndex: `${namespace}_vectors${suffix}_hnsw`,\n vectorAudienceIndex: `${namespace}_vectors${suffix}_audience_gin`,\n };\n}\n\nfunction checkedDimensions(value: number): number {\n if (!Number.isInteger(value) || value < 1 || value > 16_000) {\n throw new Error(\"Embedding dimensions must be an integer from 1 to 16000.\");\n }\n return value;\n}\n\nfunction vectorLiteral(vector: readonly number[], dimensions: number): string {\n if (vector.length !== dimensions) {\n throw new Error(\n `Embedding has ${vector.length} values; expected ${dimensions}.`,\n );\n }\n for (const value of vector) {\n if (!Number.isFinite(value)) {\n throw new Error(\"Embedding vectors may contain only finite numbers.\");\n }\n }\n return `[${vector.join(\",\")}]`;\n}\n\nfunction audienceClause(\n audienceIds: readonly string[] | undefined,\n column = \"audience_ids\",\n): { sql: string; args: string[] } {\n if (!audienceIds?.length) return { sql: \"\", args: [] };\n return {\n sql: ` AND ${column} && ARRAY[${audienceIds.map(() => \"?\").join(\", \")}]::TEXT[]`,\n args: [...audienceIds],\n };\n}\n\nexport function assertPgVectorAvailable(postgres = isPostgres()): void {\n if (!postgres) throw new Error(PGVECTOR_REQUIRED_MESSAGE);\n}\n\nexport async function ensurePgVectorIndex(\n db: DbExec,\n dimensions: number,\n options?: PgVectorOptions,\n): Promise<void> {\n const resolved = pgVectorOptions(options);\n const names = searchNamespaceIdentifiers(resolved.namespace, dimensions);\n assertPgVectorAvailable(resolved.postgres);\n try {\n await db.execute(\"CREATE EXTENSION IF NOT EXISTS vector\");\n await db.execute(`\n CREATE TABLE IF NOT EXISTS ${names.vectorTable} (\n vector_key TEXT PRIMARY KEY,\n embedding_set_id TEXT NOT NULL,\n audience_ids TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[],\n embedding vector(${checkedDimensions(dimensions)}) NOT NULL,\n updated_at TEXT NOT NULL\n )\n `);\n await db.execute(\n `ALTER TABLE ${names.vectorTable} ADD COLUMN IF NOT EXISTS audience_ids TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[]`,\n );\n await db.execute(\n `CREATE INDEX IF NOT EXISTS ${names.vectorIndex} ON ${names.vectorTable} USING hnsw (embedding vector_cosine_ops)`,\n );\n await db.execute(\n `CREATE INDEX IF NOT EXISTS ${names.vectorAudienceIndex} ON ${names.vectorTable} USING GIN (audience_ids)`,\n );\n } catch (error) {\n throw new Error(PGVECTOR_REQUIRED_MESSAGE, { cause: error });\n }\n}\n\nexport async function upsertPgVector(\n db: DbExec,\n input: {\n vectorKey: string;\n embeddingSetId: string;\n dimensions: number;\n vector: readonly number[];\n audienceIds?: readonly string[];\n updatedAt?: string;\n },\n options?: PgVectorOptions,\n): Promise<void> {\n const resolved = pgVectorOptions(options);\n const names = searchNamespaceIdentifiers(\n resolved.namespace,\n input.dimensions,\n );\n assertPgVectorAvailable(resolved.postgres);\n if (!resolved.indexInitialized) {\n await ensurePgVectorIndex(db, input.dimensions, resolved);\n }\n await db.execute({\n sql: `\n INSERT INTO ${names.vectorTable} (vector_key, embedding_set_id, audience_ids, embedding, updated_at)\n VALUES (?, ?, ARRAY[${(input.audienceIds ?? []).map(() => \"?\").join(\", \")}]::TEXT[], ?::vector, ?)\n ON CONFLICT (vector_key) DO UPDATE SET\n embedding_set_id = EXCLUDED.embedding_set_id,\n audience_ids = EXCLUDED.audience_ids,\n embedding = EXCLUDED.embedding,\n updated_at = EXCLUDED.updated_at\n `,\n args: [\n input.vectorKey,\n input.embeddingSetId,\n ...(input.audienceIds ?? []),\n vectorLiteral(input.vector, input.dimensions),\n input.updatedAt ?? new Date().toISOString(),\n ],\n });\n}\n\nexport async function deletePgVectors(\n db: DbExec,\n input: {\n dimensions: number;\n vectorKeys: readonly string[];\n namespace?: string;\n },\n postgres = isPostgres(),\n): Promise<number> {\n const names = searchNamespaceIdentifiers(input.namespace, input.dimensions);\n assertPgVectorAvailable(postgres);\n if (!input.vectorKeys.length) return 0;\n const result = await db.execute({\n sql: `DELETE FROM ${names.vectorTable} WHERE vector_key IN (${input.vectorKeys.map(() => \"?\").join(\", \")})`,\n args: [...input.vectorKeys],\n });\n return result.rowsAffected;\n}\n\nexport async function queryPgVectorIndex(\n db: DbExec,\n input: {\n embeddingSetId: string;\n dimensions: number;\n vector: readonly number[];\n limit?: number;\n allowedVectorKeys?: readonly string[];\n allowedAudienceIds?: readonly string[];\n namespace?: string;\n },\n postgres = isPostgres(),\n): Promise<PgVectorHit[]> {\n const names = searchNamespaceIdentifiers(input.namespace, input.dimensions);\n assertPgVectorAvailable(postgres);\n if (\n input.allowedVectorKeys?.length === 0 ||\n input.allowedAudienceIds?.length === 0\n )\n return [];\n const limit = Math.max(1, Math.min(200, Math.floor(input.limit ?? 40)));\n const literal = vectorLiteral(input.vector, input.dimensions);\n const keySql = input.allowedVectorKeys?.length\n ? ` AND vector_key IN (${input.allowedVectorKeys.map(() => \"?\").join(\", \")})`\n : \"\";\n const audiences = audienceClause(input.allowedAudienceIds);\n try {\n await db.execute(\"SET hnsw.iterative_scan = strict_order\");\n } catch {}\n const result = await db.execute({\n sql: `\n SELECT vector_key, embedding_set_id, 1 - (embedding <=> ?::vector) AS score\n FROM ${names.vectorTable}\n WHERE embedding_set_id = ?${keySql}${audiences.sql}\n ORDER BY embedding <=> ?::vector\n LIMIT ?\n `,\n args: [\n literal,\n input.embeddingSetId,\n ...(input.allowedVectorKeys ?? []),\n ...audiences.args,\n literal,\n limit,\n ],\n });\n return result.rows.map((row) => ({\n vectorKey: String(row.vector_key),\n embeddingSetId: String(row.embedding_set_id),\n score: Number(row.score),\n }));\n}\n\nexport async function ensurePostgresFts(\n db: DbExec,\n namespace = DEFAULT_SEARCH_NAMESPACE,\n): Promise<boolean> {\n const names = searchNamespaceIdentifiers(namespace);\n if (!isPostgres()) return false;\n await db.execute(`\n CREATE TABLE IF NOT EXISTS ${names.ftsTable} (\n chunk_id TEXT PRIMARY KEY,\n item_version_id TEXT NOT NULL,\n audience_ids TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[],\n document TSVECTOR NOT NULL,\n updated_at TEXT NOT NULL\n )\n `);\n await db.execute(\n `ALTER TABLE ${names.ftsTable} ADD COLUMN IF NOT EXISTS audience_ids TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[]`,\n );\n await db.execute(\n `CREATE INDEX IF NOT EXISTS ${names.ftsIndex} ON ${names.ftsTable} USING GIN (document)`,\n );\n await db.execute(\n `CREATE INDEX IF NOT EXISTS ${names.ftsAudienceIndex} ON ${names.ftsTable} USING GIN (audience_ids)`,\n );\n return true;\n}\n\nexport async function upsertPostgresFtsDocument(\n db: DbExec,\n input: {\n chunkId: string;\n itemVersionId: string;\n title: string;\n summary?: string | null;\n body: string;\n audienceIds?: readonly string[];\n updatedAt?: string;\n namespace?: string;\n },\n): Promise<boolean> {\n const namespace = input.namespace ?? DEFAULT_SEARCH_NAMESPACE;\n if (!(await ensurePostgresFts(db, namespace))) return false;\n const names = searchNamespaceIdentifiers(namespace);\n await db.execute({\n sql: `\n INSERT INTO ${names.ftsTable} (chunk_id, item_version_id, audience_ids, document, updated_at)\n VALUES (?, ?, ARRAY[${(input.audienceIds ?? []).map(() => \"?\").join(\", \")}]::TEXT[], setweight(to_tsvector('simple', ?), 'A') || setweight(to_tsvector('simple', ?), 'B') || setweight(to_tsvector('simple', ?), 'C'), ?)\n ON CONFLICT (chunk_id) DO UPDATE SET item_version_id = EXCLUDED.item_version_id, audience_ids = EXCLUDED.audience_ids, document = EXCLUDED.document, updated_at = EXCLUDED.updated_at\n `,\n args: [\n input.chunkId,\n input.itemVersionId,\n ...(input.audienceIds ?? []),\n input.title,\n input.summary ?? \"\",\n input.body,\n input.updatedAt ?? new Date().toISOString(),\n ],\n });\n return true;\n}\n\nexport async function queryPostgresFts(\n db: DbExec,\n input: {\n query: string;\n allowedChunkIds?: readonly string[];\n allowedAudienceIds?: readonly string[];\n limit?: number;\n namespace?: string;\n },\n): Promise<PostgresFtsHit[]> {\n const namespace = input.namespace ?? DEFAULT_SEARCH_NAMESPACE;\n const names = searchNamespaceIdentifiers(namespace);\n if (\n !isPostgres() ||\n input.allowedChunkIds?.length === 0 ||\n input.allowedAudienceIds?.length === 0\n )\n return [];\n const keys = input.allowedChunkIds?.length\n ? `chunk_id IN (${input.allowedChunkIds.map(() => \"?\").join(\", \")}) AND`\n : \"\";\n const audiences = audienceClause(input.allowedAudienceIds);\n const limit = Math.max(1, Math.min(200, Math.floor(input.limit ?? 40)));\n try {\n const result = await db.execute({\n sql: `SELECT chunk_id, item_version_id, ts_rank_cd(document, websearch_to_tsquery('simple', ?)) AS score FROM ${names.ftsTable} WHERE ${keys} document @@ websearch_to_tsquery('simple', ?)${audiences.sql} ORDER BY score DESC, chunk_id ASC LIMIT ?`,\n args: [\n input.query,\n ...(input.allowedChunkIds ?? []),\n input.query,\n ...audiences.args,\n limit,\n ],\n });\n return result.rows.map((row) => ({\n chunkId: String(row.chunk_id),\n itemVersionId: String(row.item_version_id),\n score: Number(row.score),\n }));\n } catch (error) {\n // A read can race the first write for a tenant-specific namespace. Writers\n // provision it; an absent lane simply contributes no candidates.\n if (isMissingPostgresRelation(error)) return [];\n throw error;\n }\n}\n\nfunction isMissingPostgresRelation(error: unknown): boolean {\n if (!error || typeof error !== \"object\") return false;\n return (error as { code?: unknown }).code === \"42P01\";\n}\n\nexport async function deletePostgresFtsDocuments(\n db: DbExec,\n chunkIds: readonly string[],\n namespace = DEFAULT_SEARCH_NAMESPACE,\n): Promise<number> {\n const names = searchNamespaceIdentifiers(namespace);\n if (!isPostgres() || !chunkIds.length) return 0;\n await ensurePostgresFts(db, namespace);\n const result = await db.execute({\n sql: `DELETE FROM ${names.ftsTable} WHERE chunk_id IN (${chunkIds.map(() => \"?\").join(\", \")})`,\n args: [...chunkIds],\n });\n return result.rowsAffected;\n}\n\nexport function reciprocalRankFusion<T>(\n lanes: Readonly<Record<string, readonly RankedCandidate<T>[]>>,\n options: { rankConstant?: number; limit?: number } = {},\n): FusedCandidate<T>[] {\n const rankConstant = Math.max(1, options.rankConstant ?? 60);\n const fused = new Map<string, FusedCandidate<T>>();\n for (const [lane, candidates] of Object.entries(lanes)) {\n candidates.forEach((candidate, index) => {\n const rank = index + 1;\n const current = fused.get(candidate.key) ?? {\n ...candidate,\n score: 0,\n laneRanks: {},\n reasons: [],\n };\n current.score += 1 / (rankConstant + rank);\n current.laneRanks[lane] = rank;\n if (candidate.reason && !current.reasons.includes(candidate.reason))\n current.reasons.push(candidate.reason);\n fused.set(candidate.key, current);\n });\n }\n return [...fused.values()]\n .sort((a, b) => b.score - a.score || a.key.localeCompare(b.key))\n .slice(0, Math.max(1, options.limit ?? 40));\n}\n"]}
|
|
@@ -27,11 +27,11 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
|
|
|
27
27
|
export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
28
28
|
error: any;
|
|
29
29
|
} | {
|
|
30
|
+
error?: undefined;
|
|
30
31
|
ok: boolean;
|
|
31
32
|
key: string;
|
|
32
33
|
baseUrlKey?: string;
|
|
33
34
|
scope: AgentEngineApiKeyScope;
|
|
34
|
-
error?: undefined;
|
|
35
35
|
}>>;
|
|
36
36
|
export {};
|
|
37
37
|
//# sourceMappingURL=agent-engine-api-key-route.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.112.0",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"./integrations": "./dist/integrations/index.js",
|
|
66
66
|
"./ingestion": "./dist/ingestion/index.js",
|
|
67
67
|
"./search-utils": "./dist/search-utils/index.js",
|
|
68
|
+
"./search": "./dist/search/index.js",
|
|
69
|
+
"./embeddings": "./dist/embeddings/index.js",
|
|
68
70
|
"./automation": "./dist/automation/index.js",
|
|
69
71
|
"./brand-kit": "./dist/brand-kit/index.js",
|
|
70
72
|
"./brand-kit/fig": "./dist/brand-kit/fig/index.js",
|