@inkeep/agents-core 0.6.4 → 0.6.5

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.
@@ -0,0 +1,3991 @@
1
+ import { z } from 'zod';
2
+ import { l as CredentialReferenceApiInsert, m as ContextConfigSelect, e as ContextFetchDefinition, M as MCPTransportType, n as MCPToolConfig, o as GraphScopeConfig, C as ConversationHistoryConfig, p as ProjectScopeConfig, q as PaginationConfig, r as AgentGraphInsert, s as AgentGraphUpdate, t as FullGraphDefinition, u as AgentScopeConfig, v as AgentRelationInsert, E as ExternalAgentRelationInsert, w as AgentRelationUpdate, x as AgentToolRelationUpdate, f as ToolMcpConfig, g as ToolServerCapabilities, h as McpToolDefinition, y as AgentInsert, z as AgentUpdate, B as AgentSelect, D as ApiKeySelect, H as ApiKeyInsert, I as ApiKeyUpdate, J as CreateApiKeyParams, K as ApiKeyCreateResult, L as ArtifactComponentSelect, N as ArtifactComponentInsert, O as ArtifactComponentUpdate, Q as ContextCacheSelect, R as ContextCacheInsert, U as ContextConfigInsert, V as ContextConfigUpdate, W as ConversationSelect, X as ConversationInsert, i as ConversationMetadata, Y as ConversationUpdate, Z as CredentialReferenceSelect, _ as ToolSelect, $ as CredentialReferenceInsert, a0 as CredentialReferenceUpdate, a1 as DataComponentSelect, a2 as DataComponentInsert, a3 as DataComponentUpdate, a4 as ExternalAgentInsert, a5 as ExternalAgentSelect, a6 as ExternalAgentUpdate, a7 as Artifact, a8 as LedgerArtifactSelect, k as MessageMetadata, j as MessageContent, a9 as MessageVisibility, aa as MessageInsert, ab as MessageUpdate, ac as FullProjectDefinition, ad as ProjectInfo, ae as ProjectSelect, af as PaginationResult, ag as ProjectResourceCounts, ah as ProjectInsert, ai as ProjectUpdate, aj as TaskInsert, T as TaskMetadataConfig, ak as TaskSelect, al as McpTool, am as McpToolStatus, an as ToolInsert, ao as ToolUpdate, d as CredentialStoreType, ap as ExecutionContext } from './utility-CgaoTJn6.cjs';
3
+ export { b1 as A2AError, bx as A2ARequest, by as A2AResponse, aC as APIKeySecurityScheme, bC as AgentApiInsert, du as AgentApiInsertSchema, bB as AgentApiSelect, dt as AgentApiSelectSchema, bD as AgentApiUpdate, dv as AgentApiUpdateSchema, cv as AgentArtifactComponentApiInsert, eF as AgentArtifactComponentApiInsertSchema, cu as AgentArtifactComponentApiSelect, eE as AgentArtifactComponentApiSelectSchema, cw as AgentArtifactComponentApiUpdate, eG as AgentArtifactComponentApiUpdateSchema, cs as AgentArtifactComponentInsert, eC as AgentArtifactComponentInsertSchema, cr as AgentArtifactComponentSelect, eB as AgentArtifactComponentSelectSchema, ct as AgentArtifactComponentUpdate, eD as AgentArtifactComponentUpdateSchema, ay as AgentCapabilities, aM as AgentCard, d8 as AgentConversationHistoryConfig, cm as AgentDataComponentApiInsert, et as AgentDataComponentApiInsertSchema, cl as AgentDataComponentApiSelect, es as AgentDataComponentApiSelectSchema, cn as AgentDataComponentApiUpdate, eu as AgentDataComponentApiUpdateSchema, cj as AgentDataComponentInsert, eq as AgentDataComponentInsertSchema, ci as AgentDataComponentSelect, ep as AgentDataComponentSelectSchema, ck as AgentDataComponentUpdate, er as AgentDataComponentUpdateSchema, cU as AgentDefinition, bM as AgentGraphApiInsert, dJ as AgentGraphApiInsertSchema, bL as AgentGraphApiSelect, dI as AgentGraphApiSelectSchema, bN as AgentGraphApiUpdate, dK as AgentGraphApiUpdateSchema, dG as AgentGraphInsertSchema, bK as AgentGraphSelect, dF as AgentGraphSelectSchema, dH as AgentGraphUpdateSchema, dr as AgentInsertSchema, az as AgentProvider, bG as AgentRelationApiInsert, dA as AgentRelationApiInsertSchema, bF as AgentRelationApiSelect, dz as AgentRelationApiSelectSchema, bH as AgentRelationApiUpdate, dB as AgentRelationApiUpdateSchema, dx as AgentRelationInsertSchema, bI as AgentRelationQuery, dC as AgentRelationQuerySchema, bE as AgentRelationSelect, dw as AgentRelationSelectSchema, dy as AgentRelationUpdateSchema, dq as AgentSelectSchema, aA as AgentSkill, c as AgentStopWhen, A as AgentStopWhenSchema, cK as AgentToolRelationApiInsert, fh as AgentToolRelationApiInsertSchema, cJ as AgentToolRelationApiSelect, fg as AgentToolRelationApiSelectSchema, cL as AgentToolRelationApiUpdate, fi as AgentToolRelationApiUpdateSchema, cI as AgentToolRelationInsert, fe as AgentToolRelationInsertSchema, cH as AgentToolRelationSelect, fd as AgentToolRelationSelectSchema, ff as AgentToolRelationUpdateSchema, ds as AgentUpdateSchema, eN as AllAgentSchema, cA as AllAgentSelect, cE as ApiKeyApiCreationResponse, eS as ApiKeyApiCreationResponseSchema, cC as ApiKeyApiInsert, eT as ApiKeyApiInsertSchema, cB as ApiKeyApiSelect, eR as ApiKeyApiSelectSchema, cD as ApiKeyApiUpdate, eU as ApiKeyApiUpdateSchema, eP as ApiKeyInsertSchema, eO as ApiKeySelectSchema, eQ as ApiKeyUpdateSchema, cp as ArtifactComponentApiInsert, ez as ArtifactComponentApiInsertSchema, co as ArtifactComponentApiSelect, ey as ArtifactComponentApiSelectSchema, cq as ArtifactComponentApiUpdate, eA as ArtifactComponentApiUpdateSchema, ew as ArtifactComponentInsertSchema, ev as ArtifactComponentSelectSchema, ex as ArtifactComponentUpdateSchema, aF as AuthorizationCodeOAuthFlow, cS as CanUseItem, fr as CanUseItemSchema, bh as CancelTaskRequest, bs as CancelTaskResponse, br as CancelTaskSuccessResponse, aG as ClientCredentialsOAuthFlow, a$ as ContentTypeNotSupportedError, cd as ContextCacheApiInsert, eg as ContextCacheApiInsertSchema, cc as ContextCacheApiSelect, ef as ContextCacheApiSelectSchema, ce as ContextCacheApiUpdate, eh as ContextCacheApiUpdateSchema, d9 as ContextCacheEntry, ed as ContextCacheInsertSchema, ec as ContextCacheSelectSchema, cb as ContextCacheUpdate, ee as ContextCacheUpdateSchema, c7 as ContextConfigApiInsert, fb as ContextConfigApiInsertSchema, c6 as ContextConfigApiSelect, fa as ContextConfigApiSelectSchema, c8 as ContextConfigApiUpdate, fc as ContextConfigApiUpdateSchema, f8 as ContextConfigInsertSchema, f7 as ContextConfigSelectSchema, f9 as ContextConfigUpdateSchema, c0 as ConversationApiInsert, e4 as ConversationApiInsertSchema, b$ as ConversationApiSelect, e3 as ConversationApiSelectSchema, c1 as ConversationApiUpdate, e5 as ConversationApiUpdateSchema, e1 as ConversationInsertSchema, d7 as ConversationScopeOptions, e0 as ConversationSelectSchema, e2 as ConversationUpdateSchema, eZ as CredentialReferenceApiInsertSchema, cF as CredentialReferenceApiSelect, eY as CredentialReferenceApiSelectSchema, cG as CredentialReferenceApiUpdate, e_ as CredentialReferenceApiUpdateSchema, eW as CredentialReferenceInsertSchema, eV as CredentialReferenceSelectSchema, eX as CredentialReferenceUpdateSchema, cg as DataComponentApiInsert, en as DataComponentApiInsertSchema, cf as DataComponentApiSelect, em as DataComponentApiSelectSchema, ch as DataComponentApiUpdate, eo as DataComponentApiUpdateSchema, ek as DataComponentBaseSchema, ej as DataComponentInsertSchema, ei as DataComponentSelectSchema, el as DataComponentUpdateSchema, aw as DataPart, fx as ErrorResponseSchema, fy as ExistsResponseSchema, cy as ExternalAgentApiInsert, eL as ExternalAgentApiInsertSchema, cx as ExternalAgentApiSelect, eK as ExternalAgentApiSelectSchema, cz as ExternalAgentApiUpdate, eM as ExternalAgentApiUpdateSchema, eI as ExternalAgentInsertSchema, bJ as ExternalAgentRelationApiInsert, dE as ExternalAgentRelationApiInsertSchema, dD as ExternalAgentRelationInsertSchema, eH as ExternalAgentSelectSchema, eJ as ExternalAgentUpdateSchema, ca as FetchConfig, f5 as FetchConfigSchema, c9 as FetchDefinition, f6 as FetchDefinitionSchema, as as FileBase, av as FilePart, at as FileWithBytes, au as FileWithUri, cR as FullGraphAgentInsert, F as FullGraphAgentInsertSchema, fs as FullGraphDefinitionSchema, fG as FullProjectDefinitionSchema, bj as GetTaskPushNotificationConfigRequest, bw as GetTaskPushNotificationConfigResponse, bv as GetTaskPushNotificationConfigSuccessResponse, bg as GetTaskRequest, bq as GetTaskResponse, bp as GetTaskSuccessResponse, b as GraphStopWhen, G as GraphStopWhenSchema, ft as GraphWithinContextOfProjectSchema, aD as HTTPAuthSecurityScheme, fH as HeadersScopeSchema, fO as IdParamsSchema, aH as ImplicitOAuthFlow, cT as InternalAgentDefinition, aW as InternalError, b0 as InvalidAgentResponseError, aV as InvalidParamsError, aT as InvalidRequestError, aS as JSONParseError, bb as JSONRPCError, bd as JSONRPCErrorResponse, b9 as JSONRPCMessage, ba as JSONRPCRequest, bc as JSONRPCResult, cP as LedgerArtifactApiInsert, fn as LedgerArtifactApiInsertSchema, cO as LedgerArtifactApiSelect, fm as LedgerArtifactApiSelectSchema, cQ as LedgerArtifactApiUpdate, fo as LedgerArtifactApiUpdateSchema, cM as LedgerArtifactInsert, fk as LedgerArtifactInsertSchema, fj as LedgerArtifactSelectSchema, cN as LedgerArtifactUpdate, fl as LedgerArtifactUpdateSchema, fv as ListResponseSchema, dj as MAX_ID_LENGTH, dh as MCPServerType, f0 as MCPToolConfigSchema, di as MIN_ID_LENGTH, da as McpAuthType, db as McpServerAuth, dd as McpServerCapabilities, dZ as McpToolDefinitionSchema, e$ as McpToolSchema, dc as McpTransportConfig, dX as McpTransportConfigSchema, aN as Message, c4 as MessageApiInsert, ea as MessageApiInsertSchema, c3 as MessageApiSelect, e9 as MessageApiSelectSchema, c5 as MessageApiUpdate, eb as MessageApiUpdateSchema, e7 as MessageInsertSchema, d1 as MessageMode, bz as MessagePart, d0 as MessageRole, c2 as MessageSelect, e6 as MessageSelectSchema, b7 as MessageSendConfiguration, b8 as MessageSendParams, c$ as MessageType, e8 as MessageUpdateSchema, aU as MethodNotFoundError, dn as ModelSchema, d4 as ModelSettings, dm as ModelSettingsSchema, d2 as Models, aJ as OAuth2SecurityScheme, aE as OAuthFlows, aK as OpenIdConnectSecurityScheme, cZ as Pagination, fP as PaginationQueryParamsSchema, fu as PaginationSchema, P as Part, aq as PartBase, aI as PasswordOAuthFlow, cX as ProjectApiInsert, fE as ProjectApiInsertSchema, cW as ProjectApiSelect, fD as ProjectApiSelectSchema, cY as ProjectApiUpdate, fF as ProjectApiUpdateSchema, fB as ProjectInsertSchema, dp as ProjectModelSchema, d3 as ProjectModels, fA as ProjectSelectSchema, fC as ProjectUpdateSchema, b2 as PushNotificationAuthenticationInfo, b3 as PushNotificationConfig, aZ as PushNotificationNotSupportedError, fz as RemovedResponseSchema, aL as SecurityScheme, aB as SecuritySchemeBase, be as SendMessageRequest, bm as SendMessageResponse, bl as SendMessageSuccessResponse, bf as SendStreamingMessageRequest, bo as SendStreamingMessageResponse, bn as SendStreamingMessageSuccessResponse, bi as SetTaskPushNotificationConfigRequest, bu as SetTaskPushNotificationConfigResponse, bt as SetTaskPushNotificationConfigSuccessResponse, fw as SingleResponseSchema, d6 as StatusComponent, fp as StatusComponentSchema, fq as StatusUpdateSchema, d5 as StatusUpdateSettings, a as StopWhen, S as StopWhenSchema, c_ as SummaryEvent, df as TOOL_STATUS_VALUES, aP as Task, bQ as TaskApiInsert, dP as TaskApiInsertSchema, bP as TaskApiSelect, dO as TaskApiSelectSchema, bR as TaskApiUpdate, dQ as TaskApiUpdateSchema, bA as TaskArtifact, aR as TaskArtifactUpdateEvent, b5 as TaskIdParams, dM as TaskInsertSchema, aY as TaskNotCancelableError, aX as TaskNotFoundError, b4 as TaskPushNotificationConfig, b6 as TaskQueryParams, bW as TaskRelationApiInsert, dV as TaskRelationApiInsertSchema, bV as TaskRelationApiSelect, dU as TaskRelationApiSelectSchema, bX as TaskRelationApiUpdate, dW as TaskRelationApiUpdateSchema, bT as TaskRelationInsert, dS as TaskRelationInsertSchema, bS as TaskRelationSelect, dR as TaskRelationSelectSchema, bU as TaskRelationUpdate, dT as TaskRelationUpdateSchema, bk as TaskResubscriptionRequest, dL as TaskSelectSchema, ax as TaskState, aO as TaskStatus, aQ as TaskStatusUpdateEvent, bO as TaskUpdate, dN as TaskUpdateSchema, fN as TenantIdParamsSchema, fI as TenantParamsSchema, fL as TenantProjectGraphIdParamsSchema, fK as TenantProjectGraphParamsSchema, fM as TenantProjectIdParamsSchema, fJ as TenantProjectParamsSchema, ar as TextPart, bZ as ToolApiInsert, f3 as ToolApiInsertSchema, bY as ToolApiSelect, f2 as ToolApiSelectSchema, b_ as ToolApiUpdate, f4 as ToolApiUpdateSchema, cV as ToolDefinition, d$ as ToolInsertSchema, d_ as ToolSelectSchema, dY as ToolStatusSchema, f1 as ToolUpdateSchema, dk as URL_SAFE_ID_PATTERN, a_ as UnsupportedOperationError, dg as VALID_RELATION_TYPES, dl as resourceIdSchema, de as toolStatus } from './utility-CgaoTJn6.cjs';
4
+ import { CredentialStore } from './types/index.cjs';
5
+ export { CorsConfig, ServerConfig, ServerOptions } from './types/index.cjs';
6
+ import { LibSQLDatabase } from 'drizzle-orm/libsql';
7
+ import { s as schema } from './schema-Blsr-8V7.cjs';
8
+ export { k as agentArtifactComponents, N as agentArtifactComponentsRelations, i as agentDataComponents, P as agentDataComponentsRelations, a as agentGraph, E as agentGraphRelations, e as agentRelations, R as agentRelationsRelations, m as agentToolRelations, H as agentToolRelationsRelations, d as agents, D as agentsRelations, r as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, n as conversations, K as conversationsRelations, u as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, q as ledgerArtifacts, w as ledgerArtifactsContextIdIdx, Q as ledgerArtifactsRelations, x as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, o as messages, L as messagesRelations, p as projects, z as projectsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from './schema-Blsr-8V7.cjs';
9
+ import { LoggerOptions, TransportSingleOptions, Logger } from 'pino';
10
+ import { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
11
+ import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
12
+ import { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
13
+ import { ValidateFunction } from 'ajv';
14
+ import { Context, Next } from 'hono';
15
+ import { z as z$1 } from '@hono/zod-openapi';
16
+ import { HTTPException } from 'hono/http-exception';
17
+ import { Span, Tracer } from '@opentelemetry/api';
18
+ export { generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from './validation/index.cjs';
19
+ import 'drizzle-zod';
20
+ import 'drizzle-orm/sqlite-core';
21
+ import 'drizzle-orm';
22
+
23
+ type Primitive = string | number | boolean | bigint | symbol | null | undefined | Date;
24
+ type JoinDot<P extends string, K extends string> = [P] extends [''] ? K : `${P}.${K}`;
25
+ type DotPaths<T, P extends string = ''> = [T] extends [Primitive] ? P : T extends ReadonlyArray<infer U> ? P | DotPaths<U, `${P}[${number}]`> | DotPaths<U, `${P}[*]`> : T extends Array<infer U> ? P | DotPaths<U, `${P}[${number}]`> | DotPaths<U, `${P}[*]`> : T extends object ? P | {
26
+ [K in Extract<keyof T, string>]: DotPaths<T[K], JoinDot<P, K>>;
27
+ }[Extract<keyof T, string>] : P;
28
+
29
+ type ExtractSchemasFromCV<CV> = {
30
+ [K in keyof CV]: CV[K] extends builderFetchDefinition<infer S> ? S : never;
31
+ };
32
+ type InferContextFromSchemas<CZ> = {
33
+ [K in keyof CZ]: CZ[K] extends z.ZodTypeAny ? z.infer<CZ[K]> : never;
34
+ };
35
+ type MergeRequestContext<R extends z.ZodTypeAny | undefined> = R extends z.ZodTypeAny ? {
36
+ requestContext: z.infer<R>;
37
+ } : {};
38
+ type FullContext<R extends z.ZodTypeAny | undefined, CV> = MergeRequestContext<R> & InferContextFromSchemas<ExtractSchemasFromCV<CV>>;
39
+ type AllowedPaths<R extends z.ZodTypeAny | undefined, CV> = DotPaths<FullContext<R, CV>>;
40
+ interface RequestContextSchemaBuilderOptions<R extends z.ZodTypeAny> {
41
+ schema: R;
42
+ }
43
+ declare class RequestContextSchemaBuilder<R extends z.ZodTypeAny> {
44
+ private schema;
45
+ constructor(options: RequestContextSchemaBuilderOptions<R>);
46
+ /** Template function for request context paths with type-safe autocomplete */
47
+ toTemplate<P extends DotPaths<z.infer<R>>>(path: P): `{{requestContext.${P}}}`;
48
+ getSchema(): R;
49
+ getJsonSchema(): Record<string, unknown>;
50
+ }
51
+ type builderFetchDefinition<R extends z.ZodTypeAny> = {
52
+ id: string;
53
+ name?: string;
54
+ trigger: 'initialization' | 'invocation';
55
+ fetchConfig: {
56
+ url: string;
57
+ method?: string;
58
+ headers?: Record<string, string>;
59
+ body?: Record<string, unknown>;
60
+ transform?: string;
61
+ timeout?: number;
62
+ };
63
+ responseSchema: R;
64
+ defaultValue?: unknown;
65
+ credentialReference?: CredentialReferenceApiInsert;
66
+ };
67
+ interface ContextConfigBuilderOptions<R extends z.ZodTypeAny | undefined = undefined, CV = Record<string, builderFetchDefinition<z.ZodTypeAny>>> {
68
+ id: string;
69
+ name: string;
70
+ description?: string;
71
+ requestContextSchema?: R | RequestContextSchemaBuilder<R extends z.ZodTypeAny ? R : z.ZodTypeAny>;
72
+ contextVariables?: CV;
73
+ tenantId?: string;
74
+ projectId?: string;
75
+ baseURL?: string;
76
+ }
77
+ declare class ContextConfigBuilder<R extends z.ZodTypeAny | undefined, CV extends Record<string, builderFetchDefinition<z.ZodTypeAny>>> {
78
+ private config;
79
+ private baseURL;
80
+ private tenantId;
81
+ private projectId;
82
+ constructor(options: ContextConfigBuilderOptions<R, CV>);
83
+ /**
84
+ * Convert the builder to a plain object for database operations
85
+ */
86
+ toObject(): ContextConfigSelect;
87
+ getId(): string;
88
+ getName(): string;
89
+ getDescription(): string;
90
+ getRequestContextSchema(): {} | null;
91
+ getContextVariables(): Record<string, ContextFetchDefinition>;
92
+ withRequestContextSchema(schema: any): this;
93
+ /** 4) The function you ship: path autocomplete + validation, returns {{path}} */
94
+ toTemplate<P extends AllowedPaths<R, CV>>(path: P): `{{${P}}}`;
95
+ validate(): {
96
+ valid: boolean;
97
+ errors: string[];
98
+ };
99
+ init(): Promise<void>;
100
+ private upsertContextConfig;
101
+ private parseErrorResponse;
102
+ }
103
+ declare function contextConfig<R extends z.ZodTypeAny | undefined = undefined, CV extends Record<string, builderFetchDefinition<z.ZodTypeAny>> = Record<string, builderFetchDefinition<z.ZodTypeAny>>>(options: ContextConfigBuilderOptions<R, CV> & {
104
+ contextVariables?: CV;
105
+ }): ContextConfigBuilder<R, CV>;
106
+ declare function requestContextSchema<R extends z.ZodTypeAny>(options: RequestContextSchemaBuilderOptions<R>): RequestContextSchemaBuilder<R>;
107
+ declare function fetchDefinition<R extends z.ZodTypeAny>(options: builderFetchDefinition<R>): Omit<builderFetchDefinition<R>, 'credentialReference'> & {
108
+ credentialReferenceId?: string;
109
+ };
110
+
111
+ /**
112
+ * Registry for managing credential stores in the application context
113
+ * Provides methods to register, retrieve, and manage credential stores
114
+ */
115
+ declare class CredentialStoreRegistry {
116
+ private stores;
117
+ private logger;
118
+ constructor(initialStores?: CredentialStore[]);
119
+ /**
120
+ * Add a credential store to the registry
121
+ */
122
+ add(store: CredentialStore): void;
123
+ /**
124
+ * Get a credential store by ID
125
+ */
126
+ get(id: string): CredentialStore | undefined;
127
+ /**
128
+ * Get all registered credential stores
129
+ */
130
+ getAll(): CredentialStore[];
131
+ /**
132
+ * Get all credential store IDs
133
+ */
134
+ getIds(): string[];
135
+ /**
136
+ * Check if a credential store is registered
137
+ */
138
+ has(id: string): boolean;
139
+ /**
140
+ * Remove a credential store
141
+ */
142
+ remove(id: string): boolean;
143
+ /**
144
+ * Get the number of registered stores
145
+ */
146
+ size(): number;
147
+ }
148
+
149
+ type DatabaseClient = LibSQLDatabase<typeof schema>;
150
+ interface DatabaseConfig {
151
+ url: string;
152
+ authToken?: string;
153
+ logger?: {
154
+ logQuery: (query: string, params: unknown[]) => void;
155
+ };
156
+ }
157
+ /**
158
+ * Creates a database client with the specified configuration
159
+ */
160
+ declare function createDatabaseClient(config: DatabaseConfig): DatabaseClient;
161
+ /**
162
+ * Creates an in-memory database client for testing
163
+ */
164
+ declare function createInMemoryDatabaseClient(): DatabaseClient;
165
+
166
+ interface TemplateContext {
167
+ [key: string]: unknown;
168
+ }
169
+ interface TemplateRenderOptions {
170
+ strict?: boolean;
171
+ preserveUnresolved?: boolean;
172
+ }
173
+ declare class TemplateEngine {
174
+ private static readonly DEFAULT_OPTIONS;
175
+ /**
176
+ * Render a template string with context data using JMESPath
177
+ */
178
+ static render(template: string, context: TemplateContext, options?: TemplateRenderOptions): string;
179
+ /**
180
+ * Process variable substitutions {{variable.path}} using JMESPath
181
+ */
182
+ private static processVariables;
183
+ /**
184
+ * Process built-in variables like $now, $env, etc.
185
+ */
186
+ private static processBuiltinVariable;
187
+ /**
188
+ * Check if template contains template variables
189
+ */
190
+ private static hasTemplateVariables;
191
+ /**
192
+ * Extract all template variables from a template
193
+ */
194
+ private static extractTemplateVariables;
195
+ /**
196
+ * Validate template syntax
197
+ */
198
+ static validateTemplate(template: string): {
199
+ valid: boolean;
200
+ errors: string[];
201
+ };
202
+ /**
203
+ * Preview template rendering with sample context
204
+ */
205
+ static preview(template: string, sampleContext: TemplateContext, options?: TemplateRenderOptions): {
206
+ rendered: string;
207
+ variables: string[];
208
+ errors: string[];
209
+ };
210
+ }
211
+
212
+ interface FetchResult {
213
+ data: unknown;
214
+ source: string;
215
+ durationMs: number;
216
+ }
217
+ declare class ContextFetcher {
218
+ private tenantId;
219
+ private projectId;
220
+ private defaultTimeout;
221
+ private credentialStuffer?;
222
+ private dbClient;
223
+ constructor(tenantId: string, projectId: string, dbClient: DatabaseClient, credentialStoreRegistry?: CredentialStoreRegistry, defaultTimeout?: number);
224
+ /**
225
+ * Fetch data according to a fetch definition
226
+ */
227
+ fetch(definition: ContextFetchDefinition, context: TemplateContext): Promise<unknown>;
228
+ private getCredential;
229
+ /**
230
+ * Resolve template variables in fetch configuration and inject credential headers
231
+ */
232
+ private resolveTemplateVariables;
233
+ /**
234
+ * Interpolate template variables in a string using TemplateEngine
235
+ */
236
+ private interpolateTemplate;
237
+ /**
238
+ * Interpolate template variables in an object recursively using TemplateEngine
239
+ */
240
+ private interpolateObjectTemplates;
241
+ /**
242
+ * Perform HTTP request
243
+ */
244
+ private performRequest;
245
+ /**
246
+ * Transform response data using JMESPath
247
+ */
248
+ private transformResponse;
249
+ /**
250
+ * Validate response against JSON Schema
251
+ */
252
+ private validateResponseWithJsonSchema;
253
+ /**
254
+ * Test a fetch definition without caching
255
+ */
256
+ test(definition: ContextFetchDefinition, context: TemplateContext): Promise<{
257
+ success: boolean;
258
+ data?: unknown;
259
+ error?: string;
260
+ durationMs: number;
261
+ }>;
262
+ /**
263
+ * Get fetcher statistics
264
+ */
265
+ getStats(): {
266
+ tenantId: string;
267
+ defaultTimeout: number;
268
+ };
269
+ }
270
+
271
+ interface ResolvedContext {
272
+ [templateKey: string]: unknown;
273
+ }
274
+ interface ContextResolutionOptions {
275
+ triggerEvent: 'initialization' | 'invocation';
276
+ conversationId: string;
277
+ requestContext?: Record<string, unknown>;
278
+ tenantId: string;
279
+ }
280
+ interface ContextResolutionResult {
281
+ resolvedContext: ResolvedContext;
282
+ requestContext: Record<string, unknown>;
283
+ fetchedDefinitions: string[];
284
+ cacheHits: string[];
285
+ cacheMisses: string[];
286
+ errors: Array<{
287
+ definitionId: string;
288
+ error: string;
289
+ }>;
290
+ totalDurationMs: number;
291
+ }
292
+ declare class ContextResolver {
293
+ private fetcher;
294
+ private cache;
295
+ private tenantId;
296
+ private projectId;
297
+ constructor(tenantId: string, projectId: string, dbClient: DatabaseClient, credentialStoreRegistry?: CredentialStoreRegistry);
298
+ /**
299
+ * Resolve all contexts for a given configuration and trigger event
300
+ */
301
+ resolve(contextConfig: ContextConfigSelect, options: ContextResolutionOptions): Promise<ContextResolutionResult>;
302
+ /**
303
+ * Resolve a single context variable
304
+ */
305
+ private resolveSingleFetchDefinition;
306
+ /**
307
+ * Resolve the request context for a given conversation
308
+ */
309
+ resolveRequestContext(conversationId: string, contextConfigId: string): Promise<Record<string, unknown>>;
310
+ /**
311
+ * Create a hash of the request context for cache invalidation
312
+ */
313
+ private createRequestHash;
314
+ /**
315
+ * Clear cache
316
+ */
317
+ clearCache(tenantId: string, projectId: string, conversationId: string): Promise<void>;
318
+ }
319
+
320
+ declare function determineContextTrigger(tenantId: string, projectId: string, conversationId: string, dbClient: DatabaseClient): Promise<'initialization' | 'invocation'>;
321
+ declare function handleContextConfigChange(tenantId: string, projectId: string, conversationId: string, graphId: string, newContextConfigId: string, dbClient: DatabaseClient, credentialStores?: CredentialStoreRegistry): Promise<void>;
322
+ declare function handleContextResolution({ tenantId, projectId, graphId, conversationId, requestContext, dbClient, credentialStores, }: {
323
+ tenantId: string;
324
+ projectId: string;
325
+ graphId: string;
326
+ conversationId: string;
327
+ requestContext: Record<string, unknown>;
328
+ dbClient: DatabaseClient;
329
+ credentialStores?: CredentialStoreRegistry;
330
+ }): Promise<ResolvedContext | null>;
331
+
332
+ interface CacheEntry {
333
+ contextConfigId: string;
334
+ contextVariableKey: string;
335
+ conversationId: string;
336
+ value: unknown;
337
+ requestHash?: string;
338
+ tenantId: string;
339
+ }
340
+ /**
341
+ * Context cache with request hash-based invalidation and graceful error handling.
342
+ *
343
+ * Implements conversation-scoped caching with smart cache invalidation based on
344
+ * request hash changes. All cache errors are treated as cache misses to ensure
345
+ * system reliability.
346
+ */
347
+ declare class ContextCache {
348
+ private tenantId;
349
+ private projectId;
350
+ private dbClient;
351
+ constructor(tenantId: string, projectId: string, dbClient: DatabaseClient);
352
+ /**
353
+ * Get cached context data for a conversation
354
+ */
355
+ get({ conversationId, contextConfigId, contextVariableKey, requestHash, }: {
356
+ conversationId: string;
357
+ contextConfigId: string;
358
+ contextVariableKey: string;
359
+ requestHash?: string;
360
+ }): Promise<CacheEntry | null>;
361
+ /**
362
+ * Set cached context data for a conversation
363
+ */
364
+ set(entry: CacheEntry): Promise<void>;
365
+ /**
366
+ * Clear cache entries for a specific conversation
367
+ */
368
+ clearConversation(tenantId: string, projectId: string, conversationId: string): Promise<void>;
369
+ /**
370
+ * Clear all cache entries for a specific context configuration
371
+ */
372
+ clearContextConfig(tenantId: string, projectId: string, contextConfigId: string): Promise<void>;
373
+ /**
374
+ * Clean up expired or orphaned cache entries
375
+ */
376
+ cleanup(): Promise<void>;
377
+ invalidateInvocationDefinitions(tenantId: string, projectId: string, conversationId: string, contextConfigId: string, definitionIds: string[]): Promise<void>;
378
+ invalidateRequestContext(tenantId: string, projectId: string, conversationId: string, contextConfigId: string): Promise<void>;
379
+ }
380
+
381
+ /**
382
+ * Create default credential stores based on environment variables
383
+ */
384
+ declare function createDefaultCredentialStores(): CredentialStore[];
385
+
386
+ /**
387
+ * KeyChainStore - Cross-platform system keychain credential storage
388
+ *
389
+ * Uses the native OS credential storage:
390
+ * - macOS: Keychain
391
+ * - Windows: Credential Vault
392
+ * - Linux: Secret Service API/libsecret
393
+ *
394
+ * Requires the 'keytar' npm package to be installed.
395
+ * Falls back gracefully if keytar is not available.
396
+ *
397
+ * ## macOS Permission Handling
398
+ *
399
+ * On macOS, when your Node.js app first calls keytar operations:
400
+ * - `setPassword()` creates a new Keychain item (no prompt required)
401
+ * - `getPassword()` may prompt the user for permission on first access
402
+ * - Users can click "Allow", "Always Allow", or "Deny"
403
+ * - If denied, keytar returns `null` which this implementation handles gracefully
404
+ * - The calling binary (usually `node`) will be shown in the permission prompt
405
+ * - For better UX in packaged apps, consider code signing and app bundling
406
+ *
407
+ * This implementation handles all permission scenarios gracefully:
408
+ * - Returns `null` when access is denied or credentials don't exist
409
+ * - Logs errors for debugging permission issues
410
+ * - Never throws on permission denial, only on system-level errors
411
+ */
412
+ declare class KeyChainStore implements CredentialStore {
413
+ readonly id: string;
414
+ readonly type: "keychain";
415
+ private readonly service;
416
+ private readonly logger;
417
+ private keytarAvailable;
418
+ private keytar;
419
+ private initializationPromise;
420
+ constructor(id: string, servicePrefix?: string);
421
+ /**
422
+ * Initialize keytar dynamically to handle optional availability
423
+ */
424
+ private initializeKeytar;
425
+ /**
426
+ * Get a credential from the keychain
427
+ */
428
+ get(key: string): Promise<string | null>;
429
+ /**
430
+ * Set a credential in the keychain
431
+ */
432
+ set(key: string, value: string): Promise<void>;
433
+ /**
434
+ * Check if a credential exists in the keychain
435
+ */
436
+ has(key: string): Promise<boolean>;
437
+ /**
438
+ * Delete a credential from the keychain
439
+ */
440
+ delete(key: string): Promise<boolean>;
441
+ /**
442
+ * Find all credentials for this service
443
+ * Useful for debugging and listing stored credentials
444
+ */
445
+ findAllCredentials(): Promise<Array<{
446
+ account: string;
447
+ password: string;
448
+ }>>;
449
+ /**
450
+ * Clear all credentials for this service
451
+ * WARNING: This will delete all credentials stored under this service
452
+ */
453
+ clearAll(): Promise<number>;
454
+ }
455
+ /**
456
+ * Factory function to create KeyChainStore
457
+ * Provides consistent initialization and optional configuration
458
+ *
459
+ * ## Usage Recommendations for macOS Permission Handling
460
+ *
461
+ * 1. **First-time setup**: Inform users that they may see permission prompts
462
+ * 2. **Error handling**: Check for `null` returns from `get()` operations
463
+ * 3. **User guidance**: If credentials can't be retrieved, guide users to:
464
+ * - Check Keychain Access app for denied permissions
465
+ * - Re-run the application if they accidentally clicked "Deny"
466
+ * 4. **Development**: Use a consistent `servicePrefix` to avoid permission prompt spam
467
+ * 5. **Production**: Consider code-signing your distributed app for better permission prompts
468
+ *
469
+ * Example usage with permission handling:
470
+ * ```typescript
471
+ * const store = createKeyChainStore('my-app');
472
+ *
473
+ * // Always check for null when retrieving
474
+ * const apiKey = await store.get('api-key');
475
+ * if (!apiKey) {
476
+ * console.log('API key not found or access denied');
477
+ * // Guide user to check permissions or re-enter credentials
478
+ * }
479
+ * ```
480
+ */
481
+ declare function createKeyChainStore(id: string, options?: {
482
+ servicePrefix?: string;
483
+ }): KeyChainStore;
484
+
485
+ /**
486
+ * In-memory credential store implementation
487
+ * Automatically loads environment variables prefixed with CREDENTIAL_STORE_ on initialization
488
+ * Note: Runtime credentials are lost when the server restarts, but env vars are reloaded
489
+ */
490
+ declare class InMemoryCredentialStore implements CredentialStore {
491
+ readonly id: string;
492
+ readonly type: "memory";
493
+ private credentials;
494
+ constructor(id?: string);
495
+ /**
496
+ * Get a credential from the in memory store.
497
+ * If the key is not found in the in memory store then it is loaded from environment variables.
498
+ * If the key is not found in the environment variables or in the in memory store then returns null.
499
+ * @param key - The key of the credential to get
500
+ * @returns The credential value or null if not found
501
+ */
502
+ get(key: string): Promise<string | null>;
503
+ /**
504
+ * Set a credential in the in memory store.
505
+ * @param key - The key of the credential to set
506
+ * @param value - The value of the credential to set
507
+ */
508
+ set(key: string, value: string): Promise<void>;
509
+ /**
510
+ * Check if a credential exists in the in memory store.
511
+ * @param key - The key of the credential to check
512
+ * @returns True if the credential exists, false otherwise
513
+ */
514
+ has(key: string): Promise<boolean>;
515
+ /**
516
+ * Delete a credential from the in memory store.
517
+ * @param key - The key of the credential to delete
518
+ * @returns True if the credential was deleted, false otherwise
519
+ */
520
+ delete(key: string): Promise<boolean>;
521
+ }
522
+
523
+ interface NangoConfig {
524
+ secretKey: string;
525
+ apiUrl?: string;
526
+ }
527
+ /**
528
+ * Nango-based CredentialStore that fetches OAuth credentials from Nango API
529
+ * Uses connectionId and providerConfigKey from metadata to fetch live credentials
530
+ */
531
+ declare class NangoCredentialStore implements CredentialStore {
532
+ readonly id: string;
533
+ readonly type: "nango";
534
+ private nangoConfig;
535
+ private nangoClient;
536
+ constructor(id: string, config: NangoConfig);
537
+ private getAccessToken;
538
+ private sanitizeMetadata;
539
+ /**
540
+ * Fetch credentials from Nango API using connection information
541
+ * @param connectionId - The connection ID for the Nango connection
542
+ * @param providerConfigKey - The provider config key for the Nango connection
543
+ * @returns The credential data or null if the credentials are not found
544
+ */
545
+ private fetchCredentialsFromNango;
546
+ /**
547
+ * Get credentials by key - implements CredentialStore interface
548
+ * Key format: JSON string with connectionId and providerConfigKey
549
+ */
550
+ get(key: string): Promise<string | null>;
551
+ /**
552
+ * Set credentials - not supported for Nango (OAuth flow handles this)
553
+ */
554
+ set(_key: string, _value: string): Promise<void>;
555
+ /**
556
+ * Check if credentials exist by attempting to fetch them
557
+ */
558
+ has(key: string): Promise<boolean>;
559
+ /**
560
+ * Delete credentials - not supported for Nango (revoke through Nango dashboard)
561
+ */
562
+ delete(key: string): Promise<boolean>;
563
+ }
564
+ /**
565
+ * Factory function to create NangoCredentialStore
566
+ * Automatically reads NANGO_SECRET_KEY from environment and validates it
567
+ */
568
+ declare function createNangoCredentialStore(id: string, config?: Partial<NangoConfig>): NangoCredentialStore;
569
+
570
+ /**
571
+ * Configuration options for PinoLogger
572
+ */
573
+ interface PinoLoggerConfig {
574
+ /** Pino logger options */
575
+ options?: LoggerOptions;
576
+ /** Pino transport configuration */
577
+ transportConfigs?: TransportSingleOptions[];
578
+ }
579
+ /**
580
+ * Pino logger implementation with transport customization support
581
+ */
582
+ declare class PinoLogger {
583
+ private name;
584
+ private transportConfigs;
585
+ private pinoInstance;
586
+ private options;
587
+ constructor(name: string, config?: PinoLoggerConfig);
588
+ /**
589
+ * Recreate the pino instance with current transports
590
+ */
591
+ private recreateInstance;
592
+ /**
593
+ * Add a new transport to the logger
594
+ */
595
+ addTransport(transportConfig: TransportSingleOptions): void;
596
+ /**
597
+ * Remove a transport by index
598
+ */
599
+ removeTransport(index: number): void;
600
+ /**
601
+ * Get current transports
602
+ */
603
+ getTransports(): TransportSingleOptions[];
604
+ /**
605
+ * Update logger options
606
+ */
607
+ updateOptions(options: Partial<LoggerOptions>): void;
608
+ /**
609
+ * Get the underlying pino instance for advanced usage
610
+ */
611
+ getPinoInstance(): Logger;
612
+ error(data: any, message: string): void;
613
+ warn(data: any, message: string): void;
614
+ info(data: any, message: string): void;
615
+ debug(data: any, message: string): void;
616
+ }
617
+ /**
618
+ * Logger factory configuration
619
+ */
620
+ interface LoggerFactoryConfig {
621
+ defaultLogger?: PinoLogger;
622
+ loggerFactory?: (name: string) => PinoLogger;
623
+ /** Configuration for creating PinoLogger instances when using createPinoLoggerFactory */
624
+ pinoConfig?: PinoLoggerConfig;
625
+ }
626
+ /**
627
+ * Global logger factory singleton
628
+ */
629
+ declare class LoggerFactory {
630
+ private config;
631
+ private loggers;
632
+ /**
633
+ * Configure the logger factory
634
+ */
635
+ configure(config: LoggerFactoryConfig): void;
636
+ /**
637
+ * Get or create a logger instance
638
+ */
639
+ getLogger(name: string): PinoLogger;
640
+ /**
641
+ * Reset factory to default state
642
+ */
643
+ reset(): void;
644
+ }
645
+ declare const loggerFactory: LoggerFactory;
646
+ /**
647
+ * Convenience function to get a logger
648
+ */
649
+ declare function getLogger(name: string): PinoLogger;
650
+
651
+ interface SharedServerConfig {
652
+ timeout?: number;
653
+ activeTools?: string[];
654
+ selectedTools?: string[];
655
+ }
656
+ interface McpStreamableHttpConfig extends SharedServerConfig {
657
+ type: typeof MCPTransportType.streamableHttp;
658
+ url: string | URL;
659
+ headers?: Record<string, string>;
660
+ requestInit?: StreamableHTTPClientTransportOptions['requestInit'];
661
+ eventSourceInit?: SSEClientTransportOptions['eventSourceInit'];
662
+ reconnectionOptions?: StreamableHTTPClientTransportOptions['reconnectionOptions'];
663
+ sessionId?: StreamableHTTPClientTransportOptions['sessionId'];
664
+ }
665
+ interface McpSSEConfig extends SharedServerConfig {
666
+ type: typeof MCPTransportType.sse;
667
+ url: string | URL;
668
+ headers?: Record<string, string>;
669
+ eventSourceInit?: SSEClientTransportOptions['eventSourceInit'];
670
+ }
671
+ type McpServerConfig = McpStreamableHttpConfig | McpSSEConfig;
672
+ interface McpClientOptions {
673
+ name: string;
674
+ version?: string;
675
+ server: McpServerConfig;
676
+ capabilities?: ClientCapabilities;
677
+ timeout?: number;
678
+ }
679
+ declare class McpClient {
680
+ name: string;
681
+ private client;
682
+ private readonly timeout;
683
+ private transport?;
684
+ private serverConfig;
685
+ private connected;
686
+ constructor(opts: McpClientOptions);
687
+ connect(): Promise<void>;
688
+ private connectSSE;
689
+ private connectHttp;
690
+ disconnect(): Promise<void>;
691
+ private validateSelectedTools;
692
+ private selectTools;
693
+ tools(): Promise<Record<string, any>>;
694
+ }
695
+
696
+ /**
697
+ * Context object for credential operations
698
+ */
699
+ interface CredentialContext {
700
+ /** Tenant identifier */
701
+ tenantId: string;
702
+ /** Project identifier */
703
+ projectId: string;
704
+ /** Conversation identifier */
705
+ conversationId?: string;
706
+ /** Context configuration identifier */
707
+ contextConfigId?: string;
708
+ /** Additional context data */
709
+ metadata?: Record<string, unknown>;
710
+ }
711
+ /**
712
+ * Base credential data structure containing headers and metadata
713
+ */
714
+ interface CredentialData {
715
+ /** HTTP headers for authentication */
716
+ headers: Record<string, string>;
717
+ /** Additional metadata for the credentials */
718
+ metadata?: Record<string, any>;
719
+ }
720
+ /**
721
+ * Credential store reference for lookups
722
+ */
723
+ interface CredentialStoreReference {
724
+ /** Framework credential store ID */
725
+ credentialStoreId: string;
726
+ /** Configuration parameters for credential retrieval */
727
+ retrievalParams: Record<string, unknown>;
728
+ }
729
+ interface CredentialResolverInput {
730
+ context: CredentialContext;
731
+ mcpType?: MCPToolConfig['mcpType'];
732
+ storeReference?: CredentialStoreReference;
733
+ headers?: Record<string, string>;
734
+ }
735
+ /**
736
+ * Interface for context resolver (optional)
737
+ */
738
+ interface ContextResolverInterface {
739
+ resolveRequestContext(conversationId: string, contextConfigId: string): Promise<Record<string, unknown>>;
740
+ }
741
+ /**
742
+ * Manages credential retrieval and injection for MCP tools
743
+ * Uses CredentialStoreRegistry for credential store management
744
+ */
745
+ declare class CredentialStuffer {
746
+ private credentialStoreRegistry;
747
+ private contextResolver?;
748
+ private readonly logger;
749
+ constructor(credentialStoreRegistry: CredentialStoreRegistry, contextResolver?: ContextResolverInterface | undefined, logger?: PinoLogger);
750
+ /**
751
+ * Retrieve credentials from credential store registry
752
+ */
753
+ getCredentials(context: CredentialContext, storeReference: CredentialStoreReference, mcpType?: MCPToolConfig['mcpType']): Promise<CredentialData | null>;
754
+ /**
755
+ * Generate credential lookup key based on store type
756
+ */
757
+ private generateCredentialKey;
758
+ /**
759
+ * Get credentials from request context
760
+ */
761
+ getCredentialsFromRequestContext(credentialContext: CredentialContext, headers: Record<string, string>): Promise<CredentialData | null>;
762
+ /**
763
+ * Get credential headers for MCP server configuration
764
+ */
765
+ getCredentialHeaders({ context, mcpType, storeReference, headers, }: CredentialResolverInput): Promise<Record<string, string>>;
766
+ /**
767
+ * Build MCP server configuration with credentials
768
+ */
769
+ buildMcpServerConfig(context: CredentialContext, tool: MCPToolConfig, storeReference?: CredentialStoreReference, selectedTools?: string[]): Promise<McpServerConfig>;
770
+ }
771
+
772
+ declare const getAgentGraphById: (db: DatabaseClient) => (params: {
773
+ scopes: GraphScopeConfig;
774
+ }) => Promise<{
775
+ tenantId: string;
776
+ projectId: string;
777
+ id: string;
778
+ name: string;
779
+ description: string | null;
780
+ createdAt: string;
781
+ updatedAt: string;
782
+ defaultAgentId: string | null;
783
+ models: {
784
+ base?: {
785
+ model?: string | undefined;
786
+ providerOptions?: Record<string, unknown> | undefined;
787
+ } | undefined;
788
+ structuredOutput?: {
789
+ model?: string | undefined;
790
+ providerOptions?: Record<string, unknown> | undefined;
791
+ } | undefined;
792
+ summarizer?: {
793
+ model?: string | undefined;
794
+ providerOptions?: Record<string, unknown> | undefined;
795
+ } | undefined;
796
+ } | null;
797
+ stopWhen: {
798
+ transferCountIs?: number | undefined;
799
+ } | null;
800
+ contextConfigId: string | null;
801
+ statusUpdates: {
802
+ enabled?: boolean | undefined;
803
+ numEvents?: number | undefined;
804
+ timeInSeconds?: number | undefined;
805
+ prompt?: string | undefined;
806
+ statusComponents?: {
807
+ type: string;
808
+ description?: string | undefined;
809
+ detailsSchema?: {
810
+ type: "object";
811
+ properties: Record<string, any>;
812
+ required?: string[] | undefined;
813
+ } | undefined;
814
+ }[] | undefined;
815
+ } | null;
816
+ graphPrompt: string | null;
817
+ } | null>;
818
+ declare const getAgentGraphWithDefaultAgent: (db: DatabaseClient) => (params: {
819
+ scopes: GraphScopeConfig;
820
+ }) => Promise<{
821
+ tenantId: string;
822
+ projectId: string;
823
+ id: string;
824
+ name: string;
825
+ description: string | null;
826
+ createdAt: string;
827
+ updatedAt: string;
828
+ defaultAgentId: string | null;
829
+ models: {
830
+ base?: {
831
+ model?: string | undefined;
832
+ providerOptions?: Record<string, unknown> | undefined;
833
+ } | undefined;
834
+ structuredOutput?: {
835
+ model?: string | undefined;
836
+ providerOptions?: Record<string, unknown> | undefined;
837
+ } | undefined;
838
+ summarizer?: {
839
+ model?: string | undefined;
840
+ providerOptions?: Record<string, unknown> | undefined;
841
+ } | undefined;
842
+ } | null;
843
+ stopWhen: {
844
+ transferCountIs?: number | undefined;
845
+ } | null;
846
+ contextConfigId: string | null;
847
+ statusUpdates: {
848
+ enabled?: boolean | undefined;
849
+ numEvents?: number | undefined;
850
+ timeInSeconds?: number | undefined;
851
+ prompt?: string | undefined;
852
+ statusComponents?: {
853
+ type: string;
854
+ description?: string | undefined;
855
+ detailsSchema?: {
856
+ type: "object";
857
+ properties: Record<string, any>;
858
+ required?: string[] | undefined;
859
+ } | undefined;
860
+ }[] | undefined;
861
+ } | null;
862
+ graphPrompt: string | null;
863
+ defaultAgent: {
864
+ tenantId: string;
865
+ projectId: string;
866
+ id: string;
867
+ name: string;
868
+ description: string;
869
+ prompt: string;
870
+ graphId: string;
871
+ createdAt: string;
872
+ updatedAt: string;
873
+ conversationHistoryConfig: ConversationHistoryConfig | null;
874
+ models: {
875
+ base?: {
876
+ model?: string | undefined;
877
+ providerOptions?: Record<string, unknown> | undefined;
878
+ } | undefined;
879
+ structuredOutput?: {
880
+ model?: string | undefined;
881
+ providerOptions?: Record<string, unknown> | undefined;
882
+ } | undefined;
883
+ summarizer?: {
884
+ model?: string | undefined;
885
+ providerOptions?: Record<string, unknown> | undefined;
886
+ } | undefined;
887
+ } | null;
888
+ stopWhen: {
889
+ stepCountIs?: number | undefined;
890
+ } | null;
891
+ } | null;
892
+ } | null>;
893
+ declare const listAgentGraphs: (db: DatabaseClient) => (params: {
894
+ scopes: ProjectScopeConfig;
895
+ }) => Promise<{
896
+ tenantId: string;
897
+ projectId: string;
898
+ id: string;
899
+ name: string;
900
+ description: string | null;
901
+ createdAt: string;
902
+ updatedAt: string;
903
+ defaultAgentId: string | null;
904
+ models: {
905
+ base?: {
906
+ model?: string | undefined;
907
+ providerOptions?: Record<string, unknown> | undefined;
908
+ } | undefined;
909
+ structuredOutput?: {
910
+ model?: string | undefined;
911
+ providerOptions?: Record<string, unknown> | undefined;
912
+ } | undefined;
913
+ summarizer?: {
914
+ model?: string | undefined;
915
+ providerOptions?: Record<string, unknown> | undefined;
916
+ } | undefined;
917
+ } | null;
918
+ stopWhen: {
919
+ transferCountIs?: number | undefined;
920
+ } | null;
921
+ contextConfigId: string | null;
922
+ statusUpdates: {
923
+ enabled?: boolean | undefined;
924
+ numEvents?: number | undefined;
925
+ timeInSeconds?: number | undefined;
926
+ prompt?: string | undefined;
927
+ statusComponents?: {
928
+ type: string;
929
+ description?: string | undefined;
930
+ detailsSchema?: {
931
+ type: "object";
932
+ properties: Record<string, any>;
933
+ required?: string[] | undefined;
934
+ } | undefined;
935
+ }[] | undefined;
936
+ } | null;
937
+ graphPrompt: string | null;
938
+ }[]>;
939
+ declare const listAgentGraphsPaginated: (db: DatabaseClient) => (params: {
940
+ scopes: ProjectScopeConfig;
941
+ pagination?: PaginationConfig;
942
+ }) => Promise<{
943
+ data: {
944
+ tenantId: string;
945
+ projectId: string;
946
+ id: string;
947
+ name: string;
948
+ description: string | null;
949
+ defaultAgentId: string | null;
950
+ contextConfigId: string | null;
951
+ models: {
952
+ base?: {
953
+ model?: string | undefined;
954
+ providerOptions?: Record<string, unknown> | undefined;
955
+ } | undefined;
956
+ structuredOutput?: {
957
+ model?: string | undefined;
958
+ providerOptions?: Record<string, unknown> | undefined;
959
+ } | undefined;
960
+ summarizer?: {
961
+ model?: string | undefined;
962
+ providerOptions?: Record<string, unknown> | undefined;
963
+ } | undefined;
964
+ } | null;
965
+ statusUpdates: {
966
+ enabled?: boolean | undefined;
967
+ numEvents?: number | undefined;
968
+ timeInSeconds?: number | undefined;
969
+ prompt?: string | undefined;
970
+ statusComponents?: {
971
+ type: string;
972
+ description?: string | undefined;
973
+ detailsSchema?: {
974
+ type: "object";
975
+ properties: Record<string, any>;
976
+ required?: string[] | undefined;
977
+ } | undefined;
978
+ }[] | undefined;
979
+ } | null;
980
+ graphPrompt: string | null;
981
+ stopWhen: {
982
+ transferCountIs?: number | undefined;
983
+ } | null;
984
+ createdAt: string;
985
+ updatedAt: string;
986
+ }[];
987
+ pagination: {
988
+ page: number;
989
+ limit: number;
990
+ total: number;
991
+ pages: number;
992
+ };
993
+ }>;
994
+ declare const createAgentGraph: (db: DatabaseClient) => (data: AgentGraphInsert) => Promise<{
995
+ tenantId: string;
996
+ projectId: string;
997
+ id: string;
998
+ name: string;
999
+ description: string | null;
1000
+ createdAt: string;
1001
+ updatedAt: string;
1002
+ defaultAgentId: string | null;
1003
+ models: {
1004
+ base?: {
1005
+ model?: string | undefined;
1006
+ providerOptions?: Record<string, unknown> | undefined;
1007
+ } | undefined;
1008
+ structuredOutput?: {
1009
+ model?: string | undefined;
1010
+ providerOptions?: Record<string, unknown> | undefined;
1011
+ } | undefined;
1012
+ summarizer?: {
1013
+ model?: string | undefined;
1014
+ providerOptions?: Record<string, unknown> | undefined;
1015
+ } | undefined;
1016
+ } | null;
1017
+ stopWhen: {
1018
+ transferCountIs?: number | undefined;
1019
+ } | null;
1020
+ contextConfigId: string | null;
1021
+ statusUpdates: {
1022
+ enabled?: boolean | undefined;
1023
+ numEvents?: number | undefined;
1024
+ timeInSeconds?: number | undefined;
1025
+ prompt?: string | undefined;
1026
+ statusComponents?: {
1027
+ type: string;
1028
+ description?: string | undefined;
1029
+ detailsSchema?: {
1030
+ type: "object";
1031
+ properties: Record<string, any>;
1032
+ required?: string[] | undefined;
1033
+ } | undefined;
1034
+ }[] | undefined;
1035
+ } | null;
1036
+ graphPrompt: string | null;
1037
+ }>;
1038
+ declare const updateAgentGraph: (db: DatabaseClient) => (params: {
1039
+ scopes: GraphScopeConfig;
1040
+ data: AgentGraphUpdate;
1041
+ }) => Promise<{
1042
+ tenantId: string;
1043
+ projectId: string;
1044
+ id: string;
1045
+ name: string;
1046
+ description: string | null;
1047
+ createdAt: string;
1048
+ updatedAt: string;
1049
+ defaultAgentId: string | null;
1050
+ models: {
1051
+ base?: {
1052
+ model?: string | undefined;
1053
+ providerOptions?: Record<string, unknown> | undefined;
1054
+ } | undefined;
1055
+ structuredOutput?: {
1056
+ model?: string | undefined;
1057
+ providerOptions?: Record<string, unknown> | undefined;
1058
+ } | undefined;
1059
+ summarizer?: {
1060
+ model?: string | undefined;
1061
+ providerOptions?: Record<string, unknown> | undefined;
1062
+ } | undefined;
1063
+ } | null;
1064
+ stopWhen: {
1065
+ transferCountIs?: number | undefined;
1066
+ } | null;
1067
+ contextConfigId: string | null;
1068
+ statusUpdates: {
1069
+ enabled?: boolean | undefined;
1070
+ numEvents?: number | undefined;
1071
+ timeInSeconds?: number | undefined;
1072
+ prompt?: string | undefined;
1073
+ statusComponents?: {
1074
+ type: string;
1075
+ description?: string | undefined;
1076
+ detailsSchema?: {
1077
+ type: "object";
1078
+ properties: Record<string, any>;
1079
+ required?: string[] | undefined;
1080
+ } | undefined;
1081
+ }[] | undefined;
1082
+ } | null;
1083
+ graphPrompt: string | null;
1084
+ }>;
1085
+ declare const deleteAgentGraph: (db: DatabaseClient) => (params: {
1086
+ scopes: GraphScopeConfig;
1087
+ }) => Promise<boolean>;
1088
+ /**
1089
+ * Helper function to fetch component relationships using efficient joins
1090
+ */
1091
+ declare const fetchComponentRelationships: (db: DatabaseClient) => <T extends Record<string, any>>(scopes: ProjectScopeConfig, agentIds: string[], config: {
1092
+ relationTable: any;
1093
+ componentTable: any;
1094
+ relationIdField: any;
1095
+ componentIdField: any;
1096
+ selectFields: Record<string, any>;
1097
+ }) => Promise<Record<string, T>>;
1098
+ declare const getGraphAgentInfos: (db: DatabaseClient) => ({ scopes, graphId, agentId, }: {
1099
+ scopes: ProjectScopeConfig;
1100
+ graphId: string;
1101
+ agentId: string;
1102
+ }) => Promise<{
1103
+ id: string;
1104
+ name: string;
1105
+ description: string;
1106
+ }[]>;
1107
+ declare const getFullGraphDefinition: (db: DatabaseClient) => ({ scopes: { tenantId, projectId, graphId }, }: {
1108
+ scopes: GraphScopeConfig;
1109
+ }) => Promise<FullGraphDefinition | null>;
1110
+ /**
1111
+ * Upsert an agent graph (create if it doesn't exist, update if it does)
1112
+ */
1113
+ declare const upsertAgentGraph: (db: DatabaseClient) => (params: {
1114
+ data: AgentGraphInsert;
1115
+ }) => Promise<any>;
1116
+
1117
+ declare const getAgentRelationById: (db: DatabaseClient) => (params: {
1118
+ scopes: GraphScopeConfig;
1119
+ relationId: string;
1120
+ }) => Promise<{
1121
+ tenantId: string;
1122
+ projectId: string;
1123
+ id: string;
1124
+ graphId: string;
1125
+ createdAt: string;
1126
+ updatedAt: string;
1127
+ sourceAgentId: string;
1128
+ targetAgentId: string | null;
1129
+ externalAgentId: string | null;
1130
+ relationType: string | null;
1131
+ } | undefined>;
1132
+ declare const listAgentRelations: (db: DatabaseClient) => (params: {
1133
+ scopes: GraphScopeConfig;
1134
+ pagination?: PaginationConfig;
1135
+ }) => Promise<{
1136
+ data: {
1137
+ tenantId: string;
1138
+ projectId: string;
1139
+ graphId: string;
1140
+ id: string;
1141
+ sourceAgentId: string;
1142
+ targetAgentId: string | null;
1143
+ externalAgentId: string | null;
1144
+ relationType: string | null;
1145
+ createdAt: string;
1146
+ updatedAt: string;
1147
+ }[];
1148
+ pagination: {
1149
+ page: number;
1150
+ limit: number;
1151
+ total: number;
1152
+ pages: number;
1153
+ };
1154
+ }>;
1155
+ declare const getAgentRelations: (db: DatabaseClient) => (params: {
1156
+ scopes: AgentScopeConfig;
1157
+ }) => Promise<{
1158
+ tenantId: string;
1159
+ projectId: string;
1160
+ id: string;
1161
+ graphId: string;
1162
+ createdAt: string;
1163
+ updatedAt: string;
1164
+ sourceAgentId: string;
1165
+ targetAgentId: string | null;
1166
+ externalAgentId: string | null;
1167
+ relationType: string | null;
1168
+ }[]>;
1169
+ declare const getAgentRelationsByGraph: (db: DatabaseClient) => (params: {
1170
+ scopes: GraphScopeConfig;
1171
+ }) => Promise<{
1172
+ tenantId: string;
1173
+ projectId: string;
1174
+ id: string;
1175
+ graphId: string;
1176
+ createdAt: string;
1177
+ updatedAt: string;
1178
+ sourceAgentId: string;
1179
+ targetAgentId: string | null;
1180
+ externalAgentId: string | null;
1181
+ relationType: string | null;
1182
+ }[]>;
1183
+ declare const getAgentRelationsBySource: (db: DatabaseClient) => (params: {
1184
+ scopes: GraphScopeConfig;
1185
+ sourceAgentId: string;
1186
+ pagination?: PaginationConfig;
1187
+ }) => Promise<{
1188
+ data: {
1189
+ tenantId: string;
1190
+ projectId: string;
1191
+ graphId: string;
1192
+ id: string;
1193
+ sourceAgentId: string;
1194
+ targetAgentId: string | null;
1195
+ externalAgentId: string | null;
1196
+ relationType: string | null;
1197
+ createdAt: string;
1198
+ updatedAt: string;
1199
+ }[];
1200
+ pagination: {
1201
+ page: number;
1202
+ limit: number;
1203
+ total: number;
1204
+ pages: number;
1205
+ };
1206
+ }>;
1207
+ declare const getAgentRelationsByTarget: (db: DatabaseClient) => (params: {
1208
+ scopes: GraphScopeConfig;
1209
+ targetAgentId: string;
1210
+ pagination?: PaginationConfig;
1211
+ }) => Promise<{
1212
+ data: {
1213
+ tenantId: string;
1214
+ projectId: string;
1215
+ graphId: string;
1216
+ id: string;
1217
+ sourceAgentId: string;
1218
+ targetAgentId: string | null;
1219
+ externalAgentId: string | null;
1220
+ relationType: string | null;
1221
+ createdAt: string;
1222
+ updatedAt: string;
1223
+ }[];
1224
+ pagination: {
1225
+ page: number;
1226
+ limit: number;
1227
+ total: number;
1228
+ pages: number;
1229
+ };
1230
+ }>;
1231
+ declare const getExternalAgentRelations: (db: DatabaseClient) => (params: {
1232
+ scopes: GraphScopeConfig;
1233
+ externalAgentId: string;
1234
+ pagination?: PaginationConfig;
1235
+ }) => Promise<{
1236
+ data: {
1237
+ tenantId: string;
1238
+ projectId: string;
1239
+ graphId: string;
1240
+ id: string;
1241
+ sourceAgentId: string;
1242
+ targetAgentId: string | null;
1243
+ externalAgentId: string | null;
1244
+ relationType: string | null;
1245
+ createdAt: string;
1246
+ updatedAt: string;
1247
+ }[];
1248
+ pagination: {
1249
+ page: number;
1250
+ limit: number;
1251
+ total: number;
1252
+ pages: number;
1253
+ };
1254
+ }>;
1255
+ declare const getRelatedAgentsForGraph: (db: DatabaseClient) => (params: {
1256
+ scopes: GraphScopeConfig;
1257
+ agentId: string;
1258
+ }) => Promise<{
1259
+ internalRelations: {
1260
+ id: string;
1261
+ name: string;
1262
+ description: string;
1263
+ relationType: string | null;
1264
+ }[];
1265
+ externalRelations: {
1266
+ id: string;
1267
+ relationType: string | null;
1268
+ externalAgent: {
1269
+ id: string;
1270
+ name: string;
1271
+ description: string;
1272
+ baseUrl: string;
1273
+ };
1274
+ }[];
1275
+ }>;
1276
+ declare const createAgentRelation: (db: DatabaseClient) => (params: AgentRelationInsert) => Promise<{
1277
+ tenantId: string;
1278
+ projectId: string;
1279
+ id: string;
1280
+ graphId: string;
1281
+ createdAt: string;
1282
+ updatedAt: string;
1283
+ sourceAgentId: string;
1284
+ targetAgentId: string | null;
1285
+ externalAgentId: string | null;
1286
+ relationType: string | null;
1287
+ }>;
1288
+ /**
1289
+ * Check if agent relation exists by graph, source, target, and relation type
1290
+ */
1291
+ declare const getAgentRelationByParams: (db: DatabaseClient) => (params: {
1292
+ scopes: GraphScopeConfig;
1293
+ sourceAgentId: string;
1294
+ targetAgentId?: string;
1295
+ externalAgentId?: string;
1296
+ relationType: string;
1297
+ }) => Promise<{
1298
+ tenantId: string;
1299
+ projectId: string;
1300
+ id: string;
1301
+ graphId: string;
1302
+ createdAt: string;
1303
+ updatedAt: string;
1304
+ sourceAgentId: string;
1305
+ targetAgentId: string | null;
1306
+ externalAgentId: string | null;
1307
+ relationType: string | null;
1308
+ } | undefined>;
1309
+ /**
1310
+ * Upsert agent relation (create if it doesn't exist, no-op if it does)
1311
+ */
1312
+ declare const upsertAgentRelation: (db: DatabaseClient) => (params: AgentRelationInsert) => Promise<{
1313
+ tenantId: string;
1314
+ projectId: string;
1315
+ id: string;
1316
+ graphId: string;
1317
+ createdAt: string;
1318
+ updatedAt: string;
1319
+ sourceAgentId: string;
1320
+ targetAgentId: string | null;
1321
+ externalAgentId: string | null;
1322
+ relationType: string | null;
1323
+ }>;
1324
+ declare const createExternalAgentRelation: (db: DatabaseClient) => (params: ExternalAgentRelationInsert) => Promise<{
1325
+ tenantId: string;
1326
+ projectId: string;
1327
+ id: string;
1328
+ graphId: string;
1329
+ createdAt: string;
1330
+ updatedAt: string;
1331
+ sourceAgentId: string;
1332
+ targetAgentId: string | null;
1333
+ externalAgentId: string | null;
1334
+ relationType: string | null;
1335
+ }>;
1336
+ declare const updateAgentRelation: (db: DatabaseClient) => (params: {
1337
+ scopes: GraphScopeConfig;
1338
+ relationId: string;
1339
+ data: AgentRelationUpdate;
1340
+ }) => Promise<{
1341
+ tenantId: string;
1342
+ projectId: string;
1343
+ id: string;
1344
+ graphId: string;
1345
+ createdAt: string;
1346
+ updatedAt: string;
1347
+ sourceAgentId: string;
1348
+ targetAgentId: string | null;
1349
+ externalAgentId: string | null;
1350
+ relationType: string | null;
1351
+ }>;
1352
+ declare const deleteAgentRelation: (db: DatabaseClient) => (params: {
1353
+ scopes: GraphScopeConfig;
1354
+ relationId: string;
1355
+ }) => Promise<boolean>;
1356
+ declare const deleteAgentRelationsByGraph: (db: DatabaseClient) => (params: {
1357
+ scopes: GraphScopeConfig;
1358
+ }) => Promise<boolean>;
1359
+ declare const createAgentToolRelation: (db: DatabaseClient) => (params: {
1360
+ scopes: GraphScopeConfig;
1361
+ relationId?: string;
1362
+ data: {
1363
+ agentId: string;
1364
+ toolId: string;
1365
+ selectedTools?: string[] | null;
1366
+ };
1367
+ }) => Promise<{
1368
+ tenantId: string;
1369
+ projectId: string;
1370
+ id: string;
1371
+ graphId: string;
1372
+ createdAt: string;
1373
+ updatedAt: string;
1374
+ toolId: string;
1375
+ selectedTools: string[] | null;
1376
+ agentId: string;
1377
+ }>;
1378
+ declare const updateAgentToolRelation: (db: DatabaseClient) => (params: {
1379
+ scopes: GraphScopeConfig;
1380
+ relationId: string;
1381
+ data: AgentToolRelationUpdate;
1382
+ }) => Promise<{
1383
+ tenantId: string;
1384
+ projectId: string;
1385
+ id: string;
1386
+ graphId: string;
1387
+ createdAt: string;
1388
+ updatedAt: string;
1389
+ toolId: string;
1390
+ selectedTools: string[] | null;
1391
+ agentId: string;
1392
+ }>;
1393
+ declare const deleteAgentToolRelation: (db: DatabaseClient) => (params: {
1394
+ scopes: GraphScopeConfig;
1395
+ relationId: string;
1396
+ }) => Promise<boolean>;
1397
+ declare const deleteAgentToolRelationByAgent: (db: DatabaseClient) => (params: {
1398
+ scopes: AgentScopeConfig;
1399
+ }) => Promise<boolean>;
1400
+ declare const getAgentToolRelationById: (db: DatabaseClient) => (params: {
1401
+ scopes: AgentScopeConfig;
1402
+ relationId: string;
1403
+ }) => Promise<{
1404
+ tenantId: string;
1405
+ projectId: string;
1406
+ id: string;
1407
+ graphId: string;
1408
+ createdAt: string;
1409
+ updatedAt: string;
1410
+ toolId: string;
1411
+ selectedTools: string[] | null;
1412
+ agentId: string;
1413
+ } | undefined>;
1414
+ declare const getAgentToolRelationByAgent: (db: DatabaseClient) => (params: {
1415
+ scopes: AgentScopeConfig;
1416
+ pagination?: PaginationConfig;
1417
+ }) => Promise<{
1418
+ data: {
1419
+ tenantId: string;
1420
+ projectId: string;
1421
+ graphId: string;
1422
+ agentId: string;
1423
+ id: string;
1424
+ toolId: string;
1425
+ selectedTools: string[] | null;
1426
+ createdAt: string;
1427
+ updatedAt: string;
1428
+ }[];
1429
+ pagination: {
1430
+ page: number;
1431
+ limit: number;
1432
+ total: number;
1433
+ pages: number;
1434
+ };
1435
+ }>;
1436
+ declare const getAgentToolRelationByTool: (db: DatabaseClient) => (params: {
1437
+ scopes: GraphScopeConfig;
1438
+ toolId: string;
1439
+ pagination?: PaginationConfig;
1440
+ }) => Promise<{
1441
+ data: {
1442
+ tenantId: string;
1443
+ projectId: string;
1444
+ graphId: string;
1445
+ agentId: string;
1446
+ id: string;
1447
+ toolId: string;
1448
+ selectedTools: string[] | null;
1449
+ createdAt: string;
1450
+ updatedAt: string;
1451
+ }[];
1452
+ pagination: {
1453
+ page: number;
1454
+ limit: number;
1455
+ total: number;
1456
+ pages: number;
1457
+ };
1458
+ }>;
1459
+ declare const listAgentToolRelations: (db: DatabaseClient) => (params: {
1460
+ scopes: GraphScopeConfig;
1461
+ pagination?: PaginationConfig;
1462
+ }) => Promise<{
1463
+ data: {
1464
+ tenantId: string;
1465
+ projectId: string;
1466
+ graphId: string;
1467
+ agentId: string;
1468
+ id: string;
1469
+ toolId: string;
1470
+ selectedTools: string[] | null;
1471
+ createdAt: string;
1472
+ updatedAt: string;
1473
+ }[];
1474
+ pagination: {
1475
+ page: number;
1476
+ limit: number;
1477
+ total: number;
1478
+ pages: number;
1479
+ };
1480
+ }>;
1481
+ declare const getToolsForAgent: (db: DatabaseClient) => (params: {
1482
+ scopes: AgentScopeConfig;
1483
+ pagination?: PaginationConfig;
1484
+ }) => Promise<{
1485
+ data: {
1486
+ id: string;
1487
+ tenantId: string;
1488
+ agentId: string;
1489
+ toolId: string;
1490
+ selectedTools: string[] | null;
1491
+ createdAt: string;
1492
+ updatedAt: string;
1493
+ tool: {
1494
+ id: string;
1495
+ name: string;
1496
+ config: {
1497
+ type: "mcp";
1498
+ mcp: ToolMcpConfig;
1499
+ };
1500
+ createdAt: string;
1501
+ updatedAt: string;
1502
+ capabilities: ToolServerCapabilities | null;
1503
+ lastHealthCheck: string | null;
1504
+ lastToolsSync: string | null;
1505
+ lastError: string | null;
1506
+ availableTools: McpToolDefinition[] | null;
1507
+ credentialReferenceId: string | null;
1508
+ };
1509
+ }[];
1510
+ pagination: {
1511
+ page: number;
1512
+ limit: number;
1513
+ total: number;
1514
+ pages: number;
1515
+ };
1516
+ }>;
1517
+ declare const getAgentsForTool: (db: DatabaseClient) => (params: {
1518
+ scopes: GraphScopeConfig;
1519
+ toolId: string;
1520
+ pagination?: PaginationConfig;
1521
+ }) => Promise<{
1522
+ data: {
1523
+ id: string;
1524
+ tenantId: string;
1525
+ agentId: string;
1526
+ toolId: string;
1527
+ selectedTools: string[] | null;
1528
+ createdAt: string;
1529
+ updatedAt: string;
1530
+ agent: {
1531
+ id: string;
1532
+ name: string;
1533
+ description: string;
1534
+ prompt: string;
1535
+ conversationHistoryConfig: ConversationHistoryConfig | null;
1536
+ models: {
1537
+ base?: {
1538
+ model?: string | undefined;
1539
+ providerOptions?: Record<string, unknown> | undefined;
1540
+ } | undefined;
1541
+ structuredOutput?: {
1542
+ model?: string | undefined;
1543
+ providerOptions?: Record<string, unknown> | undefined;
1544
+ } | undefined;
1545
+ summarizer?: {
1546
+ model?: string | undefined;
1547
+ providerOptions?: Record<string, unknown> | undefined;
1548
+ } | undefined;
1549
+ } | null;
1550
+ stopWhen: {
1551
+ stepCountIs?: number | undefined;
1552
+ } | null;
1553
+ createdAt: string;
1554
+ updatedAt: string;
1555
+ };
1556
+ }[];
1557
+ pagination: {
1558
+ page: number;
1559
+ limit: number;
1560
+ total: number;
1561
+ pages: number;
1562
+ };
1563
+ }>;
1564
+ declare const validateInternalAgent: (db: DatabaseClient) => (params: {
1565
+ scopes: AgentScopeConfig;
1566
+ }) => Promise<boolean>;
1567
+ declare const validateExternalAgent: (db: DatabaseClient) => (params: {
1568
+ scopes: AgentScopeConfig;
1569
+ }) => Promise<boolean>;
1570
+
1571
+ declare const getAgentById: (db: DatabaseClient) => (params: {
1572
+ scopes: GraphScopeConfig;
1573
+ agentId: string;
1574
+ }) => Promise<{
1575
+ tenantId: string;
1576
+ projectId: string;
1577
+ id: string;
1578
+ name: string;
1579
+ description: string;
1580
+ prompt: string;
1581
+ graphId: string;
1582
+ createdAt: string;
1583
+ updatedAt: string;
1584
+ conversationHistoryConfig: ConversationHistoryConfig | null;
1585
+ models: {
1586
+ base?: {
1587
+ model?: string | undefined;
1588
+ providerOptions?: Record<string, unknown> | undefined;
1589
+ } | undefined;
1590
+ structuredOutput?: {
1591
+ model?: string | undefined;
1592
+ providerOptions?: Record<string, unknown> | undefined;
1593
+ } | undefined;
1594
+ summarizer?: {
1595
+ model?: string | undefined;
1596
+ providerOptions?: Record<string, unknown> | undefined;
1597
+ } | undefined;
1598
+ } | null;
1599
+ stopWhen: {
1600
+ stepCountIs?: number | undefined;
1601
+ } | null;
1602
+ } | undefined>;
1603
+ declare const listAgents: (db: DatabaseClient) => (params: {
1604
+ scopes: GraphScopeConfig;
1605
+ }) => Promise<{
1606
+ tenantId: string;
1607
+ projectId: string;
1608
+ id: string;
1609
+ name: string;
1610
+ description: string;
1611
+ prompt: string;
1612
+ graphId: string;
1613
+ createdAt: string;
1614
+ updatedAt: string;
1615
+ conversationHistoryConfig: ConversationHistoryConfig | null;
1616
+ models: {
1617
+ base?: {
1618
+ model?: string | undefined;
1619
+ providerOptions?: Record<string, unknown> | undefined;
1620
+ } | undefined;
1621
+ structuredOutput?: {
1622
+ model?: string | undefined;
1623
+ providerOptions?: Record<string, unknown> | undefined;
1624
+ } | undefined;
1625
+ summarizer?: {
1626
+ model?: string | undefined;
1627
+ providerOptions?: Record<string, unknown> | undefined;
1628
+ } | undefined;
1629
+ } | null;
1630
+ stopWhen: {
1631
+ stepCountIs?: number | undefined;
1632
+ } | null;
1633
+ }[]>;
1634
+ declare const listAgentsPaginated: (db: DatabaseClient) => (params: {
1635
+ scopes: GraphScopeConfig;
1636
+ pagination?: PaginationConfig;
1637
+ }) => Promise<{
1638
+ data: {
1639
+ tenantId: string;
1640
+ projectId: string;
1641
+ graphId: string;
1642
+ id: string;
1643
+ name: string;
1644
+ description: string;
1645
+ prompt: string;
1646
+ conversationHistoryConfig: ConversationHistoryConfig | null;
1647
+ models: {
1648
+ base?: {
1649
+ model?: string | undefined;
1650
+ providerOptions?: Record<string, unknown> | undefined;
1651
+ } | undefined;
1652
+ structuredOutput?: {
1653
+ model?: string | undefined;
1654
+ providerOptions?: Record<string, unknown> | undefined;
1655
+ } | undefined;
1656
+ summarizer?: {
1657
+ model?: string | undefined;
1658
+ providerOptions?: Record<string, unknown> | undefined;
1659
+ } | undefined;
1660
+ } | null;
1661
+ stopWhen: {
1662
+ stepCountIs?: number | undefined;
1663
+ } | null;
1664
+ createdAt: string;
1665
+ updatedAt: string;
1666
+ }[];
1667
+ pagination: {
1668
+ page: number;
1669
+ limit: number;
1670
+ total: number;
1671
+ pages: number;
1672
+ };
1673
+ }>;
1674
+ declare const createAgent: (db: DatabaseClient) => (params: AgentInsert) => Promise<{
1675
+ tenantId: string;
1676
+ projectId: string;
1677
+ id: string;
1678
+ name: string;
1679
+ description: string;
1680
+ prompt: string;
1681
+ graphId: string;
1682
+ createdAt: string;
1683
+ updatedAt: string;
1684
+ conversationHistoryConfig: ConversationHistoryConfig | null;
1685
+ models: {
1686
+ base?: {
1687
+ model?: string | undefined;
1688
+ providerOptions?: Record<string, unknown> | undefined;
1689
+ } | undefined;
1690
+ structuredOutput?: {
1691
+ model?: string | undefined;
1692
+ providerOptions?: Record<string, unknown> | undefined;
1693
+ } | undefined;
1694
+ summarizer?: {
1695
+ model?: string | undefined;
1696
+ providerOptions?: Record<string, unknown> | undefined;
1697
+ } | undefined;
1698
+ } | null;
1699
+ stopWhen: {
1700
+ stepCountIs?: number | undefined;
1701
+ } | null;
1702
+ }>;
1703
+ declare const updateAgent: (db: DatabaseClient) => (params: {
1704
+ scopes: GraphScopeConfig;
1705
+ agentId: string;
1706
+ data: AgentUpdate;
1707
+ }) => Promise<{
1708
+ tenantId: string;
1709
+ projectId: string;
1710
+ id: string;
1711
+ name: string;
1712
+ description: string;
1713
+ prompt: string;
1714
+ graphId: string;
1715
+ createdAt: string;
1716
+ updatedAt: string;
1717
+ conversationHistoryConfig: ConversationHistoryConfig | null;
1718
+ models: {
1719
+ base?: {
1720
+ model?: string | undefined;
1721
+ providerOptions?: Record<string, unknown> | undefined;
1722
+ } | undefined;
1723
+ structuredOutput?: {
1724
+ model?: string | undefined;
1725
+ providerOptions?: Record<string, unknown> | undefined;
1726
+ } | undefined;
1727
+ summarizer?: {
1728
+ model?: string | undefined;
1729
+ providerOptions?: Record<string, unknown> | undefined;
1730
+ } | undefined;
1731
+ } | null;
1732
+ stopWhen: {
1733
+ stepCountIs?: number | undefined;
1734
+ } | null;
1735
+ }>;
1736
+ /**
1737
+ * Upsert agent (create if it doesn't exist, update if it does)
1738
+ */
1739
+ declare const upsertAgent: (db: DatabaseClient) => (params: {
1740
+ data: AgentInsert;
1741
+ }) => Promise<AgentSelect>;
1742
+ declare const deleteAgent: (db: DatabaseClient) => (params: {
1743
+ scopes: GraphScopeConfig;
1744
+ agentId: string;
1745
+ }) => Promise<boolean>;
1746
+ declare const getAgentsByIds: (db: DatabaseClient) => (params: {
1747
+ scopes: GraphScopeConfig;
1748
+ agentIds: string[];
1749
+ }) => Promise<{
1750
+ tenantId: string;
1751
+ projectId: string;
1752
+ graphId: string;
1753
+ id: string;
1754
+ name: string;
1755
+ description: string;
1756
+ prompt: string;
1757
+ conversationHistoryConfig: ConversationHistoryConfig | null;
1758
+ models: {
1759
+ base?: {
1760
+ model?: string | undefined;
1761
+ providerOptions?: Record<string, unknown> | undefined;
1762
+ } | undefined;
1763
+ structuredOutput?: {
1764
+ model?: string | undefined;
1765
+ providerOptions?: Record<string, unknown> | undefined;
1766
+ } | undefined;
1767
+ summarizer?: {
1768
+ model?: string | undefined;
1769
+ providerOptions?: Record<string, unknown> | undefined;
1770
+ } | undefined;
1771
+ } | null;
1772
+ stopWhen: {
1773
+ stepCountIs?: number | undefined;
1774
+ } | null;
1775
+ createdAt: string;
1776
+ updatedAt: string;
1777
+ }[]>;
1778
+
1779
+ declare const getApiKeyById: (db: DatabaseClient) => (params: {
1780
+ scopes: ProjectScopeConfig;
1781
+ id: string;
1782
+ }) => Promise<{
1783
+ tenantId: string;
1784
+ projectId: string;
1785
+ id: string;
1786
+ name: string | null;
1787
+ graphId: string;
1788
+ publicId: string;
1789
+ keyHash: string;
1790
+ keyPrefix: string;
1791
+ lastUsedAt: string | null;
1792
+ expiresAt: string | null;
1793
+ createdAt: string;
1794
+ updatedAt: string;
1795
+ } | undefined>;
1796
+ declare const getApiKeyByPublicId: (db: DatabaseClient) => (publicId: string) => Promise<{
1797
+ tenantId: string;
1798
+ projectId: string;
1799
+ id: string;
1800
+ name: string | null;
1801
+ graphId: string;
1802
+ publicId: string;
1803
+ keyHash: string;
1804
+ keyPrefix: string;
1805
+ lastUsedAt: string | null;
1806
+ expiresAt: string | null;
1807
+ createdAt: string;
1808
+ updatedAt: string;
1809
+ } | undefined>;
1810
+ declare const listApiKeys: (db: DatabaseClient) => (params: {
1811
+ scopes: ProjectScopeConfig;
1812
+ graphId?: string;
1813
+ }) => Promise<{
1814
+ tenantId: string;
1815
+ projectId: string;
1816
+ id: string;
1817
+ name: string | null;
1818
+ graphId: string;
1819
+ publicId: string;
1820
+ keyHash: string;
1821
+ keyPrefix: string;
1822
+ lastUsedAt: string | null;
1823
+ expiresAt: string | null;
1824
+ createdAt: string;
1825
+ updatedAt: string;
1826
+ }[]>;
1827
+ declare const listApiKeysPaginated: (db: DatabaseClient) => (params: {
1828
+ scopes: ProjectScopeConfig;
1829
+ pagination?: PaginationConfig;
1830
+ graphId?: string;
1831
+ }) => Promise<{
1832
+ data: ApiKeySelect[];
1833
+ pagination: {
1834
+ page: number;
1835
+ limit: number;
1836
+ total: number;
1837
+ pages: number;
1838
+ };
1839
+ }>;
1840
+ declare const createApiKey: (db: DatabaseClient) => (params: ApiKeyInsert) => Promise<{
1841
+ tenantId: string;
1842
+ projectId: string;
1843
+ id: string;
1844
+ name: string | null;
1845
+ graphId: string;
1846
+ publicId: string;
1847
+ keyHash: string;
1848
+ keyPrefix: string;
1849
+ lastUsedAt: string | null;
1850
+ expiresAt: string | null;
1851
+ createdAt: string;
1852
+ updatedAt: string;
1853
+ }>;
1854
+ declare const updateApiKey: (db: DatabaseClient) => (params: {
1855
+ scopes: ProjectScopeConfig;
1856
+ id: string;
1857
+ data: ApiKeyUpdate;
1858
+ }) => Promise<{
1859
+ tenantId: string;
1860
+ projectId: string;
1861
+ id: string;
1862
+ name: string | null;
1863
+ graphId: string;
1864
+ publicId: string;
1865
+ keyHash: string;
1866
+ keyPrefix: string;
1867
+ lastUsedAt: string | null;
1868
+ expiresAt: string | null;
1869
+ createdAt: string;
1870
+ updatedAt: string;
1871
+ }>;
1872
+ declare const deleteApiKey: (db: DatabaseClient) => (params: {
1873
+ scopes: ProjectScopeConfig;
1874
+ id: string;
1875
+ }) => Promise<boolean>;
1876
+ declare const hasApiKey: (db: DatabaseClient) => (params: {
1877
+ scopes: ProjectScopeConfig;
1878
+ id: string;
1879
+ }) => Promise<boolean>;
1880
+ declare const updateApiKeyLastUsed: (db: DatabaseClient) => (id: string) => Promise<void>;
1881
+ declare const countApiKeys: (db: DatabaseClient) => (params: {
1882
+ scopes: ProjectScopeConfig;
1883
+ graphId?: string;
1884
+ }) => Promise<number>;
1885
+ /**
1886
+ * Create a new API key
1887
+ * Returns both the API key record and the full key (which should be shown to the user only once)
1888
+ */
1889
+ declare const generateAndCreateApiKey: (params: CreateApiKeyParams, db: DatabaseClient) => Promise<ApiKeyCreateResult>;
1890
+ /**
1891
+ * Validate an API key and return the associated record if valid
1892
+ */
1893
+ declare const validateAndGetApiKey: (key: string, db: DatabaseClient) => Promise<ApiKeySelect | null>;
1894
+
1895
+ declare const getArtifactComponentById: (db: DatabaseClient) => (params: {
1896
+ scopes: ProjectScopeConfig;
1897
+ id: string;
1898
+ }) => Promise<{
1899
+ tenantId: string;
1900
+ projectId: string;
1901
+ id: string;
1902
+ name: string;
1903
+ description: string;
1904
+ createdAt: string;
1905
+ updatedAt: string;
1906
+ summaryProps: Record<string, unknown> | null;
1907
+ fullProps: Record<string, unknown> | null;
1908
+ } | undefined>;
1909
+ declare const listArtifactComponents: (db: DatabaseClient) => (params: {
1910
+ scopes: ProjectScopeConfig;
1911
+ }) => Promise<{
1912
+ tenantId: string;
1913
+ projectId: string;
1914
+ id: string;
1915
+ name: string;
1916
+ description: string;
1917
+ summaryProps: Record<string, unknown> | null;
1918
+ fullProps: Record<string, unknown> | null;
1919
+ createdAt: string;
1920
+ updatedAt: string;
1921
+ }[]>;
1922
+ declare const listArtifactComponentsPaginated: (db: DatabaseClient) => (params: {
1923
+ scopes: ProjectScopeConfig;
1924
+ pagination?: PaginationConfig;
1925
+ }) => Promise<{
1926
+ data: ArtifactComponentSelect[];
1927
+ pagination: {
1928
+ page: number;
1929
+ limit: number;
1930
+ total: number;
1931
+ pages: number;
1932
+ };
1933
+ }>;
1934
+ declare const createArtifactComponent: (db: DatabaseClient) => (params: ArtifactComponentInsert) => Promise<{
1935
+ tenantId: string;
1936
+ projectId: string;
1937
+ id: string;
1938
+ name: string;
1939
+ description: string;
1940
+ createdAt: string;
1941
+ updatedAt: string;
1942
+ summaryProps: Record<string, unknown> | null;
1943
+ fullProps: Record<string, unknown> | null;
1944
+ }>;
1945
+ declare const updateArtifactComponent: (db: DatabaseClient) => (params: {
1946
+ scopes: ProjectScopeConfig;
1947
+ id: string;
1948
+ data: ArtifactComponentUpdate;
1949
+ }) => Promise<{
1950
+ tenantId: string;
1951
+ projectId: string;
1952
+ id: string;
1953
+ name: string;
1954
+ description: string;
1955
+ createdAt: string;
1956
+ updatedAt: string;
1957
+ summaryProps: Record<string, unknown> | null;
1958
+ fullProps: Record<string, unknown> | null;
1959
+ }>;
1960
+ declare const deleteArtifactComponent: (db: DatabaseClient) => (params: {
1961
+ scopes: ProjectScopeConfig;
1962
+ id: string;
1963
+ }) => Promise<boolean>;
1964
+ declare const getArtifactComponentsForAgent: (db: DatabaseClient) => (params: {
1965
+ scopes: AgentScopeConfig;
1966
+ }) => Promise<{
1967
+ id: string;
1968
+ tenantId: string;
1969
+ projectId: string;
1970
+ name: string;
1971
+ description: string;
1972
+ summaryProps: Record<string, unknown> | null;
1973
+ fullProps: Record<string, unknown> | null;
1974
+ createdAt: string;
1975
+ updatedAt: string;
1976
+ }[]>;
1977
+ declare const associateArtifactComponentWithAgent: (db: DatabaseClient) => (params: {
1978
+ scopes: AgentScopeConfig;
1979
+ artifactComponentId: string;
1980
+ }) => Promise<{
1981
+ tenantId: string;
1982
+ projectId: string;
1983
+ id: string;
1984
+ graphId: string;
1985
+ createdAt: string;
1986
+ agentId: string;
1987
+ artifactComponentId: string;
1988
+ }>;
1989
+ declare const removeArtifactComponentFromAgent: (db: DatabaseClient) => (params: {
1990
+ scopes: AgentScopeConfig;
1991
+ artifactComponentId: string;
1992
+ }) => Promise<boolean>;
1993
+ declare const deleteAgentArtifactComponentRelationByAgent: (db: DatabaseClient) => (params: {
1994
+ scopes: AgentScopeConfig;
1995
+ }) => Promise<boolean>;
1996
+ declare const getAgentsUsingArtifactComponent: (db: DatabaseClient) => (params: {
1997
+ scopes: ProjectScopeConfig;
1998
+ artifactComponentId: string;
1999
+ }) => Promise<{
2000
+ graphId: string;
2001
+ agentId: string;
2002
+ createdAt: string;
2003
+ }[]>;
2004
+ declare const isArtifactComponentAssociatedWithAgent: (db: DatabaseClient) => (params: {
2005
+ scopes: AgentScopeConfig;
2006
+ artifactComponentId: string;
2007
+ }) => Promise<boolean>;
2008
+ declare const graphHasArtifactComponents: (db: DatabaseClient) => (params: {
2009
+ scopes: GraphScopeConfig;
2010
+ }) => Promise<boolean>;
2011
+ declare const countArtifactComponents: (db: DatabaseClient) => (params: {
2012
+ scopes: ProjectScopeConfig;
2013
+ }) => Promise<number>;
2014
+ declare const countArtifactComponentsForAgent: (db: DatabaseClient) => (params: {
2015
+ scopes: AgentScopeConfig;
2016
+ }) => Promise<number>;
2017
+ /**
2018
+ * Upsert agent-artifact component relation (create if it doesn't exist, no-op if it does)
2019
+ */
2020
+ declare const upsertAgentArtifactComponentRelation: (db: DatabaseClient) => (params: {
2021
+ scopes: AgentScopeConfig;
2022
+ artifactComponentId: string;
2023
+ }) => Promise<{
2024
+ tenantId: string;
2025
+ projectId: string;
2026
+ id: string;
2027
+ graphId: string;
2028
+ createdAt: string;
2029
+ agentId: string;
2030
+ artifactComponentId: string;
2031
+ } | null>;
2032
+ /**
2033
+ * Upsert an artifact component (create if it doesn't exist, update if it does)
2034
+ */
2035
+ declare const upsertArtifactComponent: (db: DatabaseClient) => (params: {
2036
+ data: ArtifactComponentInsert;
2037
+ }) => Promise<ArtifactComponentSelect>;
2038
+
2039
+ /**
2040
+ * Get cached context data for a conversation with optional request hash validation
2041
+ */
2042
+ declare const getCacheEntry: (db: DatabaseClient) => (params: {
2043
+ conversationId: string;
2044
+ contextConfigId: string;
2045
+ contextVariableKey: string;
2046
+ requestHash?: string;
2047
+ }) => Promise<ContextCacheSelect | null>;
2048
+ /**
2049
+ * Set cached context data for a conversation
2050
+ */
2051
+ declare const setCacheEntry: (db: DatabaseClient) => (entry: ContextCacheInsert) => Promise<ContextCacheSelect | null>;
2052
+ /**
2053
+ * Clear cache entries for a specific conversation
2054
+ */
2055
+ declare const clearConversationCache: (db: DatabaseClient) => (params: {
2056
+ scopes: ProjectScopeConfig;
2057
+ conversationId: string;
2058
+ }) => Promise<number>;
2059
+ /**
2060
+ * Clear all cache entries for a specific context configuration
2061
+ */
2062
+ declare const clearContextConfigCache: (db: DatabaseClient) => (params: {
2063
+ scopes: ProjectScopeConfig;
2064
+ contextConfigId: string;
2065
+ }) => Promise<number>;
2066
+ /**
2067
+ * Clean up all cache entries for a tenant
2068
+ */
2069
+ declare const cleanupTenantCache: (db: DatabaseClient) => (params: {
2070
+ scopes: ProjectScopeConfig;
2071
+ }) => Promise<number>;
2072
+ /**
2073
+ * Invalidate the request context cache for a conversation
2074
+ */
2075
+ declare const invalidateRequestContextCache: (db: DatabaseClient) => (params: {
2076
+ scopes: ProjectScopeConfig;
2077
+ conversationId: string;
2078
+ contextConfigId: string;
2079
+ }) => Promise<number>;
2080
+ /**
2081
+ * Invalidate specific cache entries for invocation-trigger definitions
2082
+ */
2083
+ declare const invalidateInvocationDefinitionsCache: (db: DatabaseClient) => (params: {
2084
+ scopes: ProjectScopeConfig;
2085
+ conversationId: string;
2086
+ contextConfigId: string;
2087
+ invocationDefinitionIds: string[];
2088
+ }) => Promise<number>;
2089
+ /**
2090
+ * Get all cache entries for a conversation
2091
+ */
2092
+ declare const getConversationCacheEntries: (db: DatabaseClient) => (params: {
2093
+ scopes: ProjectScopeConfig;
2094
+ conversationId: string;
2095
+ }) => Promise<ContextCacheSelect[]>;
2096
+ /**
2097
+ * Get all cache entries for a context configuration
2098
+ */
2099
+ declare const getContextConfigCacheEntries: (db: DatabaseClient) => (params: {
2100
+ scopes: ProjectScopeConfig;
2101
+ contextConfigId: string;
2102
+ }) => Promise<ContextCacheSelect[]>;
2103
+
2104
+ declare const getContextConfigById: (db: DatabaseClient) => (params: {
2105
+ scopes: ProjectScopeConfig;
2106
+ id: string;
2107
+ }) => Promise<{
2108
+ tenantId: string;
2109
+ projectId: string;
2110
+ id: string;
2111
+ name: string;
2112
+ description: string;
2113
+ createdAt: string;
2114
+ updatedAt: string;
2115
+ requestContextSchema: unknown;
2116
+ contextVariables: Record<string, ContextFetchDefinition> | null;
2117
+ } | undefined>;
2118
+ declare const listContextConfigs: (db: DatabaseClient) => (params: {
2119
+ scopes: ProjectScopeConfig;
2120
+ }) => Promise<{
2121
+ tenantId: string;
2122
+ projectId: string;
2123
+ id: string;
2124
+ name: string;
2125
+ description: string;
2126
+ createdAt: string;
2127
+ updatedAt: string;
2128
+ requestContextSchema: unknown;
2129
+ contextVariables: Record<string, ContextFetchDefinition> | null;
2130
+ }[]>;
2131
+ declare const listContextConfigsPaginated: (db: DatabaseClient) => (params: {
2132
+ scopes: ProjectScopeConfig;
2133
+ pagination?: PaginationConfig;
2134
+ }) => Promise<{
2135
+ data: any[];
2136
+ pagination: {
2137
+ page: number;
2138
+ limit: number;
2139
+ total: number;
2140
+ pages: number;
2141
+ };
2142
+ }>;
2143
+ declare const createContextConfig: (db: DatabaseClient) => (params: ContextConfigInsert) => Promise<{
2144
+ tenantId: string;
2145
+ projectId: string;
2146
+ id: string;
2147
+ name: string;
2148
+ description: string;
2149
+ createdAt: string;
2150
+ updatedAt: string;
2151
+ requestContextSchema: unknown;
2152
+ contextVariables: Record<string, ContextFetchDefinition> | null;
2153
+ }>;
2154
+ declare const updateContextConfig: (db: DatabaseClient) => (params: {
2155
+ scopes: ProjectScopeConfig;
2156
+ id: string;
2157
+ data: Partial<ContextConfigUpdate>;
2158
+ }) => Promise<{
2159
+ tenantId: string;
2160
+ projectId: string;
2161
+ id: string;
2162
+ name: string;
2163
+ description: string;
2164
+ createdAt: string;
2165
+ updatedAt: string;
2166
+ requestContextSchema: unknown;
2167
+ contextVariables: Record<string, ContextFetchDefinition> | null;
2168
+ }>;
2169
+ declare const deleteContextConfig: (db: DatabaseClient) => (params: {
2170
+ scopes: ProjectScopeConfig;
2171
+ id: string;
2172
+ }) => Promise<boolean>;
2173
+ declare const hasContextConfig: (db: DatabaseClient) => (params: {
2174
+ scopes: ProjectScopeConfig;
2175
+ id: string;
2176
+ }) => Promise<boolean>;
2177
+ declare const countContextConfigs: (db: DatabaseClient) => (params: {
2178
+ scopes: ProjectScopeConfig;
2179
+ }) => Promise<number>;
2180
+ declare const getContextConfigsByName: (db: DatabaseClient) => (params: {
2181
+ scopes: ProjectScopeConfig;
2182
+ name: string;
2183
+ }) => Promise<{
2184
+ tenantId: string;
2185
+ projectId: string;
2186
+ id: string;
2187
+ name: string;
2188
+ description: string;
2189
+ createdAt: string;
2190
+ updatedAt: string;
2191
+ requestContextSchema: unknown;
2192
+ contextVariables: Record<string, ContextFetchDefinition> | null;
2193
+ }[]>;
2194
+ /**
2195
+ * Upsert a context config (create if it doesn't exist, update if it does)
2196
+ */
2197
+ declare const upsertContextConfig: (db: DatabaseClient) => (params: {
2198
+ data: ContextConfigInsert;
2199
+ }) => Promise<{
2200
+ tenantId: string;
2201
+ projectId: string;
2202
+ id: string;
2203
+ name: string;
2204
+ description: string;
2205
+ createdAt: string;
2206
+ updatedAt: string;
2207
+ requestContextSchema: unknown;
2208
+ contextVariables: Record<string, ContextFetchDefinition> | null;
2209
+ }>;
2210
+
2211
+ declare const listConversations: (db: DatabaseClient) => (params: {
2212
+ scopes: ProjectScopeConfig;
2213
+ userId?: string;
2214
+ pagination?: PaginationConfig;
2215
+ }) => Promise<{
2216
+ conversations: ConversationSelect[];
2217
+ total: number;
2218
+ }>;
2219
+ declare const createConversation: (db: DatabaseClient) => (params: ConversationInsert) => Promise<{
2220
+ tenantId: string;
2221
+ projectId: string;
2222
+ id: string;
2223
+ createdAt: string;
2224
+ updatedAt: string;
2225
+ title: string | null;
2226
+ metadata: ConversationMetadata | null;
2227
+ userId: string | null;
2228
+ activeAgentId: string;
2229
+ lastContextResolution: string | null;
2230
+ }>;
2231
+ declare const updateConversation: (db: DatabaseClient) => (params: {
2232
+ scopes: ProjectScopeConfig;
2233
+ conversationId: string;
2234
+ data: ConversationUpdate;
2235
+ }) => Promise<{
2236
+ tenantId: string;
2237
+ projectId: string;
2238
+ id: string;
2239
+ createdAt: string;
2240
+ updatedAt: string;
2241
+ title: string | null;
2242
+ metadata: ConversationMetadata | null;
2243
+ userId: string | null;
2244
+ activeAgentId: string;
2245
+ lastContextResolution: string | null;
2246
+ }>;
2247
+ declare const deleteConversation: (db: DatabaseClient) => (params: {
2248
+ scopes: ProjectScopeConfig;
2249
+ conversationId: string;
2250
+ }) => Promise<boolean>;
2251
+ declare const updateConversationActiveAgent: (db: DatabaseClient) => (params: {
2252
+ scopes: ProjectScopeConfig;
2253
+ conversationId: string;
2254
+ activeAgentId: string;
2255
+ }) => Promise<{
2256
+ tenantId: string;
2257
+ projectId: string;
2258
+ id: string;
2259
+ createdAt: string;
2260
+ updatedAt: string;
2261
+ title: string | null;
2262
+ metadata: ConversationMetadata | null;
2263
+ userId: string | null;
2264
+ activeAgentId: string;
2265
+ lastContextResolution: string | null;
2266
+ }>;
2267
+ declare const getConversation: (db: DatabaseClient) => (params: {
2268
+ scopes: ProjectScopeConfig;
2269
+ conversationId: string;
2270
+ }) => Promise<{
2271
+ tenantId: string;
2272
+ projectId: string;
2273
+ id: string;
2274
+ createdAt: string;
2275
+ updatedAt: string;
2276
+ title: string | null;
2277
+ metadata: ConversationMetadata | null;
2278
+ userId: string | null;
2279
+ activeAgentId: string;
2280
+ lastContextResolution: string | null;
2281
+ } | undefined>;
2282
+ declare const createOrGetConversation: (db: DatabaseClient) => (input: ConversationInsert) => Promise<{
2283
+ id: string;
2284
+ tenantId: string;
2285
+ projectId: string;
2286
+ userId: string | null | undefined;
2287
+ activeAgentId: string;
2288
+ title: string | null | undefined;
2289
+ lastContextResolution: string | null | undefined;
2290
+ metadata: ConversationMetadata | null | undefined;
2291
+ createdAt: string;
2292
+ updatedAt: string;
2293
+ }>;
2294
+ /**
2295
+ * Get conversation history with filtering and context management
2296
+ */
2297
+ declare const getConversationHistory: (db: DatabaseClient) => (params: {
2298
+ scopes: ProjectScopeConfig;
2299
+ conversationId: string;
2300
+ options?: ConversationHistoryConfig;
2301
+ }) => Promise<any[]>;
2302
+ /**
2303
+ * Get active agent for a conversation
2304
+ */
2305
+ declare const getActiveAgentForConversation: (db: DatabaseClient) => (params: {
2306
+ scopes: ProjectScopeConfig;
2307
+ conversationId: string;
2308
+ }) => Promise<{
2309
+ tenantId: string;
2310
+ projectId: string;
2311
+ id: string;
2312
+ createdAt: string;
2313
+ updatedAt: string;
2314
+ title: string | null;
2315
+ metadata: ConversationMetadata | null;
2316
+ userId: string | null;
2317
+ activeAgentId: string;
2318
+ lastContextResolution: string | null;
2319
+ } | undefined>;
2320
+ /**
2321
+ * Set active agent for a conversation (upsert operation)
2322
+ */
2323
+ declare const setActiveAgentForConversation: (db: DatabaseClient) => (params: {
2324
+ scopes: ProjectScopeConfig;
2325
+ conversationId: string;
2326
+ agentId: string;
2327
+ }) => Promise<void>;
2328
+ declare const setActiveAgentForThread: (db: DatabaseClient) => ({ scopes, threadId, agentId, }: {
2329
+ scopes: ProjectScopeConfig;
2330
+ threadId: string;
2331
+ agentId: string;
2332
+ }) => Promise<void>;
2333
+
2334
+ type CredentialReferenceWithTools = CredentialReferenceSelect & {
2335
+ tools: ToolSelect[];
2336
+ };
2337
+ /**
2338
+ * Get a credential reference by ID
2339
+ */
2340
+ declare const getCredentialReference: (db: DatabaseClient) => (params: {
2341
+ scopes: ProjectScopeConfig;
2342
+ id: string;
2343
+ }) => Promise<CredentialReferenceSelect | undefined>;
2344
+ /**
2345
+ * Get a credential reference by ID with its related tools
2346
+ */
2347
+ declare const getCredentialReferenceWithTools: (db: DatabaseClient) => (params: {
2348
+ scopes: ProjectScopeConfig;
2349
+ id: string;
2350
+ }) => Promise<CredentialReferenceWithTools | undefined>;
2351
+ /**
2352
+ * List all credential references for a tenant/project
2353
+ */
2354
+ declare const listCredentialReferences: (db: DatabaseClient) => (params: {
2355
+ scopes: ProjectScopeConfig;
2356
+ }) => Promise<CredentialReferenceSelect[]>;
2357
+ /**
2358
+ * List credential references with pagination
2359
+ */
2360
+ declare const listCredentialReferencesPaginated: (db: DatabaseClient) => (params: {
2361
+ scopes: ProjectScopeConfig;
2362
+ pagination?: PaginationConfig;
2363
+ }) => Promise<{
2364
+ data: CredentialReferenceSelect[];
2365
+ pagination: {
2366
+ page: number;
2367
+ limit: number;
2368
+ total: number;
2369
+ pages: number;
2370
+ };
2371
+ }>;
2372
+ /**
2373
+ * Create a new credential reference
2374
+ */
2375
+ declare const createCredentialReference: (db: DatabaseClient) => (params: CredentialReferenceInsert) => Promise<CredentialReferenceSelect>;
2376
+ /**
2377
+ * Update a credential reference
2378
+ */
2379
+ declare const updateCredentialReference: (db: DatabaseClient) => (params: {
2380
+ scopes: ProjectScopeConfig;
2381
+ id: string;
2382
+ data: Partial<CredentialReferenceUpdate>;
2383
+ }) => Promise<CredentialReferenceWithTools | undefined>;
2384
+ /**
2385
+ * Delete a credential reference
2386
+ */
2387
+ declare const deleteCredentialReference: (db: DatabaseClient) => (params: {
2388
+ scopes: ProjectScopeConfig;
2389
+ id: string;
2390
+ }) => Promise<boolean>;
2391
+ /**
2392
+ * Check if a credential reference exists
2393
+ */
2394
+ declare const hasCredentialReference: (db: DatabaseClient) => (params: {
2395
+ scopes: ProjectScopeConfig;
2396
+ id: string;
2397
+ }) => Promise<boolean>;
2398
+ /**
2399
+ * Get credential reference by ID (simple version without tools)
2400
+ */
2401
+ declare const getCredentialReferenceById: (db: DatabaseClient) => (params: {
2402
+ scopes: ProjectScopeConfig;
2403
+ id: string;
2404
+ }) => Promise<CredentialReferenceSelect | null>;
2405
+ /**
2406
+ * Count credential references for a tenant/project
2407
+ */
2408
+ declare const countCredentialReferences: (db: DatabaseClient) => (params: {
2409
+ scopes: ProjectScopeConfig;
2410
+ }) => Promise<number>;
2411
+ /**
2412
+ * Upsert a credential reference (create if it doesn't exist, update if it does)
2413
+ */
2414
+ declare const upsertCredentialReference: (db: DatabaseClient) => (params: {
2415
+ data: CredentialReferenceInsert;
2416
+ }) => Promise<CredentialReferenceSelect>;
2417
+
2418
+ /**
2419
+ * Get a data component by ID
2420
+ */
2421
+ declare const getDataComponent: (db: DatabaseClient) => (params: {
2422
+ scopes: ProjectScopeConfig;
2423
+ dataComponentId: string;
2424
+ }) => Promise<DataComponentSelect | null>;
2425
+ /**
2426
+ * List all data components for a tenant/project
2427
+ */
2428
+ declare const listDataComponents: (db: DatabaseClient) => (params: {
2429
+ scopes: ProjectScopeConfig;
2430
+ }) => Promise<DataComponentSelect[]>;
2431
+ /**
2432
+ * List data components with pagination
2433
+ */
2434
+ declare const listDataComponentsPaginated: (db: DatabaseClient) => (params: {
2435
+ scopes: ProjectScopeConfig;
2436
+ pagination?: PaginationConfig;
2437
+ }) => Promise<{
2438
+ data: DataComponentSelect[];
2439
+ pagination: {
2440
+ page: number;
2441
+ limit: number;
2442
+ total: number;
2443
+ pages: number;
2444
+ };
2445
+ }>;
2446
+ /**
2447
+ * Create a new data component
2448
+ */
2449
+ declare const createDataComponent: (db: DatabaseClient) => (params: DataComponentInsert) => Promise<DataComponentSelect>;
2450
+ /**
2451
+ * Update a data component
2452
+ */
2453
+ declare const updateDataComponent: (db: DatabaseClient) => (params: {
2454
+ scopes: ProjectScopeConfig;
2455
+ dataComponentId: string;
2456
+ data: DataComponentUpdate;
2457
+ }) => Promise<DataComponentSelect | null>;
2458
+ /**
2459
+ * Delete a data component
2460
+ */
2461
+ declare const deleteDataComponent: (db: DatabaseClient) => (params: {
2462
+ scopes: ProjectScopeConfig;
2463
+ dataComponentId: string;
2464
+ }) => Promise<boolean>;
2465
+ /**
2466
+ * Get data components for a specific agent
2467
+ */
2468
+ declare const getDataComponentsForAgent: (db: DatabaseClient) => (params: {
2469
+ scopes: AgentScopeConfig;
2470
+ }) => Promise<DataComponentSelect[]>;
2471
+ /**
2472
+ * Associate a data component with an agent
2473
+ */
2474
+ declare const associateDataComponentWithAgent: (db: DatabaseClient) => (params: {
2475
+ scopes: AgentScopeConfig;
2476
+ dataComponentId: string;
2477
+ }) => Promise<{
2478
+ tenantId: string;
2479
+ projectId: string;
2480
+ id: string;
2481
+ graphId: string;
2482
+ createdAt: string;
2483
+ agentId: string;
2484
+ dataComponentId: string;
2485
+ }>;
2486
+ /**
2487
+ * Remove association between data component and agent
2488
+ */
2489
+ declare const removeDataComponentFromAgent: (db: DatabaseClient) => (params: {
2490
+ scopes: AgentScopeConfig;
2491
+ dataComponentId: string;
2492
+ }) => Promise<boolean>;
2493
+ declare const deleteAgentDataComponentRelationByAgent: (db: DatabaseClient) => (params: {
2494
+ scopes: AgentScopeConfig;
2495
+ }) => Promise<boolean>;
2496
+ /**
2497
+ * Get all agents that use a specific data component
2498
+ */
2499
+ declare const getAgentsUsingDataComponent: (db: DatabaseClient) => (params: {
2500
+ scopes: ProjectScopeConfig;
2501
+ dataComponentId: string;
2502
+ }) => Promise<{
2503
+ agentId: string;
2504
+ createdAt: string;
2505
+ }[]>;
2506
+ /**
2507
+ * Check if a data component is associated with an agent
2508
+ */
2509
+ declare const isDataComponentAssociatedWithAgent: (db: DatabaseClient) => (params: {
2510
+ scopes: AgentScopeConfig;
2511
+ dataComponentId: string;
2512
+ }) => Promise<boolean>;
2513
+ /**
2514
+ * Upsert agent-data component relation (create if it doesn't exist, no-op if it does)
2515
+ */
2516
+ declare const upsertAgentDataComponentRelation: (db: DatabaseClient) => (params: {
2517
+ scopes: AgentScopeConfig;
2518
+ dataComponentId: string;
2519
+ }) => Promise<{
2520
+ tenantId: string;
2521
+ projectId: string;
2522
+ id: string;
2523
+ graphId: string;
2524
+ createdAt: string;
2525
+ agentId: string;
2526
+ dataComponentId: string;
2527
+ } | null>;
2528
+ /**
2529
+ * Count data components for a tenant/project
2530
+ */
2531
+ declare const countDataComponents: (db: DatabaseClient) => (params: {
2532
+ scopes: ProjectScopeConfig;
2533
+ }) => Promise<number>;
2534
+ /**
2535
+ * Upsert a data component (create if it doesn't exist, update if it does)
2536
+ */
2537
+ declare const upsertDataComponent: (db: DatabaseClient) => (params: {
2538
+ data: DataComponentInsert;
2539
+ }) => Promise<DataComponentSelect | null>;
2540
+
2541
+ /**
2542
+ * Create a new external agent
2543
+ */
2544
+ declare const createExternalAgent: (db: DatabaseClient) => (params: ExternalAgentInsert) => Promise<ExternalAgentSelect>;
2545
+ /**
2546
+ * Get external agent by ID
2547
+ */
2548
+ declare const getExternalAgent: (db: DatabaseClient) => (params: {
2549
+ scopes: GraphScopeConfig;
2550
+ agentId: string;
2551
+ }) => Promise<ExternalAgentSelect | null>;
2552
+ /**
2553
+ * Get external agent by base URL
2554
+ */
2555
+ declare const getExternalAgentByUrl: (db: DatabaseClient) => (params: {
2556
+ scopes: GraphScopeConfig;
2557
+ baseUrl: string;
2558
+ }) => Promise<ExternalAgentSelect | null>;
2559
+ /**
2560
+ * List external agents for a tenant
2561
+ */
2562
+ declare const listExternalAgents: (db: DatabaseClient) => (params: {
2563
+ scopes: GraphScopeConfig;
2564
+ }) => Promise<ExternalAgentSelect[]>;
2565
+ /**
2566
+ * List external agents with pagination
2567
+ */
2568
+ declare const listExternalAgentsPaginated: (db: DatabaseClient) => (params: {
2569
+ scopes: GraphScopeConfig;
2570
+ pagination?: PaginationConfig;
2571
+ }) => Promise<{
2572
+ data: ExternalAgentSelect[];
2573
+ pagination: {
2574
+ page: number;
2575
+ limit: number;
2576
+ total: number;
2577
+ pages: number;
2578
+ };
2579
+ }>;
2580
+ /**
2581
+ * Update an existing external agent
2582
+ */
2583
+ declare const updateExternalAgent: (db: DatabaseClient) => (params: {
2584
+ scopes: GraphScopeConfig;
2585
+ agentId: string;
2586
+ data: Partial<ExternalAgentUpdate>;
2587
+ }) => Promise<ExternalAgentSelect | null>;
2588
+ /**
2589
+ * Upsert external agent (create if it doesn't exist, update if it does)
2590
+ */
2591
+ declare const upsertExternalAgent: (db: DatabaseClient) => (params: {
2592
+ data: ExternalAgentInsert;
2593
+ }) => Promise<ExternalAgentSelect>;
2594
+ /**
2595
+ * Delete an external agent
2596
+ */
2597
+ declare const deleteExternalAgent: (db: DatabaseClient) => (params: {
2598
+ scopes: GraphScopeConfig;
2599
+ agentId: string;
2600
+ }) => Promise<boolean>;
2601
+ /**
2602
+ * Check if an external agent exists
2603
+ */
2604
+ declare const externalAgentExists: (db: DatabaseClient) => (params: {
2605
+ scopes: GraphScopeConfig;
2606
+ agentId: string;
2607
+ }) => Promise<boolean>;
2608
+ /**
2609
+ * Check if an external agent exists by URL
2610
+ */
2611
+ declare const externalAgentUrlExists: (db: DatabaseClient) => (params: {
2612
+ scopes: GraphScopeConfig;
2613
+ baseUrl: string;
2614
+ }) => Promise<boolean>;
2615
+ /**
2616
+ * Count external agents for a tenant
2617
+ */
2618
+ declare const countExternalAgents: (db: DatabaseClient) => (params: {
2619
+ scopes: GraphScopeConfig;
2620
+ }) => Promise<number>;
2621
+
2622
+ interface GraphLogger {
2623
+ info(obj: Record<string, any>, msg?: string): void;
2624
+ error(obj: Record<string, any>, msg?: string): void;
2625
+ }
2626
+ /**
2627
+ * Server-side implementation of createFullGraph that performs actual database operations.
2628
+ * This function creates a complete graph with all agents, tools, and relationships.
2629
+ */
2630
+ declare const createFullGraphServerSide: (db: DatabaseClient, logger?: GraphLogger) => (scopes: ProjectScopeConfig, graphData: FullGraphDefinition) => Promise<FullGraphDefinition>;
2631
+ /**
2632
+ * Server-side implementation of updateFullGraph that performs actual database operations.
2633
+ * This function updates a complete graph with all agents, tools, and relationships.
2634
+ */
2635
+ declare const updateFullGraphServerSide: (db: DatabaseClient, logger?: GraphLogger) => (scopes: ProjectScopeConfig, graphData: FullGraphDefinition) => Promise<FullGraphDefinition>;
2636
+ /**
2637
+ * Get a complete graph definition by ID
2638
+ */
2639
+ declare const getFullGraph: (db: DatabaseClient, logger?: GraphLogger) => (params: {
2640
+ scopes: GraphScopeConfig;
2641
+ }) => Promise<FullGraphDefinition | null>;
2642
+ /**
2643
+ * Delete a complete graph and cascade to all related entities
2644
+ */
2645
+ declare const deleteFullGraph: (db: DatabaseClient, logger?: GraphLogger) => (params: {
2646
+ scopes: GraphScopeConfig;
2647
+ }) => Promise<boolean>;
2648
+
2649
+ /**
2650
+ * Save one or more artifacts to the ledger
2651
+ */
2652
+ declare const addLedgerArtifacts: (db: DatabaseClient) => (params: {
2653
+ scopes: ProjectScopeConfig;
2654
+ contextId: string;
2655
+ taskId?: string | null;
2656
+ artifacts: Artifact[];
2657
+ }) => Promise<void>;
2658
+ /**
2659
+ * Retrieve artifacts by taskId and/or artifactId.
2660
+ * At least one of taskId or artifactId must be provided.
2661
+ */
2662
+ declare const getLedgerArtifacts: (db: DatabaseClient) => (params: {
2663
+ scopes: ProjectScopeConfig;
2664
+ taskId?: string;
2665
+ artifactId?: string;
2666
+ }) => Promise<Artifact[]>;
2667
+ /**
2668
+ * Get ledger artifacts by context ID
2669
+ */
2670
+ declare const getLedgerArtifactsByContext: (db: DatabaseClient) => (params: {
2671
+ scopes: ProjectScopeConfig;
2672
+ contextId: string;
2673
+ }) => Promise<LedgerArtifactSelect[]>;
2674
+ /**
2675
+ * Delete ledger artifacts by task ID
2676
+ */
2677
+ declare const deleteLedgerArtifactsByTask: (db: DatabaseClient) => (params: {
2678
+ scopes: ProjectScopeConfig;
2679
+ taskId: string;
2680
+ }) => Promise<boolean>;
2681
+ /**
2682
+ * Delete ledger artifacts by context ID
2683
+ */
2684
+ declare const deleteLedgerArtifactsByContext: (db: DatabaseClient) => (params: {
2685
+ scopes: ProjectScopeConfig;
2686
+ contextId: string;
2687
+ }) => Promise<boolean>;
2688
+ /**
2689
+ * Count ledger artifacts by task ID
2690
+ */
2691
+ declare const countLedgerArtifactsByTask: (db: DatabaseClient) => (params: {
2692
+ scopes: ProjectScopeConfig;
2693
+ taskId: string;
2694
+ }) => Promise<number>;
2695
+
2696
+ declare const getMessageById: (db: DatabaseClient) => (params: {
2697
+ scopes: ProjectScopeConfig;
2698
+ messageId: string;
2699
+ }) => Promise<{
2700
+ tenantId: string;
2701
+ projectId: string;
2702
+ id: string;
2703
+ createdAt: string;
2704
+ updatedAt: string;
2705
+ metadata: MessageMetadata | null;
2706
+ role: string;
2707
+ content: MessageContent;
2708
+ conversationId: string;
2709
+ agentId: string | null;
2710
+ fromAgentId: string | null;
2711
+ toAgentId: string | null;
2712
+ fromExternalAgentId: string | null;
2713
+ toExternalAgentId: string | null;
2714
+ visibility: string;
2715
+ messageType: string;
2716
+ taskId: string | null;
2717
+ parentMessageId: string | null;
2718
+ a2aTaskId: string | null;
2719
+ a2aSessionId: string | null;
2720
+ } | undefined>;
2721
+ declare const listMessages: (db: DatabaseClient) => (params: {
2722
+ scopes: ProjectScopeConfig;
2723
+ pagination: PaginationConfig;
2724
+ }) => Promise<{
2725
+ tenantId: string;
2726
+ projectId: string;
2727
+ id: string;
2728
+ conversationId: string;
2729
+ role: string;
2730
+ fromAgentId: string | null;
2731
+ toAgentId: string | null;
2732
+ fromExternalAgentId: string | null;
2733
+ toExternalAgentId: string | null;
2734
+ content: MessageContent;
2735
+ visibility: string;
2736
+ messageType: string;
2737
+ agentId: string | null;
2738
+ taskId: string | null;
2739
+ parentMessageId: string | null;
2740
+ a2aTaskId: string | null;
2741
+ a2aSessionId: string | null;
2742
+ metadata: MessageMetadata | null;
2743
+ createdAt: string;
2744
+ updatedAt: string;
2745
+ }[]>;
2746
+ declare const getMessagesByConversation: (db: DatabaseClient) => (params: {
2747
+ scopes: ProjectScopeConfig;
2748
+ conversationId: string;
2749
+ pagination: PaginationConfig;
2750
+ }) => Promise<{
2751
+ tenantId: string;
2752
+ projectId: string;
2753
+ id: string;
2754
+ conversationId: string;
2755
+ role: string;
2756
+ fromAgentId: string | null;
2757
+ toAgentId: string | null;
2758
+ fromExternalAgentId: string | null;
2759
+ toExternalAgentId: string | null;
2760
+ content: MessageContent;
2761
+ visibility: string;
2762
+ messageType: string;
2763
+ agentId: string | null;
2764
+ taskId: string | null;
2765
+ parentMessageId: string | null;
2766
+ a2aTaskId: string | null;
2767
+ a2aSessionId: string | null;
2768
+ metadata: MessageMetadata | null;
2769
+ createdAt: string;
2770
+ updatedAt: string;
2771
+ }[]>;
2772
+ declare const getMessagesByTask: (db: DatabaseClient) => (params: {
2773
+ scopes: ProjectScopeConfig;
2774
+ taskId: string;
2775
+ pagination: PaginationConfig;
2776
+ }) => Promise<{
2777
+ tenantId: string;
2778
+ projectId: string;
2779
+ id: string;
2780
+ conversationId: string;
2781
+ role: string;
2782
+ fromAgentId: string | null;
2783
+ toAgentId: string | null;
2784
+ fromExternalAgentId: string | null;
2785
+ toExternalAgentId: string | null;
2786
+ content: MessageContent;
2787
+ visibility: string;
2788
+ messageType: string;
2789
+ agentId: string | null;
2790
+ taskId: string | null;
2791
+ parentMessageId: string | null;
2792
+ a2aTaskId: string | null;
2793
+ a2aSessionId: string | null;
2794
+ metadata: MessageMetadata | null;
2795
+ createdAt: string;
2796
+ updatedAt: string;
2797
+ }[]>;
2798
+ declare const getVisibleMessages: (db: DatabaseClient) => (params: {
2799
+ scopes: ProjectScopeConfig;
2800
+ conversationId: string;
2801
+ visibility?: MessageVisibility[];
2802
+ pagination: PaginationConfig;
2803
+ }) => Promise<{
2804
+ tenantId: string;
2805
+ projectId: string;
2806
+ id: string;
2807
+ conversationId: string;
2808
+ role: string;
2809
+ fromAgentId: string | null;
2810
+ toAgentId: string | null;
2811
+ fromExternalAgentId: string | null;
2812
+ toExternalAgentId: string | null;
2813
+ content: MessageContent;
2814
+ visibility: string;
2815
+ messageType: string;
2816
+ agentId: string | null;
2817
+ taskId: string | null;
2818
+ parentMessageId: string | null;
2819
+ a2aTaskId: string | null;
2820
+ a2aSessionId: string | null;
2821
+ metadata: MessageMetadata | null;
2822
+ createdAt: string;
2823
+ updatedAt: string;
2824
+ }[]>;
2825
+ declare const createMessage: (db: DatabaseClient) => (params: MessageInsert) => Promise<{
2826
+ tenantId: string;
2827
+ projectId: string;
2828
+ id: string;
2829
+ createdAt: string;
2830
+ updatedAt: string;
2831
+ metadata: MessageMetadata | null;
2832
+ role: string;
2833
+ content: MessageContent;
2834
+ conversationId: string;
2835
+ agentId: string | null;
2836
+ fromAgentId: string | null;
2837
+ toAgentId: string | null;
2838
+ fromExternalAgentId: string | null;
2839
+ toExternalAgentId: string | null;
2840
+ visibility: string;
2841
+ messageType: string;
2842
+ taskId: string | null;
2843
+ parentMessageId: string | null;
2844
+ a2aTaskId: string | null;
2845
+ a2aSessionId: string | null;
2846
+ }>;
2847
+ declare const updateMessage: (db: DatabaseClient) => (params: {
2848
+ scopes: ProjectScopeConfig;
2849
+ messageId: string;
2850
+ data: MessageUpdate;
2851
+ }) => Promise<{
2852
+ tenantId: string;
2853
+ projectId: string;
2854
+ id: string;
2855
+ createdAt: string;
2856
+ updatedAt: string;
2857
+ metadata: MessageMetadata | null;
2858
+ role: string;
2859
+ content: MessageContent;
2860
+ conversationId: string;
2861
+ agentId: string | null;
2862
+ fromAgentId: string | null;
2863
+ toAgentId: string | null;
2864
+ fromExternalAgentId: string | null;
2865
+ toExternalAgentId: string | null;
2866
+ visibility: string;
2867
+ messageType: string;
2868
+ taskId: string | null;
2869
+ parentMessageId: string | null;
2870
+ a2aTaskId: string | null;
2871
+ a2aSessionId: string | null;
2872
+ }>;
2873
+ declare const deleteMessage: (db: DatabaseClient) => (params: {
2874
+ scopes: ProjectScopeConfig;
2875
+ messageId: string;
2876
+ }) => Promise<{
2877
+ tenantId: string;
2878
+ projectId: string;
2879
+ id: string;
2880
+ createdAt: string;
2881
+ updatedAt: string;
2882
+ metadata: MessageMetadata | null;
2883
+ role: string;
2884
+ content: MessageContent;
2885
+ conversationId: string;
2886
+ agentId: string | null;
2887
+ fromAgentId: string | null;
2888
+ toAgentId: string | null;
2889
+ fromExternalAgentId: string | null;
2890
+ toExternalAgentId: string | null;
2891
+ visibility: string;
2892
+ messageType: string;
2893
+ taskId: string | null;
2894
+ parentMessageId: string | null;
2895
+ a2aTaskId: string | null;
2896
+ a2aSessionId: string | null;
2897
+ }>;
2898
+ declare const countMessagesByConversation: (db: DatabaseClient) => (params: {
2899
+ scopes: ProjectScopeConfig;
2900
+ conversationId: string;
2901
+ }) => Promise<number>;
2902
+
2903
+ /**
2904
+ * Server-side data access layer for Full Project operations.
2905
+ * This module provides functions for creating, retrieving, updating, and deleting
2906
+ * complete project definitions with all nested resources (graphs, agents, tools, etc.).
2907
+ */
2908
+
2909
+ type ProjectLogger = ReturnType<typeof getLogger>;
2910
+ /**
2911
+ * Server-side implementation of createFullProject that performs actual database operations.
2912
+ * This function creates a complete project with all graphs and their nested resources.
2913
+ */
2914
+ declare const createFullProjectServerSide: (db: DatabaseClient, logger?: ProjectLogger) => (scopes: ProjectScopeConfig, projectData: FullProjectDefinition) => Promise<FullProjectDefinition>;
2915
+ /**
2916
+ * Server-side implementation of updateFullProject that performs actual database operations.
2917
+ * This function updates a complete project with all graphs and their nested resources.
2918
+ */
2919
+ declare const updateFullProjectServerSide: (db: DatabaseClient, logger?: ProjectLogger) => (scopes: ProjectScopeConfig, projectData: FullProjectDefinition) => Promise<FullProjectDefinition>;
2920
+ /**
2921
+ * Get a complete project definition with all nested resources
2922
+ */
2923
+ declare const getFullProject: (db: DatabaseClient, logger?: ProjectLogger) => (params: {
2924
+ scopes: ProjectScopeConfig;
2925
+ }) => Promise<FullProjectDefinition | null>;
2926
+ /**
2927
+ * Delete a complete project and cascade to all related entities
2928
+ */
2929
+ declare const deleteFullProject: (db: DatabaseClient, logger?: ProjectLogger) => (params: {
2930
+ scopes: ProjectScopeConfig;
2931
+ }) => Promise<boolean>;
2932
+
2933
+ /**
2934
+ * List all unique project IDs within a tenant by scanning all resource tables
2935
+ */
2936
+ declare const listProjects: (db: DatabaseClient) => (params: {
2937
+ tenantId: string;
2938
+ }) => Promise<ProjectInfo[]>;
2939
+ /**
2940
+ * List all unique project IDs within a tenant with pagination
2941
+ */
2942
+ declare const listProjectsPaginated: (db: DatabaseClient) => (params: {
2943
+ tenantId: string;
2944
+ pagination?: PaginationConfig;
2945
+ }) => Promise<{
2946
+ data: ProjectSelect[];
2947
+ pagination: PaginationResult;
2948
+ }>;
2949
+ /**
2950
+ * Get resource counts for a specific project
2951
+ */
2952
+ declare const getProjectResourceCounts: (db: DatabaseClient) => (params: ProjectScopeConfig) => Promise<ProjectResourceCounts>;
2953
+ /**
2954
+ * Check if a project exists (has any resources)
2955
+ */
2956
+ declare const projectExists: (db: DatabaseClient) => (params: ProjectScopeConfig) => Promise<boolean>;
2957
+ /**
2958
+ * Count total projects for a tenant
2959
+ */
2960
+ declare const countProjects: (db: DatabaseClient) => (params: {
2961
+ tenantId: string;
2962
+ }) => Promise<number>;
2963
+ /**
2964
+ * Get a single project by ID
2965
+ */
2966
+ declare const getProject: (db: DatabaseClient) => (params: {
2967
+ scopes: ProjectScopeConfig;
2968
+ }) => Promise<ProjectSelect | null>;
2969
+ /**
2970
+ * Create a new project
2971
+ */
2972
+ declare const createProject: (db: DatabaseClient) => (params: ProjectInsert) => Promise<ProjectSelect>;
2973
+ /**
2974
+ * Update an existing project
2975
+ */
2976
+ declare const updateProject: (db: DatabaseClient) => (params: {
2977
+ scopes: ProjectScopeConfig;
2978
+ data: ProjectUpdate;
2979
+ }) => Promise<ProjectSelect | null>;
2980
+ /**
2981
+ * Check if a project exists in the projects table
2982
+ */
2983
+ declare const projectExistsInTable: (db: DatabaseClient) => (params: {
2984
+ scopes: ProjectScopeConfig;
2985
+ }) => Promise<boolean>;
2986
+ /**
2987
+ * Check if a project has any resources (used before deletion)
2988
+ */
2989
+ declare const projectHasResources: (db: DatabaseClient) => (params: ProjectScopeConfig) => Promise<boolean>;
2990
+ /**
2991
+ * Delete a project (with validation for existing resources)
2992
+ */
2993
+ declare const deleteProject: (db: DatabaseClient) => (params: {
2994
+ scopes: ProjectScopeConfig;
2995
+ }) => Promise<boolean>;
2996
+
2997
+ declare const createTask: (db: DatabaseClient) => (params: TaskInsert) => Promise<{
2998
+ tenantId: string;
2999
+ projectId: string;
3000
+ id: string;
3001
+ createdAt: string;
3002
+ updatedAt: string;
3003
+ metadata: TaskMetadataConfig | null;
3004
+ status: string;
3005
+ contextId: string;
3006
+ agentId: string;
3007
+ }>;
3008
+ declare const getTask: (db: DatabaseClient) => (params: {
3009
+ id: string;
3010
+ }) => Promise<TaskSelect | null>;
3011
+ declare const updateTask: (db: DatabaseClient) => (params: {
3012
+ taskId: string;
3013
+ data: {
3014
+ status?: string;
3015
+ metadata?: any;
3016
+ };
3017
+ }) => Promise<{
3018
+ tenantId: string;
3019
+ projectId: string;
3020
+ id: string;
3021
+ createdAt: string;
3022
+ updatedAt: string;
3023
+ metadata: TaskMetadataConfig | null;
3024
+ status: string;
3025
+ contextId: string;
3026
+ agentId: string;
3027
+ }>;
3028
+ declare const listTaskIdsByContextId: (db: DatabaseClient) => (params: {
3029
+ contextId: string;
3030
+ }) => Promise<string[]>;
3031
+
3032
+ declare const dbResultToMcpTool: (dbResult: ToolSelect) => McpTool;
3033
+ declare const getToolById: (db: DatabaseClient) => (params: {
3034
+ scopes: ProjectScopeConfig;
3035
+ toolId: string;
3036
+ }) => Promise<{
3037
+ tenantId: string;
3038
+ projectId: string;
3039
+ id: string;
3040
+ name: string;
3041
+ config: {
3042
+ type: "mcp";
3043
+ mcp: ToolMcpConfig;
3044
+ };
3045
+ credentialReferenceId: string | null;
3046
+ createdAt: string;
3047
+ updatedAt: string;
3048
+ headers: Record<string, string> | null;
3049
+ status: string;
3050
+ capabilities: ToolServerCapabilities | null;
3051
+ imageUrl: string | null;
3052
+ lastHealthCheck: string | null;
3053
+ lastError: string | null;
3054
+ availableTools: McpToolDefinition[] | null;
3055
+ lastToolsSync: string | null;
3056
+ } | null>;
3057
+ declare const listTools: (db: DatabaseClient) => (params: {
3058
+ scopes: ProjectScopeConfig;
3059
+ pagination?: PaginationConfig;
3060
+ }) => Promise<{
3061
+ data: {
3062
+ tenantId: string;
3063
+ projectId: string;
3064
+ id: string;
3065
+ name: string;
3066
+ config: {
3067
+ type: "mcp";
3068
+ mcp: ToolMcpConfig;
3069
+ };
3070
+ credentialReferenceId: string | null;
3071
+ headers: Record<string, string> | null;
3072
+ imageUrl: string | null;
3073
+ capabilities: ToolServerCapabilities | null;
3074
+ status: string;
3075
+ lastHealthCheck: string | null;
3076
+ lastError: string | null;
3077
+ availableTools: McpToolDefinition[] | null;
3078
+ lastToolsSync: string | null;
3079
+ createdAt: string;
3080
+ updatedAt: string;
3081
+ }[];
3082
+ pagination: {
3083
+ page: number;
3084
+ limit: number;
3085
+ total: number;
3086
+ pages: number;
3087
+ };
3088
+ }>;
3089
+ declare const getToolsByStatus: (db: DatabaseClient) => (params: {
3090
+ scopes: ProjectScopeConfig;
3091
+ status: string;
3092
+ }) => Promise<{
3093
+ tenantId: string;
3094
+ projectId: string;
3095
+ id: string;
3096
+ name: string;
3097
+ config: {
3098
+ type: "mcp";
3099
+ mcp: ToolMcpConfig;
3100
+ };
3101
+ credentialReferenceId: string | null;
3102
+ headers: Record<string, string> | null;
3103
+ imageUrl: string | null;
3104
+ capabilities: ToolServerCapabilities | null;
3105
+ status: string;
3106
+ lastHealthCheck: string | null;
3107
+ lastError: string | null;
3108
+ availableTools: McpToolDefinition[] | null;
3109
+ lastToolsSync: string | null;
3110
+ createdAt: string;
3111
+ updatedAt: string;
3112
+ }[]>;
3113
+ declare const listToolsByStatus: (db: DatabaseClient) => (params: {
3114
+ scopes: ProjectScopeConfig;
3115
+ status: McpToolStatus;
3116
+ }) => Promise<{
3117
+ tenantId: string;
3118
+ projectId: string;
3119
+ id: string;
3120
+ name: string;
3121
+ config: {
3122
+ type: "mcp";
3123
+ mcp: ToolMcpConfig;
3124
+ };
3125
+ credentialReferenceId: string | null;
3126
+ createdAt: string;
3127
+ updatedAt: string;
3128
+ headers: Record<string, string> | null;
3129
+ status: string;
3130
+ capabilities: ToolServerCapabilities | null;
3131
+ imageUrl: string | null;
3132
+ lastHealthCheck: string | null;
3133
+ lastError: string | null;
3134
+ availableTools: McpToolDefinition[] | null;
3135
+ lastToolsSync: string | null;
3136
+ }[]>;
3137
+ declare const createTool: (db: DatabaseClient) => (params: ToolInsert) => Promise<{
3138
+ tenantId: string;
3139
+ projectId: string;
3140
+ id: string;
3141
+ name: string;
3142
+ config: {
3143
+ type: "mcp";
3144
+ mcp: ToolMcpConfig;
3145
+ };
3146
+ credentialReferenceId: string | null;
3147
+ createdAt: string;
3148
+ updatedAt: string;
3149
+ headers: Record<string, string> | null;
3150
+ status: string;
3151
+ capabilities: ToolServerCapabilities | null;
3152
+ imageUrl: string | null;
3153
+ lastHealthCheck: string | null;
3154
+ lastError: string | null;
3155
+ availableTools: McpToolDefinition[] | null;
3156
+ lastToolsSync: string | null;
3157
+ }>;
3158
+ declare const updateTool: (db: DatabaseClient) => (params: {
3159
+ scopes: ProjectScopeConfig;
3160
+ toolId: string;
3161
+ data: ToolUpdate;
3162
+ }) => Promise<{
3163
+ tenantId: string;
3164
+ projectId: string;
3165
+ id: string;
3166
+ name: string;
3167
+ config: {
3168
+ type: "mcp";
3169
+ mcp: ToolMcpConfig;
3170
+ };
3171
+ credentialReferenceId: string | null;
3172
+ createdAt: string;
3173
+ updatedAt: string;
3174
+ headers: Record<string, string> | null;
3175
+ status: string;
3176
+ capabilities: ToolServerCapabilities | null;
3177
+ imageUrl: string | null;
3178
+ lastHealthCheck: string | null;
3179
+ lastError: string | null;
3180
+ availableTools: McpToolDefinition[] | null;
3181
+ lastToolsSync: string | null;
3182
+ }>;
3183
+ declare const deleteTool: (db: DatabaseClient) => (params: {
3184
+ scopes: ProjectScopeConfig;
3185
+ toolId: string;
3186
+ }) => Promise<boolean>;
3187
+ declare const addToolToAgent: (db: DatabaseClient) => (params: {
3188
+ scopes: GraphScopeConfig;
3189
+ agentId: string;
3190
+ toolId: string;
3191
+ selectedTools?: string[] | null;
3192
+ }) => Promise<{
3193
+ tenantId: string;
3194
+ projectId: string;
3195
+ id: string;
3196
+ graphId: string;
3197
+ createdAt: string;
3198
+ updatedAt: string;
3199
+ toolId: string;
3200
+ selectedTools: string[] | null;
3201
+ agentId: string;
3202
+ }>;
3203
+ declare const removeToolFromAgent: (db: DatabaseClient) => (params: {
3204
+ scopes: GraphScopeConfig;
3205
+ agentId: string;
3206
+ toolId: string;
3207
+ }) => Promise<{
3208
+ tenantId: string;
3209
+ projectId: string;
3210
+ id: string;
3211
+ graphId: string;
3212
+ createdAt: string;
3213
+ updatedAt: string;
3214
+ toolId: string;
3215
+ selectedTools: string[] | null;
3216
+ agentId: string;
3217
+ }>;
3218
+ /**
3219
+ * Upsert agent-tool relation (create if it doesn't exist, update if it does)
3220
+ */
3221
+ declare const upsertAgentToolRelation: (db: DatabaseClient) => (params: {
3222
+ scopes: GraphScopeConfig;
3223
+ agentId: string;
3224
+ toolId: string;
3225
+ selectedTools?: string[] | null;
3226
+ }) => Promise<{
3227
+ tenantId: string;
3228
+ projectId: string;
3229
+ id: string;
3230
+ graphId: string;
3231
+ createdAt: string;
3232
+ updatedAt: string;
3233
+ toolId: string;
3234
+ selectedTools: string[] | null;
3235
+ agentId: string;
3236
+ }>;
3237
+ declare const updateToolStatus: (db: DatabaseClient) => (params: {
3238
+ scopes: ProjectScopeConfig;
3239
+ toolId: string;
3240
+ status: string;
3241
+ lastHealthCheck?: string;
3242
+ lastError?: string;
3243
+ }) => Promise<{
3244
+ tenantId: string;
3245
+ projectId: string;
3246
+ id: string;
3247
+ name: string;
3248
+ config: {
3249
+ type: "mcp";
3250
+ mcp: ToolMcpConfig;
3251
+ };
3252
+ credentialReferenceId: string | null;
3253
+ createdAt: string;
3254
+ updatedAt: string;
3255
+ headers: Record<string, string> | null;
3256
+ status: string;
3257
+ capabilities: ToolServerCapabilities | null;
3258
+ imageUrl: string | null;
3259
+ lastHealthCheck: string | null;
3260
+ lastError: string | null;
3261
+ availableTools: McpToolDefinition[] | null;
3262
+ lastToolsSync: string | null;
3263
+ }>;
3264
+ /**
3265
+ * Upsert a tool (create if it doesn't exist, update if it does)
3266
+ */
3267
+ declare const upsertTool: (db: DatabaseClient) => (params: {
3268
+ data: ToolInsert;
3269
+ }) => Promise<{
3270
+ tenantId: string;
3271
+ projectId: string;
3272
+ id: string;
3273
+ name: string;
3274
+ config: {
3275
+ type: "mcp";
3276
+ mcp: ToolMcpConfig;
3277
+ };
3278
+ credentialReferenceId: string | null;
3279
+ createdAt: string;
3280
+ updatedAt: string;
3281
+ headers: Record<string, string> | null;
3282
+ status: string;
3283
+ capabilities: ToolServerCapabilities | null;
3284
+ imageUrl: string | null;
3285
+ lastHealthCheck: string | null;
3286
+ lastError: string | null;
3287
+ availableTools: McpToolDefinition[] | null;
3288
+ lastToolsSync: string | null;
3289
+ }>;
3290
+ declare const getHealthyToolsForAgent: (db: DatabaseClient) => (params: {
3291
+ scopes: AgentScopeConfig;
3292
+ }) => Promise<{
3293
+ tenantId: string;
3294
+ projectId: string;
3295
+ id: string;
3296
+ name: string;
3297
+ config: {
3298
+ type: "mcp";
3299
+ mcp: ToolMcpConfig;
3300
+ };
3301
+ credentialReferenceId: string | null;
3302
+ headers: Record<string, string> | null;
3303
+ imageUrl: string | null;
3304
+ capabilities: ToolServerCapabilities | null;
3305
+ status: string;
3306
+ lastHealthCheck: string | null;
3307
+ lastError: string | null;
3308
+ availableTools: McpToolDefinition[] | null;
3309
+ lastToolsSync: string | null;
3310
+ createdAt: string;
3311
+ updatedAt: string;
3312
+ }[]>;
3313
+
3314
+ /**
3315
+ * Validates that a project exists before performing database operations
3316
+ * This provides runtime validation even when foreign key constraints are not enforced
3317
+ */
3318
+ declare const validateProjectExists: (db: DatabaseClient, tenantId: string, projectId: string) => Promise<void>;
3319
+ /**
3320
+ * Wraps a database operation with project validation
3321
+ * Ensures the project exists before executing the operation
3322
+ */
3323
+ declare const withProjectValidation: <T extends (...args: any[]) => Promise<any>>(db: DatabaseClient, operation: T) => (params: Parameters<T>[0]) => Promise<ReturnType<T>>;
3324
+ /**
3325
+ * Creates a validated version of data access functions
3326
+ * Automatically adds project validation to insert/update operations
3327
+ */
3328
+ declare const createValidatedDataAccess: <T extends Record<string, any>>(db: DatabaseClient, dataAccessFunctions: T) => T;
3329
+
3330
+ declare const loadEnvironmentFiles: () => void;
3331
+
3332
+ declare const HTTP_REQUEST_PARTS: readonly ["headers"];
3333
+ type HttpRequestPart = (typeof HTTP_REQUEST_PARTS)[number];
3334
+ interface ContextValidationError {
3335
+ field: string;
3336
+ message: string;
3337
+ value?: unknown;
3338
+ }
3339
+ interface ContextValidationResult {
3340
+ valid: boolean;
3341
+ errors: ContextValidationError[];
3342
+ validatedContext?: Record<string, unknown> | ParsedHttpRequest;
3343
+ }
3344
+ interface ParsedHttpRequest {
3345
+ headers?: Record<string, string>;
3346
+ }
3347
+ declare function isValidHttpRequest(obj: any): obj is ParsedHttpRequest;
3348
+ declare function getCachedValidator(schema: Record<string, unknown>): ValidateFunction;
3349
+ declare function validationHelper(jsonSchema: Record<string, unknown>): ValidateFunction<unknown>;
3350
+ declare function validateAgainstJsonSchema(jsonSchema: Record<string, unknown>, context: unknown): boolean;
3351
+ /**
3352
+ * Validates HTTP request headers against schema
3353
+ */
3354
+ declare function validateHttpRequestHeaders(headersSchema: any, httpRequest: ParsedHttpRequest): Promise<ContextValidationResult>;
3355
+ /**
3356
+ * Validates request context against the JSON Schema stored in context configuration
3357
+ * Supports both legacy simple schemas and new comprehensive HTTP request schemas
3358
+ */
3359
+ declare function validateRequestContext({ tenantId, projectId, graphId, conversationId, parsedRequest, dbClient, credentialStores, }: {
3360
+ tenantId: string;
3361
+ projectId: string;
3362
+ graphId: string;
3363
+ conversationId: string;
3364
+ parsedRequest: ParsedHttpRequest;
3365
+ dbClient: DatabaseClient;
3366
+ credentialStores?: CredentialStoreRegistry;
3367
+ }): Promise<ContextValidationResult>;
3368
+ /**
3369
+ * Hono middleware for context validation
3370
+ */
3371
+ declare function contextValidationMiddleware(dbClient: DatabaseClient): (c: Context, next: Next) => Promise<void>;
3372
+
3373
+ type ApiKeyGenerationResult = {
3374
+ id: string;
3375
+ publicId: string;
3376
+ key: string;
3377
+ keyHash: string;
3378
+ keyPrefix: string;
3379
+ };
3380
+ /**
3381
+ * Generate a new API key with secure random bytes
3382
+ */
3383
+ declare function generateApiKey(): Promise<ApiKeyGenerationResult>;
3384
+ /**
3385
+ * Hash an API key using scrypt
3386
+ */
3387
+ declare function hashApiKey(key: string): Promise<string>;
3388
+ /**
3389
+ * Validate an API key against its hash
3390
+ */
3391
+ declare function validateApiKey(key: string, storedHash: string): Promise<boolean>;
3392
+ /**
3393
+ * Check if an API key has expired
3394
+ */
3395
+ declare function isApiKeyExpired(expiresAt?: string | null): boolean;
3396
+ /**
3397
+ * Extract the publicId from an API key
3398
+ */
3399
+ declare function extractPublicId(key: string): string | null;
3400
+ /**
3401
+ * Mask an API key for display (show only prefix and last 4 chars)
3402
+ */
3403
+ declare function maskApiKey(keyPrefix: string): string;
3404
+
3405
+ /**
3406
+ * Centralized authentication detection utilities for MCP tools
3407
+ */
3408
+
3409
+ /**
3410
+ * OAuth configuration interface
3411
+ */
3412
+ interface OAuthConfig {
3413
+ authorizationUrl: string;
3414
+ tokenUrl: string;
3415
+ registrationUrl?: string;
3416
+ supportsDynamicRegistration: boolean;
3417
+ }
3418
+ /**
3419
+ * Full OAuth endpoint discovery with complete configuration
3420
+ */
3421
+ declare const discoverOAuthEndpoints: (serverUrl: string, logger?: PinoLogger) => Promise<OAuthConfig | null>;
3422
+ /**
3423
+ * Detect if OAuth 2.1/PKCE authentication is specifically required for a tool
3424
+ */
3425
+ declare const detectAuthenticationRequired: (tool: McpTool, error: Error, logger?: PinoLogger) => Promise<boolean>;
3426
+
3427
+ /**
3428
+ * Get a lookup key for a credential store from retrieval params
3429
+ * @param retrievalParams - The retrieval params for the credential store
3430
+ * @param credentialStoreType - The type of credential store
3431
+ * @returns A lookup key for the credential store, used to call <CredentialStore>.get()
3432
+ */
3433
+ declare function getCredentialStoreLookupKeyFromRetrievalParams({ retrievalParams, credentialStoreType, }: {
3434
+ retrievalParams: Record<string, unknown>;
3435
+ credentialStoreType: keyof typeof CredentialStoreType;
3436
+ }): string | null;
3437
+
3438
+ declare const ErrorCode: z$1.ZodEnum<{
3439
+ unauthorized: "unauthorized";
3440
+ bad_request: "bad_request";
3441
+ forbidden: "forbidden";
3442
+ not_found: "not_found";
3443
+ conflict: "conflict";
3444
+ internal_server_error: "internal_server_error";
3445
+ unprocessable_entity: "unprocessable_entity";
3446
+ }>;
3447
+ declare const ERROR_DOCS_BASE_URL = "https://docs.inkeep.com/agents-api/errors";
3448
+ declare const problemDetailsSchema: z$1.ZodObject<{
3449
+ title: z$1.ZodString;
3450
+ status: z$1.ZodNumber;
3451
+ detail: z$1.ZodString;
3452
+ instance: z$1.ZodOptional<z$1.ZodString>;
3453
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3454
+ code: z$1.ZodEnum<{
3455
+ unauthorized: "unauthorized";
3456
+ bad_request: "bad_request";
3457
+ forbidden: "forbidden";
3458
+ not_found: "not_found";
3459
+ conflict: "conflict";
3460
+ internal_server_error: "internal_server_error";
3461
+ unprocessable_entity: "unprocessable_entity";
3462
+ }>;
3463
+ }, z$1.core.$strip>;
3464
+ type ProblemDetails = z$1.infer<typeof problemDetailsSchema>;
3465
+ type ErrorCodes = z$1.infer<typeof ErrorCode>;
3466
+ declare const errorResponseSchema: z$1.ZodObject<{
3467
+ error: z$1.ZodObject<{
3468
+ code: z$1.ZodEnum<{
3469
+ unauthorized: "unauthorized";
3470
+ bad_request: "bad_request";
3471
+ forbidden: "forbidden";
3472
+ not_found: "not_found";
3473
+ conflict: "conflict";
3474
+ internal_server_error: "internal_server_error";
3475
+ unprocessable_entity: "unprocessable_entity";
3476
+ }>;
3477
+ message: z$1.ZodString;
3478
+ }, z$1.core.$strip>;
3479
+ }, z$1.core.$strip>;
3480
+ type ErrorResponse = z$1.infer<typeof errorResponseSchema>;
3481
+ declare function createApiError({ code, message, instance, requestId, }: {
3482
+ code: ErrorCodes;
3483
+ message: string;
3484
+ instance?: string;
3485
+ requestId?: string;
3486
+ }): HTTPException;
3487
+ declare function handleApiError(error: unknown, requestId?: string): Promise<ProblemDetails & {
3488
+ error: {
3489
+ code: ErrorCodes;
3490
+ message: string;
3491
+ };
3492
+ }>;
3493
+ declare const errorSchemaFactory: (code: ErrorCodes, description: string) => {
3494
+ description: string;
3495
+ content: {
3496
+ 'application/problem+json': {
3497
+ schema: z$1.ZodObject<{
3498
+ instance: z$1.ZodOptional<z$1.ZodString>;
3499
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3500
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3501
+ detail: z$1.ZodString;
3502
+ title: z$1.ZodString;
3503
+ status: z$1.ZodLiteral<number>;
3504
+ error: z$1.ZodObject<{
3505
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3506
+ message: z$1.ZodString;
3507
+ }, z$1.core.$strip>;
3508
+ }, z$1.core.$strip>;
3509
+ };
3510
+ };
3511
+ };
3512
+ declare const commonCreateErrorResponses: {
3513
+ readonly 400: {
3514
+ description: string;
3515
+ content: {
3516
+ 'application/problem+json': {
3517
+ schema: z$1.ZodObject<{
3518
+ instance: z$1.ZodOptional<z$1.ZodString>;
3519
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3520
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3521
+ detail: z$1.ZodString;
3522
+ title: z$1.ZodString;
3523
+ status: z$1.ZodLiteral<number>;
3524
+ error: z$1.ZodObject<{
3525
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3526
+ message: z$1.ZodString;
3527
+ }, z$1.core.$strip>;
3528
+ }, z$1.core.$strip>;
3529
+ };
3530
+ };
3531
+ };
3532
+ readonly 401: {
3533
+ description: string;
3534
+ content: {
3535
+ 'application/problem+json': {
3536
+ schema: z$1.ZodObject<{
3537
+ instance: z$1.ZodOptional<z$1.ZodString>;
3538
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3539
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3540
+ detail: z$1.ZodString;
3541
+ title: z$1.ZodString;
3542
+ status: z$1.ZodLiteral<number>;
3543
+ error: z$1.ZodObject<{
3544
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3545
+ message: z$1.ZodString;
3546
+ }, z$1.core.$strip>;
3547
+ }, z$1.core.$strip>;
3548
+ };
3549
+ };
3550
+ };
3551
+ readonly 403: {
3552
+ description: string;
3553
+ content: {
3554
+ 'application/problem+json': {
3555
+ schema: z$1.ZodObject<{
3556
+ instance: z$1.ZodOptional<z$1.ZodString>;
3557
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3558
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3559
+ detail: z$1.ZodString;
3560
+ title: z$1.ZodString;
3561
+ status: z$1.ZodLiteral<number>;
3562
+ error: z$1.ZodObject<{
3563
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3564
+ message: z$1.ZodString;
3565
+ }, z$1.core.$strip>;
3566
+ }, z$1.core.$strip>;
3567
+ };
3568
+ };
3569
+ };
3570
+ readonly 422: {
3571
+ description: string;
3572
+ content: {
3573
+ 'application/problem+json': {
3574
+ schema: z$1.ZodObject<{
3575
+ instance: z$1.ZodOptional<z$1.ZodString>;
3576
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3577
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3578
+ detail: z$1.ZodString;
3579
+ title: z$1.ZodString;
3580
+ status: z$1.ZodLiteral<number>;
3581
+ error: z$1.ZodObject<{
3582
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3583
+ message: z$1.ZodString;
3584
+ }, z$1.core.$strip>;
3585
+ }, z$1.core.$strip>;
3586
+ };
3587
+ };
3588
+ };
3589
+ readonly 500: {
3590
+ description: string;
3591
+ content: {
3592
+ 'application/problem+json': {
3593
+ schema: z$1.ZodObject<{
3594
+ instance: z$1.ZodOptional<z$1.ZodString>;
3595
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3596
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3597
+ detail: z$1.ZodString;
3598
+ title: z$1.ZodString;
3599
+ status: z$1.ZodLiteral<number>;
3600
+ error: z$1.ZodObject<{
3601
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3602
+ message: z$1.ZodString;
3603
+ }, z$1.core.$strip>;
3604
+ }, z$1.core.$strip>;
3605
+ };
3606
+ };
3607
+ };
3608
+ };
3609
+ declare const commonUpdateErrorResponses: {
3610
+ readonly 400: {
3611
+ description: string;
3612
+ content: {
3613
+ 'application/problem+json': {
3614
+ schema: z$1.ZodObject<{
3615
+ instance: z$1.ZodOptional<z$1.ZodString>;
3616
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3617
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3618
+ detail: z$1.ZodString;
3619
+ title: z$1.ZodString;
3620
+ status: z$1.ZodLiteral<number>;
3621
+ error: z$1.ZodObject<{
3622
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3623
+ message: z$1.ZodString;
3624
+ }, z$1.core.$strip>;
3625
+ }, z$1.core.$strip>;
3626
+ };
3627
+ };
3628
+ };
3629
+ readonly 401: {
3630
+ description: string;
3631
+ content: {
3632
+ 'application/problem+json': {
3633
+ schema: z$1.ZodObject<{
3634
+ instance: z$1.ZodOptional<z$1.ZodString>;
3635
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3636
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3637
+ detail: z$1.ZodString;
3638
+ title: z$1.ZodString;
3639
+ status: z$1.ZodLiteral<number>;
3640
+ error: z$1.ZodObject<{
3641
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3642
+ message: z$1.ZodString;
3643
+ }, z$1.core.$strip>;
3644
+ }, z$1.core.$strip>;
3645
+ };
3646
+ };
3647
+ };
3648
+ readonly 403: {
3649
+ description: string;
3650
+ content: {
3651
+ 'application/problem+json': {
3652
+ schema: z$1.ZodObject<{
3653
+ instance: z$1.ZodOptional<z$1.ZodString>;
3654
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3655
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3656
+ detail: z$1.ZodString;
3657
+ title: z$1.ZodString;
3658
+ status: z$1.ZodLiteral<number>;
3659
+ error: z$1.ZodObject<{
3660
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3661
+ message: z$1.ZodString;
3662
+ }, z$1.core.$strip>;
3663
+ }, z$1.core.$strip>;
3664
+ };
3665
+ };
3666
+ };
3667
+ readonly 404: {
3668
+ description: string;
3669
+ content: {
3670
+ 'application/problem+json': {
3671
+ schema: z$1.ZodObject<{
3672
+ instance: z$1.ZodOptional<z$1.ZodString>;
3673
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3674
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3675
+ detail: z$1.ZodString;
3676
+ title: z$1.ZodString;
3677
+ status: z$1.ZodLiteral<number>;
3678
+ error: z$1.ZodObject<{
3679
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3680
+ message: z$1.ZodString;
3681
+ }, z$1.core.$strip>;
3682
+ }, z$1.core.$strip>;
3683
+ };
3684
+ };
3685
+ };
3686
+ readonly 422: {
3687
+ description: string;
3688
+ content: {
3689
+ 'application/problem+json': {
3690
+ schema: z$1.ZodObject<{
3691
+ instance: z$1.ZodOptional<z$1.ZodString>;
3692
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3693
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3694
+ detail: z$1.ZodString;
3695
+ title: z$1.ZodString;
3696
+ status: z$1.ZodLiteral<number>;
3697
+ error: z$1.ZodObject<{
3698
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3699
+ message: z$1.ZodString;
3700
+ }, z$1.core.$strip>;
3701
+ }, z$1.core.$strip>;
3702
+ };
3703
+ };
3704
+ };
3705
+ readonly 500: {
3706
+ description: string;
3707
+ content: {
3708
+ 'application/problem+json': {
3709
+ schema: z$1.ZodObject<{
3710
+ instance: z$1.ZodOptional<z$1.ZodString>;
3711
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3712
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3713
+ detail: z$1.ZodString;
3714
+ title: z$1.ZodString;
3715
+ status: z$1.ZodLiteral<number>;
3716
+ error: z$1.ZodObject<{
3717
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3718
+ message: z$1.ZodString;
3719
+ }, z$1.core.$strip>;
3720
+ }, z$1.core.$strip>;
3721
+ };
3722
+ };
3723
+ };
3724
+ };
3725
+ declare const commonGetErrorResponses: {
3726
+ readonly 400: {
3727
+ description: string;
3728
+ content: {
3729
+ 'application/problem+json': {
3730
+ schema: z$1.ZodObject<{
3731
+ instance: z$1.ZodOptional<z$1.ZodString>;
3732
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3733
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3734
+ detail: z$1.ZodString;
3735
+ title: z$1.ZodString;
3736
+ status: z$1.ZodLiteral<number>;
3737
+ error: z$1.ZodObject<{
3738
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3739
+ message: z$1.ZodString;
3740
+ }, z$1.core.$strip>;
3741
+ }, z$1.core.$strip>;
3742
+ };
3743
+ };
3744
+ };
3745
+ readonly 401: {
3746
+ description: string;
3747
+ content: {
3748
+ 'application/problem+json': {
3749
+ schema: z$1.ZodObject<{
3750
+ instance: z$1.ZodOptional<z$1.ZodString>;
3751
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3752
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3753
+ detail: z$1.ZodString;
3754
+ title: z$1.ZodString;
3755
+ status: z$1.ZodLiteral<number>;
3756
+ error: z$1.ZodObject<{
3757
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3758
+ message: z$1.ZodString;
3759
+ }, z$1.core.$strip>;
3760
+ }, z$1.core.$strip>;
3761
+ };
3762
+ };
3763
+ };
3764
+ readonly 403: {
3765
+ description: string;
3766
+ content: {
3767
+ 'application/problem+json': {
3768
+ schema: z$1.ZodObject<{
3769
+ instance: z$1.ZodOptional<z$1.ZodString>;
3770
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3771
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3772
+ detail: z$1.ZodString;
3773
+ title: z$1.ZodString;
3774
+ status: z$1.ZodLiteral<number>;
3775
+ error: z$1.ZodObject<{
3776
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3777
+ message: z$1.ZodString;
3778
+ }, z$1.core.$strip>;
3779
+ }, z$1.core.$strip>;
3780
+ };
3781
+ };
3782
+ };
3783
+ readonly 404: {
3784
+ description: string;
3785
+ content: {
3786
+ 'application/problem+json': {
3787
+ schema: z$1.ZodObject<{
3788
+ instance: z$1.ZodOptional<z$1.ZodString>;
3789
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3790
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3791
+ detail: z$1.ZodString;
3792
+ title: z$1.ZodString;
3793
+ status: z$1.ZodLiteral<number>;
3794
+ error: z$1.ZodObject<{
3795
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3796
+ message: z$1.ZodString;
3797
+ }, z$1.core.$strip>;
3798
+ }, z$1.core.$strip>;
3799
+ };
3800
+ };
3801
+ };
3802
+ readonly 422: {
3803
+ description: string;
3804
+ content: {
3805
+ 'application/problem+json': {
3806
+ schema: z$1.ZodObject<{
3807
+ instance: z$1.ZodOptional<z$1.ZodString>;
3808
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3809
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3810
+ detail: z$1.ZodString;
3811
+ title: z$1.ZodString;
3812
+ status: z$1.ZodLiteral<number>;
3813
+ error: z$1.ZodObject<{
3814
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3815
+ message: z$1.ZodString;
3816
+ }, z$1.core.$strip>;
3817
+ }, z$1.core.$strip>;
3818
+ };
3819
+ };
3820
+ };
3821
+ readonly 500: {
3822
+ description: string;
3823
+ content: {
3824
+ 'application/problem+json': {
3825
+ schema: z$1.ZodObject<{
3826
+ instance: z$1.ZodOptional<z$1.ZodString>;
3827
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3828
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3829
+ detail: z$1.ZodString;
3830
+ title: z$1.ZodString;
3831
+ status: z$1.ZodLiteral<number>;
3832
+ error: z$1.ZodObject<{
3833
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3834
+ message: z$1.ZodString;
3835
+ }, z$1.core.$strip>;
3836
+ }, z$1.core.$strip>;
3837
+ };
3838
+ };
3839
+ };
3840
+ };
3841
+ declare const commonDeleteErrorResponses: {
3842
+ readonly 400: {
3843
+ description: string;
3844
+ content: {
3845
+ 'application/problem+json': {
3846
+ schema: z$1.ZodObject<{
3847
+ instance: z$1.ZodOptional<z$1.ZodString>;
3848
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3849
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3850
+ detail: z$1.ZodString;
3851
+ title: z$1.ZodString;
3852
+ status: z$1.ZodLiteral<number>;
3853
+ error: z$1.ZodObject<{
3854
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3855
+ message: z$1.ZodString;
3856
+ }, z$1.core.$strip>;
3857
+ }, z$1.core.$strip>;
3858
+ };
3859
+ };
3860
+ };
3861
+ readonly 401: {
3862
+ description: string;
3863
+ content: {
3864
+ 'application/problem+json': {
3865
+ schema: z$1.ZodObject<{
3866
+ instance: z$1.ZodOptional<z$1.ZodString>;
3867
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3868
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3869
+ detail: z$1.ZodString;
3870
+ title: z$1.ZodString;
3871
+ status: z$1.ZodLiteral<number>;
3872
+ error: z$1.ZodObject<{
3873
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3874
+ message: z$1.ZodString;
3875
+ }, z$1.core.$strip>;
3876
+ }, z$1.core.$strip>;
3877
+ };
3878
+ };
3879
+ };
3880
+ readonly 403: {
3881
+ description: string;
3882
+ content: {
3883
+ 'application/problem+json': {
3884
+ schema: z$1.ZodObject<{
3885
+ instance: z$1.ZodOptional<z$1.ZodString>;
3886
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3887
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3888
+ detail: z$1.ZodString;
3889
+ title: z$1.ZodString;
3890
+ status: z$1.ZodLiteral<number>;
3891
+ error: z$1.ZodObject<{
3892
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3893
+ message: z$1.ZodString;
3894
+ }, z$1.core.$strip>;
3895
+ }, z$1.core.$strip>;
3896
+ };
3897
+ };
3898
+ };
3899
+ readonly 404: {
3900
+ description: string;
3901
+ content: {
3902
+ 'application/problem+json': {
3903
+ schema: z$1.ZodObject<{
3904
+ instance: z$1.ZodOptional<z$1.ZodString>;
3905
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3906
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3907
+ detail: z$1.ZodString;
3908
+ title: z$1.ZodString;
3909
+ status: z$1.ZodLiteral<number>;
3910
+ error: z$1.ZodObject<{
3911
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3912
+ message: z$1.ZodString;
3913
+ }, z$1.core.$strip>;
3914
+ }, z$1.core.$strip>;
3915
+ };
3916
+ };
3917
+ };
3918
+ readonly 422: {
3919
+ description: string;
3920
+ content: {
3921
+ 'application/problem+json': {
3922
+ schema: z$1.ZodObject<{
3923
+ instance: z$1.ZodOptional<z$1.ZodString>;
3924
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3925
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3926
+ detail: z$1.ZodString;
3927
+ title: z$1.ZodString;
3928
+ status: z$1.ZodLiteral<number>;
3929
+ error: z$1.ZodObject<{
3930
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3931
+ message: z$1.ZodString;
3932
+ }, z$1.core.$strip>;
3933
+ }, z$1.core.$strip>;
3934
+ };
3935
+ };
3936
+ };
3937
+ readonly 500: {
3938
+ description: string;
3939
+ content: {
3940
+ 'application/problem+json': {
3941
+ schema: z$1.ZodObject<{
3942
+ instance: z$1.ZodOptional<z$1.ZodString>;
3943
+ requestId: z$1.ZodOptional<z$1.ZodString>;
3944
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3945
+ detail: z$1.ZodString;
3946
+ title: z$1.ZodString;
3947
+ status: z$1.ZodLiteral<number>;
3948
+ error: z$1.ZodObject<{
3949
+ code: z$1.ZodLiteral<"unauthorized" | "bad_request" | "forbidden" | "not_found" | "conflict" | "internal_server_error" | "unprocessable_entity">;
3950
+ message: z$1.ZodString;
3951
+ }, z$1.core.$strip>;
3952
+ }, z$1.core.$strip>;
3953
+ };
3954
+ };
3955
+ };
3956
+ };
3957
+ type CommonCreateErrorResponses = typeof commonCreateErrorResponses;
3958
+ type CommonUpdateErrorResponses = typeof commonUpdateErrorResponses;
3959
+ type CommonGetErrorResponses = typeof commonGetErrorResponses;
3960
+ type CommonDeleteErrorResponses = typeof commonDeleteErrorResponses;
3961
+
3962
+ /**
3963
+ * Create execution context from middleware values
3964
+ */
3965
+ declare function createExecutionContext(params: {
3966
+ apiKey: string;
3967
+ tenantId: string;
3968
+ projectId: string;
3969
+ graphId: string;
3970
+ apiKeyId: string;
3971
+ baseUrl?: string;
3972
+ }): ExecutionContext;
3973
+ /**
3974
+ * Get execution context from API key authentication
3975
+ */
3976
+ declare function getRequestExecutionContext(c: Context): ExecutionContext;
3977
+
3978
+ /**
3979
+ * Helper function to handle span errors consistently
3980
+ * Records the exception, sets error status, and optionally logs
3981
+ */
3982
+ declare function setSpanWithError(span: Span, error: unknown, logger?: {
3983
+ error: (obj: any, msg?: string) => void;
3984
+ }, logMessage?: string): void;
3985
+ /**
3986
+ * Get a tracer instance for the specified service
3987
+ * Returns a no-op tracer if OpenTelemetry is not available
3988
+ */
3989
+ declare function getTracer(serviceName: string, serviceVersion?: string): Tracer;
3990
+
3991
+ export { AgentGraphInsert, AgentGraphUpdate, AgentInsert, AgentRelationInsert, AgentRelationUpdate, AgentScopeConfig, AgentSelect, AgentToolRelationUpdate, AgentUpdate, ApiKeyCreateResult, type ApiKeyGenerationResult, ApiKeyInsert, ApiKeySelect, ApiKeyUpdate, Artifact, ArtifactComponentInsert, ArtifactComponentSelect, ArtifactComponentUpdate, type CommonCreateErrorResponses, type CommonDeleteErrorResponses, type CommonGetErrorResponses, type CommonUpdateErrorResponses, ContextCache, ContextCacheInsert, ContextCacheSelect, ContextConfigBuilder, type ContextConfigBuilderOptions, ContextConfigInsert, ContextConfigSelect, ContextConfigUpdate, ContextFetchDefinition, ContextFetcher, type ContextResolutionOptions, type ContextResolutionResult, ContextResolver, type ContextResolverInterface, type ContextValidationError, type ContextValidationResult, ConversationHistoryConfig, ConversationInsert, ConversationMetadata, ConversationSelect, ConversationUpdate, CreateApiKeyParams, type CredentialContext, type CredentialData, CredentialReferenceApiInsert, CredentialReferenceInsert, CredentialReferenceSelect, CredentialReferenceUpdate, type CredentialReferenceWithTools, type CredentialResolverInput, CredentialStore, type CredentialStoreReference, CredentialStoreRegistry, CredentialStoreType, CredentialStuffer, DataComponentInsert, DataComponentSelect, DataComponentUpdate, type DatabaseClient, type DatabaseConfig, type DotPaths, ERROR_DOCS_BASE_URL, ErrorCode, type ErrorCodes, type ErrorResponse, ExecutionContext, ExternalAgentInsert, ExternalAgentRelationInsert, ExternalAgentSelect, ExternalAgentUpdate, type FetchResult, FullGraphDefinition, FullProjectDefinition, type GraphLogger, GraphScopeConfig, HTTP_REQUEST_PARTS, type HttpRequestPart, InMemoryCredentialStore, KeyChainStore, LedgerArtifactSelect, type LoggerFactoryConfig, MCPToolConfig, MCPTransportType, McpClient, type McpClientOptions, type McpSSEConfig, type McpServerConfig, type McpStreamableHttpConfig, McpTool, McpToolDefinition, McpToolStatus, MessageContent, MessageInsert, MessageMetadata, MessageUpdate, MessageVisibility, NangoCredentialStore, type OAuthConfig, PaginationConfig, PaginationResult, type ParsedHttpRequest, PinoLogger, type PinoLoggerConfig, type ProblemDetails, ProjectInfo, ProjectInsert, type ProjectLogger, ProjectResourceCounts, ProjectScopeConfig, ProjectSelect, ProjectUpdate, type ResolvedContext, TaskInsert, TaskMetadataConfig, TaskSelect, type TemplateContext, TemplateEngine, type TemplateRenderOptions, ToolInsert, ToolMcpConfig, ToolSelect, ToolServerCapabilities, ToolUpdate, addLedgerArtifacts, addToolToAgent, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, contextConfig, contextValidationMiddleware, countApiKeys, countArtifactComponents, countArtifactComponentsForAgent, countContextConfigs, countCredentialReferences, countDataComponents, countExternalAgents, countLedgerArtifactsByTask, countMessagesByConversation, countProjects, createAgent, createAgentGraph, createAgentRelation, createAgentToolRelation, createApiError, createApiKey, createArtifactComponent, createContextConfig, createConversation, createCredentialReference, createDataComponent, createDatabaseClient, createDefaultCredentialStores, createExecutionContext, createExternalAgent, createExternalAgentRelation, createFullGraphServerSide, createFullProjectServerSide, createInMemoryDatabaseClient, createKeyChainStore, createMessage, createNangoCredentialStore, createOrGetConversation, createProject, createTask, createTool, createValidatedDataAccess, dbResultToMcpTool, deleteAgent, deleteAgentArtifactComponentRelationByAgent, deleteAgentDataComponentRelationByAgent, deleteAgentGraph, deleteAgentRelation, deleteAgentRelationsByGraph, deleteAgentToolRelation, deleteAgentToolRelationByAgent, deleteApiKey, deleteArtifactComponent, deleteContextConfig, deleteConversation, deleteCredentialReference, deleteDataComponent, deleteExternalAgent, deleteFullGraph, deleteFullProject, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, deleteMessage, deleteProject, deleteTool, detectAuthenticationRequired, determineContextTrigger, discoverOAuthEndpoints, errorResponseSchema, errorSchemaFactory, externalAgentExists, externalAgentUrlExists, extractPublicId, fetchComponentRelationships, fetchDefinition, generateAndCreateApiKey, generateApiKey, getActiveAgentForConversation, getAgentById, getAgentGraphById, getAgentGraphWithDefaultAgent, getAgentRelationById, getAgentRelationByParams, getAgentRelations, getAgentRelationsByGraph, getAgentRelationsBySource, getAgentRelationsByTarget, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentsByIds, getAgentsForTool, getAgentsUsingArtifactComponent, getAgentsUsingDataComponent, getApiKeyById, getApiKeyByPublicId, getArtifactComponentById, getArtifactComponentsForAgent, getCacheEntry, getCachedValidator, getContextConfigById, getContextConfigCacheEntries, getContextConfigsByName, getConversation, getConversationCacheEntries, getConversationHistory, getCredentialReference, getCredentialReferenceById, getCredentialReferenceWithTools, getCredentialStoreLookupKeyFromRetrievalParams, getDataComponent, getDataComponentsForAgent, getExternalAgent, getExternalAgentByUrl, getExternalAgentRelations, getFullGraph, getFullGraphDefinition, getFullProject, getGraphAgentInfos, getHealthyToolsForAgent, getLedgerArtifacts, getLedgerArtifactsByContext, getLogger, getMessageById, getMessagesByConversation, getMessagesByTask, getProject, getProjectResourceCounts, getRelatedAgentsForGraph, getRequestExecutionContext, getTask, getToolById, getToolsByStatus, getToolsForAgent, getTracer, getVisibleMessages, graphHasArtifactComponents, handleApiError, handleContextConfigChange, handleContextResolution, hasApiKey, hasContextConfig, hasCredentialReference, hashApiKey, invalidateInvocationDefinitionsCache, invalidateRequestContextCache, isApiKeyExpired, isArtifactComponentAssociatedWithAgent, isDataComponentAssociatedWithAgent, isValidHttpRequest, listAgentGraphs, listAgentGraphsPaginated, listAgentRelations, listAgentToolRelations, listAgents, listAgentsPaginated, listApiKeys, listApiKeysPaginated, listArtifactComponents, listArtifactComponentsPaginated, listContextConfigs, listContextConfigsPaginated, listConversations, listCredentialReferences, listCredentialReferencesPaginated, listDataComponents, listDataComponentsPaginated, listExternalAgents, listExternalAgentsPaginated, listMessages, listProjects, listProjectsPaginated, listTaskIdsByContextId, listTools, listToolsByStatus, loadEnvironmentFiles, loggerFactory, maskApiKey, problemDetailsSchema, projectExists, projectExistsInTable, projectHasResources, removeArtifactComponentFromAgent, removeDataComponentFromAgent, removeToolFromAgent, requestContextSchema, setActiveAgentForConversation, setActiveAgentForThread, setCacheEntry, setSpanWithError, updateAgent, updateAgentGraph, updateAgentRelation, updateAgentToolRelation, updateApiKey, updateApiKeyLastUsed, updateArtifactComponent, updateContextConfig, updateConversation, updateConversationActiveAgent, updateCredentialReference, updateDataComponent, updateExternalAgent, updateFullGraphServerSide, updateFullProjectServerSide, updateMessage, updateProject, updateTask, updateTool, updateToolStatus, upsertAgent, upsertAgentArtifactComponentRelation, upsertAgentDataComponentRelation, upsertAgentGraph, upsertAgentRelation, upsertAgentToolRelation, upsertArtifactComponent, upsertContextConfig, upsertCredentialReference, upsertDataComponent, upsertExternalAgent, upsertTool, validateAgainstJsonSchema, validateAndGetApiKey, validateApiKey, validateExternalAgent, validateHttpRequestHeaders, validateInternalAgent, validateProjectExists, validateRequestContext, validationHelper, withProjectValidation };