@inkeep/agents-core 0.35.2 → 0.35.4

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.
@@ -1,13 +1,13 @@
1
1
  import * as better_auth_adapters from 'better-auth/adapters';
2
2
  import * as better_auth from 'better-auth';
3
3
  import { BetterAuthPlugin } from 'better-auth';
4
- import { D as DatabaseClient } from '../client-CPYOMZF2.js';
4
+ import { D as DatabaseClient } from '../client-HrEgt7wv.js';
5
5
  import 'drizzle-orm/node-postgres';
6
6
  import 'drizzle-orm/pglite';
7
- import '../schema-5N2lPWNV.js';
7
+ import '../schema-CoC3tYFX.js';
8
8
  import 'drizzle-orm';
9
9
  import 'drizzle-orm/pg-core';
10
- import '../utility-DbltUp2Q.js';
10
+ import '../utility-C4QAannk.js';
11
11
  import 'zod';
12
12
  import 'drizzle-zod';
13
13
  import '@hono/zod-openapi';
package/dist/auth/auth.js CHANGED
@@ -1,6 +1,7 @@
1
- import { createTestDatabaseClient, generateId } from '../chunk-ZYSTJ4XY.js';
2
- import { ownerRole, adminRole, memberRole, ac } from '../chunk-F5WWOOIX.js';
1
+ import { generateId } from '../chunk-D3NGJEP2.js';
2
+ import { createTestDatabaseClient } from '../chunk-SG75RA63.js';
3
3
  import { ssoProvider } from '../chunk-NOPEANIU.js';
4
+ import { ownerRole, adminRole, memberRole, ac } from '../chunk-F5WWOOIX.js';
4
5
  import { sso } from '@better-auth/sso';
5
6
  import { betterAuth } from 'better-auth';
6
7
  import { drizzleAdapter } from 'better-auth/adapters/drizzle';
@@ -1,42 +1,10 @@
1
- import { VALID_RELATION_TYPES, MCPTransportType, TOOL_STATUS_VALUES, CredentialStoreType, MCPServerType } from './chunk-YFHT5M2R.js';
1
+ import { schemaValidationDefaults } from './chunk-Z64UK4CA.js';
2
2
  import { subAgents, subAgentRelations, agents, tasks, taskRelations, conversations, messages, contextCache, dataComponents, subAgentDataComponents, artifactComponents, subAgentArtifactComponents, externalAgents, apiKeys, credentialReferences, tools, functionTools, functions, contextConfigs, subAgentToolRelations, subAgentExternalAgentRelations, subAgentTeamAgentRelations, ledgerArtifacts, projects } from './chunk-NFYCSHD3.js';
3
+ import { VALID_RELATION_TYPES, MCPTransportType, TOOL_STATUS_VALUES, CredentialStoreType, MCPServerType } from './chunk-YFHT5M2R.js';
3
4
  import { z } from '@hono/zod-openapi';
4
5
  import { createSelectSchema as createSelectSchema$1, createInsertSchema as createInsertSchema$1 } from 'drizzle-zod';
5
6
  import Ajv from 'ajv';
6
7
 
7
- // src/constants/schema-validation/defaults.ts
8
- var schemaValidationDefaults = {
9
- // Agent Execution Transfer Count
10
- // Controls how many times an agent can transfer control to sub-agents in a single conversation turn.
11
- // This prevents infinite transfer loops while allowing multi-agent collaboration workflows.
12
- AGENT_EXECUTION_TRANSFER_COUNT_MIN: 1,
13
- AGENT_EXECUTION_TRANSFER_COUNT_MAX: 1e3,
14
- AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT: 10,
15
- // Sub-Agent Turn Generation Steps
16
- // Limits how many AI generation steps a sub-agent can perform within a single turn.
17
- // Each generation step typically involves sending a prompt to the LLM and processing its response.
18
- // This prevents runaway token usage while allowing complex multi-step reasoning.
19
- SUB_AGENT_TURN_GENERATION_STEPS_MIN: 1,
20
- SUB_AGENT_TURN_GENERATION_STEPS_MAX: 1e3,
21
- SUB_AGENT_TURN_GENERATION_STEPS_DEFAULT: 12,
22
- // Status Update Thresholds
23
- // Real-time status updates are triggered when either threshold is exceeded during longer operations.
24
- // MAX_NUM_EVENTS: Maximum number of internal events before forcing a status update to the client.
25
- // MAX_INTERVAL_SECONDS: Maximum time between status updates regardless of event count.
26
- STATUS_UPDATE_MAX_NUM_EVENTS: 100,
27
- STATUS_UPDATE_MAX_INTERVAL_SECONDS: 600,
28
- // 10 minutes
29
- // Prompt Text Length Validation
30
- // Maximum character limits for agent and sub-agent system prompts to prevent excessive token usage.
31
- // Enforced during agent configuration to ensure prompts remain focused and manageable.
32
- VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS: 2e3,
33
- VALIDATION_AGENT_PROMPT_MAX_CHARS: 5e3,
34
- // Context Fetcher HTTP Timeout
35
- // Maximum time allowed for HTTP requests made by Context Fetchers (e.g., CRM lookups, external API calls).
36
- // Context Fetchers automatically retrieve external data at the start of a conversation to enrich agent context.
37
- CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT: 1e4
38
- // 10 seconds
39
- };
40
8
  var MIN_ID_LENGTH = 1;
41
9
  var MAX_ID_LENGTH = 255;
42
10
  var URL_SAFE_ID_PATTERN = /^[a-zA-Z0-9\-_.]+$/;
@@ -1111,6 +1079,23 @@ var PaginationQueryParamsSchema = z.object({
1111
1079
  page: pageNumber,
1112
1080
  limit: limitNumber
1113
1081
  }).openapi("PaginationQueryParams");
1082
+ var PrebuiltMCPServerSchema = z.object({
1083
+ id: z.string().describe("Unique identifier for the MCP server"),
1084
+ name: z.string().describe("Display name of the MCP server"),
1085
+ url: z.url().describe("URL endpoint for the MCP server"),
1086
+ transport: z.enum(MCPTransportType).describe("Transport protocol type"),
1087
+ imageUrl: z.url().optional().describe("Logo/icon URL for the MCP server"),
1088
+ isOpen: z.boolean().optional().describe("Whether the MCP server is open (doesn't require authentication)"),
1089
+ category: z.string().optional().describe("Category of the MCP server (e.g., communication, project_management)"),
1090
+ description: z.string().optional().describe("Brief description of what the MCP server does"),
1091
+ thirdPartyConnectAccountUrl: z.url().optional().describe("URL to connect to the third party account")
1092
+ });
1093
+ var MCPCatalogListResponse = z.object({
1094
+ data: z.array(PrebuiltMCPServerSchema)
1095
+ }).openapi("MCPCatalogListResponse");
1096
+ var ThirdPartyMCPServerResponse = z.object({
1097
+ data: PrebuiltMCPServerSchema.nullable()
1098
+ }).openapi("ThirdPartyMCPServerResponse");
1114
1099
  function validatePropsAsJsonSchema(props) {
1115
1100
  if (!props || typeof props === "object" && Object.keys(props).length === 0) {
1116
1101
  return {
@@ -1214,4 +1199,4 @@ function validatePropsAsJsonSchema(props) {
1214
1199
  }
1215
1200
  }
1216
1201
 
1217
- export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentInsertSchema, AgentListResponse, AgentResponse, AgentSelectSchema, AgentStopWhenSchema, AgentUpdateSchema, AgentWithinContextOfProjectResponse, AgentWithinContextOfProjectSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeyListResponse, ApiKeyResponse, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentArrayResponse, ArtifactComponentInsertSchema, ArtifactComponentListResponse, ArtifactComponentResponse, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ComponentAssociationListResponse, ComponentAssociationSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigListResponse, ContextConfigResponse, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationListResponse, ConversationResponse, ConversationSelectSchema, ConversationUpdateSchema, CreateCredentialInStoreRequestSchema, CreateCredentialInStoreResponseSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceListResponse, CredentialReferenceResponse, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, CredentialStoreListResponseSchema, CredentialStoreSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentArrayResponse, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentListResponse, DataComponentResponse, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentListResponse, ExternalAgentResponse, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, ExternalSubAgentRelationApiInsertSchema, ExternalSubAgentRelationInsertSchema, FetchConfigSchema, FetchDefinitionSchema, FullAgentAgentInsertSchema, FullProjectDefinitionResponse, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionListResponse, FunctionResponse, FunctionSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiSelectSchema, FunctionToolApiUpdateSchema, FunctionToolConfigSchema, FunctionToolInsertSchema, FunctionToolListResponse, FunctionToolResponse, FunctionToolSelectSchema, FunctionToolUpdateSchema, FunctionUpdateSchema, HeadersScopeSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolListResponse, McpToolResponse, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageListResponse, MessageResponse, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, OAuthCallbackQuerySchema, OAuthLoginQuerySchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectListResponse, ProjectModelSchema, ProjectResponse, ProjectSelectSchema, ProjectUpdateSchema, RelatedAgentInfoListResponse, RelatedAgentInfoSchema, RemovedResponseSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, SubAgentApiInsertSchema, SubAgentApiSelectSchema, SubAgentApiUpdateSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiUpdateSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentListResponse, SubAgentArtifactComponentResponse, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentUpdateSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiUpdateSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentListResponse, SubAgentDataComponentResponse, SubAgentDataComponentSelectSchema, SubAgentDataComponentUpdateSchema, SubAgentExternalAgentRelationApiInsertSchema, SubAgentExternalAgentRelationApiSelectSchema, SubAgentExternalAgentRelationApiUpdateSchema, SubAgentExternalAgentRelationInsertSchema, SubAgentExternalAgentRelationListResponse, SubAgentExternalAgentRelationResponse, SubAgentExternalAgentRelationSelectSchema, SubAgentExternalAgentRelationUpdateSchema, SubAgentInsertSchema, SubAgentListResponse, SubAgentRelationApiInsertSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationInsertSchema, SubAgentRelationListResponse, SubAgentRelationQuerySchema, SubAgentRelationResponse, SubAgentRelationSelectSchema, SubAgentRelationUpdateSchema, SubAgentResponse, SubAgentSelectSchema, SubAgentStopWhenSchema, SubAgentTeamAgentRelationApiInsertSchema, SubAgentTeamAgentRelationApiSelectSchema, SubAgentTeamAgentRelationApiUpdateSchema, SubAgentTeamAgentRelationInsertSchema, SubAgentTeamAgentRelationListResponse, SubAgentTeamAgentRelationResponse, SubAgentTeamAgentRelationSelectSchema, SubAgentTeamAgentRelationUpdateSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, SubAgentToolRelationSelectSchema, SubAgentToolRelationUpdateSchema, SubAgentUpdateSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TeamAgentSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolListResponse, ToolResponse, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, canDelegateToExternalAgentSchema, canDelegateToTeamAgentSchema, resourceIdSchema, schemaValidationDefaults, validatePropsAsJsonSchema };
1202
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentInsertSchema, AgentListResponse, AgentResponse, AgentSelectSchema, AgentStopWhenSchema, AgentUpdateSchema, AgentWithinContextOfProjectResponse, AgentWithinContextOfProjectSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeyListResponse, ApiKeyResponse, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentArrayResponse, ArtifactComponentInsertSchema, ArtifactComponentListResponse, ArtifactComponentResponse, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ComponentAssociationListResponse, ComponentAssociationSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigListResponse, ContextConfigResponse, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationListResponse, ConversationResponse, ConversationSelectSchema, ConversationUpdateSchema, CreateCredentialInStoreRequestSchema, CreateCredentialInStoreResponseSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceListResponse, CredentialReferenceResponse, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, CredentialStoreListResponseSchema, CredentialStoreSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentArrayResponse, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentListResponse, DataComponentResponse, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentListResponse, ExternalAgentResponse, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, ExternalSubAgentRelationApiInsertSchema, ExternalSubAgentRelationInsertSchema, FetchConfigSchema, FetchDefinitionSchema, FullAgentAgentInsertSchema, FullProjectDefinitionResponse, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionListResponse, FunctionResponse, FunctionSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiSelectSchema, FunctionToolApiUpdateSchema, FunctionToolConfigSchema, FunctionToolInsertSchema, FunctionToolListResponse, FunctionToolResponse, FunctionToolSelectSchema, FunctionToolUpdateSchema, FunctionUpdateSchema, HeadersScopeSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPCatalogListResponse, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolListResponse, McpToolResponse, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageListResponse, MessageResponse, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, OAuthCallbackQuerySchema, OAuthLoginQuerySchema, PaginationQueryParamsSchema, PaginationSchema, PrebuiltMCPServerSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectListResponse, ProjectModelSchema, ProjectResponse, ProjectSelectSchema, ProjectUpdateSchema, RelatedAgentInfoListResponse, RelatedAgentInfoSchema, RemovedResponseSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, SubAgentApiInsertSchema, SubAgentApiSelectSchema, SubAgentApiUpdateSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiUpdateSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentListResponse, SubAgentArtifactComponentResponse, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentUpdateSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiUpdateSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentListResponse, SubAgentDataComponentResponse, SubAgentDataComponentSelectSchema, SubAgentDataComponentUpdateSchema, SubAgentExternalAgentRelationApiInsertSchema, SubAgentExternalAgentRelationApiSelectSchema, SubAgentExternalAgentRelationApiUpdateSchema, SubAgentExternalAgentRelationInsertSchema, SubAgentExternalAgentRelationListResponse, SubAgentExternalAgentRelationResponse, SubAgentExternalAgentRelationSelectSchema, SubAgentExternalAgentRelationUpdateSchema, SubAgentInsertSchema, SubAgentListResponse, SubAgentRelationApiInsertSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationInsertSchema, SubAgentRelationListResponse, SubAgentRelationQuerySchema, SubAgentRelationResponse, SubAgentRelationSelectSchema, SubAgentRelationUpdateSchema, SubAgentResponse, SubAgentSelectSchema, SubAgentStopWhenSchema, SubAgentTeamAgentRelationApiInsertSchema, SubAgentTeamAgentRelationApiSelectSchema, SubAgentTeamAgentRelationApiUpdateSchema, SubAgentTeamAgentRelationInsertSchema, SubAgentTeamAgentRelationListResponse, SubAgentTeamAgentRelationResponse, SubAgentTeamAgentRelationSelectSchema, SubAgentTeamAgentRelationUpdateSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, SubAgentToolRelationSelectSchema, SubAgentToolRelationUpdateSchema, SubAgentUpdateSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TeamAgentSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ThirdPartyMCPServerResponse, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolListResponse, ToolResponse, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, canDelegateToExternalAgentSchema, canDelegateToTeamAgentSchema, resourceIdSchema, validatePropsAsJsonSchema };
@@ -0,0 +1,59 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import dotenv from 'dotenv';
5
+ import { expand } from 'dotenv-expand';
6
+ import { findUpSync } from 'find-up';
7
+ import { z } from 'zod';
8
+
9
+ // src/env.ts
10
+ var loadEnvironmentFiles = () => {
11
+ const environmentFiles = [];
12
+ const currentEnv = path.resolve(process.cwd(), ".env");
13
+ if (fs.existsSync(currentEnv)) {
14
+ environmentFiles.push(currentEnv);
15
+ }
16
+ const rootEnv = findUpSync(".env", { cwd: path.dirname(process.cwd()) });
17
+ if (rootEnv) {
18
+ if (rootEnv !== currentEnv) {
19
+ environmentFiles.push(rootEnv);
20
+ }
21
+ }
22
+ const userConfigPath = path.join(os.homedir(), ".inkeep", "config");
23
+ if (fs.existsSync(userConfigPath)) {
24
+ dotenv.config({ path: userConfigPath, override: true, quiet: true });
25
+ }
26
+ if (environmentFiles.length > 0) {
27
+ dotenv.config({
28
+ path: environmentFiles,
29
+ override: false,
30
+ quiet: true
31
+ });
32
+ expand({ processEnv: process.env });
33
+ }
34
+ };
35
+ loadEnvironmentFiles();
36
+ var envSchema = z.object({
37
+ ENVIRONMENT: z.enum(["development", "production", "pentest", "test"]).optional(),
38
+ DATABASE_URL: z.string().optional(),
39
+ POSTGRES_POOL_SIZE: z.string().optional(),
40
+ INKEEP_AGENTS_JWT_SIGNING_SECRET: z.string().min(32, "INKEEP_AGENTS_JWT_SIGNING_SECRET must be at least 32 characters").optional()
41
+ });
42
+ var parseEnv = () => {
43
+ try {
44
+ const parsedEnv = envSchema.parse(process.env);
45
+ return parsedEnv;
46
+ } catch (error) {
47
+ if (error instanceof z.ZodError) {
48
+ const missingVars = error.issues.map((issue) => issue.path.join("."));
49
+ throw new Error(
50
+ `\u274C Invalid environment variables: ${missingVars.join(", ")}
51
+ ${error.message}`
52
+ );
53
+ }
54
+ throw error;
55
+ }
56
+ };
57
+ var env = parseEnv();
58
+
59
+ export { env, loadEnvironmentFiles };
@@ -0,0 +1,63 @@
1
+ import { getLogger } from './chunk-DN4B564Y.js';
2
+ import { z } from 'zod';
3
+
4
+ var logger = getLogger("schema-conversion");
5
+ function convertZodToJsonSchema(zodSchema) {
6
+ try {
7
+ const jsonSchema = z.toJSONSchema(zodSchema);
8
+ if (jsonSchema.$schema) {
9
+ delete jsonSchema.$schema;
10
+ }
11
+ return jsonSchema;
12
+ } catch (error) {
13
+ logger.error(
14
+ {
15
+ error: error instanceof Error ? error.message : "Unknown error",
16
+ stack: error instanceof Error ? error.stack : void 0
17
+ },
18
+ "Failed to convert Zod schema to JSON Schema"
19
+ );
20
+ throw new Error("Failed to convert Zod schema to JSON Schema");
21
+ }
22
+ }
23
+ var preview = (schema) => {
24
+ schema._def.inPreview = true;
25
+ return schema;
26
+ };
27
+ function convertZodToJsonSchemaWithPreview(zodSchema) {
28
+ const jsonSchema = convertZodToJsonSchema(zodSchema);
29
+ if (zodSchema instanceof z.ZodObject && jsonSchema.properties) {
30
+ const shape = zodSchema.shape;
31
+ for (const [key, fieldSchema] of Object.entries(shape)) {
32
+ if (fieldSchema?._def?.inPreview === true) {
33
+ jsonSchema.properties[key].inPreview = true;
34
+ }
35
+ }
36
+ }
37
+ return jsonSchema;
38
+ }
39
+ function isZodSchema(value) {
40
+ return value?._def?.type === "object";
41
+ }
42
+ function extractPreviewFields(schema) {
43
+ const previewFields = [];
44
+ if (schema instanceof z.ZodObject) {
45
+ const shape = schema.shape;
46
+ for (const [key, fieldSchema] of Object.entries(shape)) {
47
+ if (fieldSchema?._def?.inPreview === true) {
48
+ previewFields.push(key);
49
+ }
50
+ }
51
+ return previewFields;
52
+ }
53
+ if (schema?.type === "object" && schema.properties) {
54
+ for (const [key, prop] of Object.entries(schema.properties)) {
55
+ if (prop.inPreview === true) {
56
+ previewFields.push(key);
57
+ }
58
+ }
59
+ }
60
+ return previewFields;
61
+ }
62
+
63
+ export { convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, isZodSchema, preview };