@inkeep/agents-core 0.41.2 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-client/base-client.d.ts +87 -8
- package/dist/api-client/base-client.js +174 -1
- package/dist/api-client/eval-api-client.d.ts +47 -0
- package/dist/api-client/eval-api-client.js +65 -0
- package/dist/api-client/index.d.ts +4 -0
- package/dist/api-client/index.js +5 -0
- package/dist/api-client/manage-api-client.d.ts +34 -0
- package/dist/api-client/manage-api-client.js +104 -0
- package/dist/auth/auth.d.ts +86 -20
- package/dist/auth/auth.js +60 -2
- package/dist/auth/authz/client.d.ts +87 -0
- package/dist/auth/authz/client.js +196 -0
- package/dist/auth/authz/config.d.ts +103 -0
- package/dist/auth/authz/config.js +93 -0
- package/dist/auth/authz/index.d.ts +5 -0
- package/dist/auth/authz/index.js +6 -0
- package/dist/auth/authz/permissions.d.ts +53 -0
- package/dist/auth/authz/permissions.js +83 -0
- package/dist/auth/authz/sync.d.ts +106 -0
- package/dist/auth/authz/sync.js +321 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/permissions.js +2 -181
- package/dist/client-exports.d.ts +9 -3
- package/dist/client-exports.js +4 -2
- package/dist/constants/context-breakdown.d.ts +61 -0
- package/dist/constants/context-breakdown.js +124 -0
- package/dist/constants/execution-limits-shared/defaults.d.ts +1 -1
- package/dist/constants/execution-limits-shared/defaults.js +1 -1
- package/dist/constants/execution-limits-shared/index.d.ts +1 -1
- package/dist/constants/otel-attributes.d.ts +4 -0
- package/dist/constants/otel-attributes.js +4 -0
- package/dist/context/ContextConfig.d.ts +2 -2
- package/dist/context/ContextConfig.js +3 -3
- package/dist/context/TemplateEngine.d.ts +0 -6
- package/dist/context/TemplateEngine.js +4 -19
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.js +1 -5
- package/dist/credential-stores/keychain-store.d.ts +20 -8
- package/dist/credential-stores/keychain-store.js +107 -43
- package/dist/credential-stuffer/CredentialStuffer.d.ts +1 -1
- package/dist/data-access/index.d.ts +34 -26
- package/dist/data-access/index.js +34 -26
- package/dist/data-access/manage/agentFull.d.ts +36 -0
- package/dist/data-access/{agentFull.js → manage/agentFull.js} +209 -7
- package/dist/data-access/{agents.d.ts → manage/agents.d.ts} +64 -63
- package/dist/data-access/{agents.js → manage/agents.js} +80 -27
- package/dist/data-access/{artifactComponents.d.ts → manage/artifactComponents.d.ts} +33 -33
- package/dist/data-access/{artifactComponents.js → manage/artifactComponents.js} +5 -5
- package/dist/data-access/{contextConfigs.d.ts → manage/contextConfigs.d.ts} +26 -26
- package/dist/data-access/{contextConfigs.js → manage/contextConfigs.js} +3 -3
- package/dist/data-access/{credentialReferences.d.ts → manage/credentialReferences.d.ts} +17 -17
- package/dist/data-access/{credentialReferences.js → manage/credentialReferences.js} +2 -2
- package/dist/data-access/{dataComponents.d.ts → manage/dataComponents.d.ts} +26 -26
- package/dist/data-access/{dataComponents.js → manage/dataComponents.js} +7 -7
- package/dist/data-access/manage/evalConfig.d.ts +221 -0
- package/dist/data-access/manage/evalConfig.js +275 -0
- package/dist/data-access/{externalAgents.d.ts → manage/externalAgents.d.ts} +16 -16
- package/dist/data-access/{externalAgents.js → manage/externalAgents.js} +2 -2
- package/dist/data-access/manage/functionTools.d.ts +242 -0
- package/dist/data-access/{functionTools.js → manage/functionTools.js} +124 -30
- package/dist/data-access/{functions.d.ts → manage/functions.d.ts} +9 -9
- package/dist/data-access/{functions.js → manage/functions.js} +3 -3
- package/dist/data-access/manage/projectFull.d.ts +38 -0
- package/dist/data-access/{projectFull.js → manage/projectFull.js} +64 -65
- package/dist/data-access/manage/projectLifecycle.d.ts +119 -0
- package/dist/data-access/manage/projectLifecycle.js +234 -0
- package/dist/data-access/manage/projects.d.ts +75 -0
- package/dist/data-access/{projects.js → manage/projects.js} +15 -16
- package/dist/data-access/{subAgentExternalAgentRelations.d.ts → manage/subAgentExternalAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentExternalAgentRelations.js → manage/subAgentExternalAgentRelations.js} +2 -2
- package/dist/data-access/{subAgentRelations.d.ts → manage/subAgentRelations.d.ts} +65 -65
- package/dist/data-access/{subAgentRelations.js → manage/subAgentRelations.js} +3 -3
- package/dist/data-access/{subAgentTeamAgentRelations.d.ts → manage/subAgentTeamAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentTeamAgentRelations.js → manage/subAgentTeamAgentRelations.js} +2 -2
- package/dist/data-access/{subAgents.d.ts → manage/subAgents.d.ts} +28 -28
- package/dist/data-access/{subAgents.js → manage/subAgents.js} +4 -4
- package/dist/data-access/{tools.d.ts → manage/tools.d.ts} +65 -52
- package/dist/data-access/{tools.js → manage/tools.js} +109 -64
- package/dist/data-access/manage/triggers.d.ts +106 -0
- package/dist/data-access/manage/triggers.js +81 -0
- package/dist/data-access/{apiKeys.d.ts → runtime/apiKeys.d.ts} +37 -37
- package/dist/data-access/{apiKeys.js → runtime/apiKeys.js} +3 -3
- package/dist/data-access/runtime/cascade-delete.d.ts +77 -0
- package/dist/data-access/runtime/cascade-delete.js +111 -0
- package/dist/data-access/{contextCache.d.ts → runtime/contextCache.d.ts} +13 -13
- package/dist/data-access/{contextCache.js → runtime/contextCache.js} +5 -5
- package/dist/data-access/{conversations.d.ts → runtime/conversations.d.ts} +80 -31
- package/dist/data-access/{conversations.js → runtime/conversations.js} +13 -7
- package/dist/data-access/runtime/evalRuns.d.ts +120 -0
- package/dist/data-access/runtime/evalRuns.js +168 -0
- package/dist/data-access/{ledgerArtifacts.d.ts → runtime/ledgerArtifacts.d.ts} +13 -13
- package/dist/data-access/{ledgerArtifacts.js → runtime/ledgerArtifacts.js} +3 -3
- package/dist/data-access/{messages.d.ts → runtime/messages.d.ts} +24 -24
- package/dist/data-access/{messages.js → runtime/messages.js} +2 -2
- package/dist/data-access/{organizations.d.ts → runtime/organizations.d.ts} +16 -7
- package/dist/data-access/{organizations.js → runtime/organizations.js} +16 -4
- package/dist/data-access/runtime/projects.d.ts +62 -0
- package/dist/data-access/runtime/projects.js +90 -0
- package/dist/data-access/runtime/tasks.d.ts +55 -0
- package/dist/data-access/{tasks.js → runtime/tasks.js} +2 -2
- package/dist/data-access/runtime/triggerInvocations.d.ts +62 -0
- package/dist/data-access/runtime/triggerInvocations.js +54 -0
- package/dist/data-access/runtime/users.d.ts +19 -0
- package/dist/data-access/{users.js → runtime/users.js} +2 -2
- package/dist/data-access/validation.d.ts +4 -4
- package/dist/data-access/validation.js +1 -1
- package/dist/db/clean.d.ts +8 -4
- package/dist/db/clean.js +14 -105
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +7 -10
- package/dist/db/manage/dolt-cleanup.d.ts +51 -0
- package/dist/db/manage/dolt-cleanup.js +132 -0
- package/dist/db/manage/manage-client.d.ts +26 -0
- package/dist/db/manage/manage-client.js +68 -0
- package/dist/db/{schema.d.ts → manage/manage-schema.d.ts} +1257 -969
- package/dist/db/{schema.js → manage/manage-schema.js} +436 -334
- package/dist/db/manage/test-manage-client.d.ts +27 -0
- package/dist/db/manage/test-manage-client.js +68 -0
- package/dist/db/runtime/runtime-client.d.ts +20 -0
- package/dist/db/runtime/runtime-client.js +30 -0
- package/dist/db/runtime/runtime-schema.d.ts +2834 -0
- package/dist/db/runtime/runtime-schema.js +483 -0
- package/dist/db/runtime/test-runtime-client.d.ts +27 -0
- package/dist/db/{test-client.js → runtime/test-runtime-client.js} +11 -25
- package/dist/db/utils.d.ts +6 -0
- package/dist/db/utils.js +42 -0
- package/dist/dolt/branch.d.ts +62 -0
- package/dist/dolt/branch.js +82 -0
- package/dist/dolt/branches-api.d.ts +108 -0
- package/dist/dolt/branches-api.js +162 -0
- package/dist/dolt/commit.d.ts +94 -0
- package/dist/dolt/commit.js +103 -0
- package/dist/dolt/diff.d.ts +27 -0
- package/dist/dolt/diff.js +21 -0
- package/dist/dolt/index.d.ts +10 -0
- package/dist/dolt/index.js +11 -0
- package/dist/dolt/merge.d.ts +63 -0
- package/dist/dolt/merge.js +81 -0
- package/dist/dolt/migrate-all-branches.d.ts +4 -0
- package/dist/dolt/migrate-all-branches.js +83 -0
- package/dist/dolt/migrate-dolt.d.ts +1 -0
- package/dist/dolt/migrate-dolt.js +25 -0
- package/dist/dolt/ref-helpers.d.ts +19 -0
- package/dist/dolt/ref-helpers.js +65 -0
- package/dist/dolt/ref-middleware.d.ts +82 -0
- package/dist/dolt/ref-middleware.js +217 -0
- package/dist/dolt/ref-scope.d.ts +101 -0
- package/dist/dolt/ref-scope.js +231 -0
- package/dist/dolt/schema-sync.d.ts +135 -0
- package/dist/dolt/schema-sync.js +255 -0
- package/dist/env.d.ts +6 -4
- package/dist/env.js +3 -2
- package/dist/index.d.ts +73 -46
- package/dist/index.js +76 -49
- package/dist/types/@napi-rs__keyring/index.d.ts +14 -0
- package/dist/types/entities.d.ts +81 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +46 -5
- package/dist/types/utility.js +2 -1
- package/dist/utils/JsonTransformer.d.ts +42 -0
- package/dist/utils/JsonTransformer.js +103 -0
- package/dist/utils/apiKeys.d.ts +5 -1
- package/dist/utils/apiKeys.js +11 -1
- package/dist/utils/colors.d.ts +34 -0
- package/dist/utils/colors.js +49 -0
- package/dist/utils/credential-store-utils.d.ts +1 -1
- package/dist/utils/format-messages.d.ts +1 -1
- package/dist/utils/index.d.ts +8 -4
- package/dist/utils/index.js +8 -4
- package/dist/utils/internal-service-auth.d.ts +79 -0
- package/dist/utils/internal-service-auth.js +140 -0
- package/dist/utils/jmespath-utils.d.ts +152 -0
- package/dist/utils/jmespath-utils.js +213 -0
- package/dist/utils/jwt-helpers.d.ts +56 -0
- package/dist/utils/jwt-helpers.js +90 -0
- package/dist/utils/mcp-client.d.ts +1 -1
- package/dist/utils/mcp-client.js +1 -1
- package/dist/utils/service-token-auth.d.ts +9 -27
- package/dist/utils/service-token-auth.js +48 -96
- package/dist/utils/signature-validation.d.ts +2 -0
- package/dist/utils/signature-validation.js +3 -0
- package/dist/utils/template-interpolation.d.ts +22 -0
- package/dist/utils/template-interpolation.js +62 -0
- package/dist/utils/third-party-mcp-servers/composio-client.d.ts +13 -1
- package/dist/utils/third-party-mcp-servers/composio-client.js +47 -29
- package/dist/utils/third-party-mcp-servers/index.d.ts +2 -2
- package/dist/utils/third-party-mcp-servers/index.js +2 -2
- package/dist/utils/trigger-auth.d.ts +85 -0
- package/dist/utils/trigger-auth.js +233 -0
- package/dist/validation/agentFull.js +2 -4
- package/dist/validation/dolt-schemas.d.ts +49 -0
- package/dist/validation/dolt-schemas.js +44 -0
- package/dist/validation/drizzle-schema-helpers.d.ts +4 -26
- package/dist/validation/drizzle-schema-helpers.js +5 -151
- package/dist/validation/index.d.ts +5 -4
- package/dist/validation/index.js +4 -3
- package/dist/validation/render-validation.js +19 -0
- package/dist/validation/schemas.d.ts +18223 -5148
- package/dist/validation/schemas.js +559 -12
- package/dist/validation/stream-event-schemas.d.ts +96 -1
- package/dist/validation/stream-event-schemas.js +67 -2
- package/drizzle/manage/0000_tearful_rhodey.sql +414 -0
- package/drizzle/manage/0001_broken_wendell_vaughn.sql +19 -0
- package/drizzle/manage/0002_bent_sunfire.sql +1 -0
- package/drizzle/manage/0003_tiny_captain_universe.sql +8 -0
- package/drizzle/manage/0004_curious_phil_sheldon.sql +2 -0
- package/drizzle/manage/0005_silent_shatterstar.sql +53 -0
- package/drizzle/manage/meta/0000_snapshot.json +2987 -0
- package/drizzle/manage/meta/0001_snapshot.json +3115 -0
- package/drizzle/manage/meta/0002_snapshot.json +3115 -0
- package/drizzle/manage/meta/0003_snapshot.json +3134 -0
- package/drizzle/manage/meta/0004_snapshot.json +3141 -0
- package/drizzle/manage/meta/0005_snapshot.json +3141 -0
- package/drizzle/manage/meta/_journal.json +48 -0
- package/drizzle/runtime/0008_silly_preak.sql +127 -0
- package/drizzle/runtime/0009_freezing_leo.sql +17 -0
- package/drizzle/runtime/meta/0008_snapshot.json +2263 -0
- package/drizzle/runtime/meta/0009_snapshot.json +2397 -0
- package/drizzle/{meta → runtime/meta}/_journal.json +14 -0
- package/package.json +56 -18
- package/spicedb/schema.zed +114 -0
- package/dist/context/ContextFetcher.d.ts +0 -73
- package/dist/context/ContextFetcher.js +0 -291
- package/dist/context/ContextResolver.d.ts +0 -60
- package/dist/context/ContextResolver.js +0 -278
- package/dist/context/context.d.ts +0 -27
- package/dist/context/context.js +0 -128
- package/dist/context/contextCache.d.ts +0 -58
- package/dist/context/contextCache.js +0 -177
- package/dist/data-access/agentFull.d.ts +0 -33
- package/dist/data-access/functionTools.d.ts +0 -169
- package/dist/data-access/projectFull.d.ts +0 -32
- package/dist/data-access/projects.d.ts +0 -71
- package/dist/data-access/tasks.d.ts +0 -45
- package/dist/data-access/users.d.ts +0 -19
- package/dist/db/client.d.ts +0 -20
- package/dist/db/client.js +0 -28
- package/dist/db/test-client.d.ts +0 -31
- package/dist/middleware/contextValidation.d.ts +0 -46
- package/dist/middleware/contextValidation.js +0 -280
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.js +0 -3
- package/dist/utils/execution.d.ts +0 -22
- package/dist/utils/execution.js +0 -25
- /package/drizzle/{0000_exotic_mysterio.sql → runtime/0000_exotic_mysterio.sql} +0 -0
- /package/drizzle/{0001_calm_sheva_callister.sql → runtime/0001_calm_sheva_callister.sql} +0 -0
- /package/drizzle/{0002_puzzling_goblin_queen.sql → runtime/0002_puzzling_goblin_queen.sql} +0 -0
- /package/drizzle/{0003_sweet_human_robot.sql → runtime/0003_sweet_human_robot.sql} +0 -0
- /package/drizzle/{0004_cuddly_shooting_star.sql → runtime/0004_cuddly_shooting_star.sql} +0 -0
- /package/drizzle/{0005_reflective_starfox.sql → runtime/0005_reflective_starfox.sql} +0 -0
- /package/drizzle/{0006_stale_thaddeus_ross.sql → runtime/0006_stale_thaddeus_ross.sql} +0 -0
- /package/drizzle/{0007_slim_karma.sql → runtime/0007_slim_karma.sql} +0 -0
- /package/drizzle/{meta → runtime/meta}/0000_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0001_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0003_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0005_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0006_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0007_snapshot.json +0 -0
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { getLogger } from "../utils/logger.js";
|
|
2
|
-
import { generateId } from "../utils/conversations.js";
|
|
3
|
-
import { cleanupTenantCache, clearContextConfigCache, clearConversationCache, getCacheEntry, invalidateHeadersCache, invalidateInvocationDefinitionsCache, setCacheEntry } from "../data-access/contextCache.js";
|
|
4
|
-
import "../data-access/index.js";
|
|
5
|
-
|
|
6
|
-
//#region src/context/contextCache.ts
|
|
7
|
-
const logger = getLogger("context-cache");
|
|
8
|
-
/**
|
|
9
|
-
* Context cache with request hash-based invalidation and graceful error handling.
|
|
10
|
-
*
|
|
11
|
-
* Implements conversation-scoped caching with smart cache invalidation based on
|
|
12
|
-
* request hash changes. All cache errors are treated as cache misses to ensure
|
|
13
|
-
* system reliability.
|
|
14
|
-
*/
|
|
15
|
-
var ContextCache = class {
|
|
16
|
-
tenantId;
|
|
17
|
-
projectId;
|
|
18
|
-
dbClient;
|
|
19
|
-
constructor(tenantId, projectId, dbClient) {
|
|
20
|
-
this.tenantId = tenantId;
|
|
21
|
-
this.projectId = projectId;
|
|
22
|
-
this.dbClient = dbClient;
|
|
23
|
-
logger.info({ tenantId: this.tenantId }, "ContextCache initialized");
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get cached context data for a conversation
|
|
27
|
-
*/
|
|
28
|
-
async get({ conversationId, contextConfigId, contextVariableKey, requestHash }) {
|
|
29
|
-
try {
|
|
30
|
-
const cacheEntry = await getCacheEntry(this.dbClient)({
|
|
31
|
-
conversationId,
|
|
32
|
-
contextConfigId,
|
|
33
|
-
contextVariableKey,
|
|
34
|
-
requestHash
|
|
35
|
-
});
|
|
36
|
-
if (!cacheEntry) return null;
|
|
37
|
-
return {
|
|
38
|
-
contextConfigId: cacheEntry.contextConfigId,
|
|
39
|
-
contextVariableKey: cacheEntry.contextVariableKey,
|
|
40
|
-
conversationId: cacheEntry.conversationId,
|
|
41
|
-
value: cacheEntry.value,
|
|
42
|
-
requestHash: cacheEntry.requestHash || void 0,
|
|
43
|
-
tenantId: this.tenantId
|
|
44
|
-
};
|
|
45
|
-
} catch (error) {
|
|
46
|
-
logger.error({
|
|
47
|
-
conversationId,
|
|
48
|
-
contextConfigId,
|
|
49
|
-
contextVariableKey,
|
|
50
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
51
|
-
}, "Failed to get cache entry");
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Set cached context data for a conversation
|
|
57
|
-
*/
|
|
58
|
-
async set(entry) {
|
|
59
|
-
try {
|
|
60
|
-
const cacheData = {
|
|
61
|
-
id: generateId(),
|
|
62
|
-
tenantId: this.tenantId,
|
|
63
|
-
projectId: this.projectId,
|
|
64
|
-
conversationId: entry.conversationId,
|
|
65
|
-
contextConfigId: entry.contextConfigId,
|
|
66
|
-
contextVariableKey: entry.contextVariableKey,
|
|
67
|
-
value: entry.value,
|
|
68
|
-
requestHash: entry.requestHash,
|
|
69
|
-
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
70
|
-
fetchSource: `${entry.contextConfigId}:${entry.contextVariableKey}`,
|
|
71
|
-
fetchDurationMs: 0,
|
|
72
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
73
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
74
|
-
};
|
|
75
|
-
await setCacheEntry(this.dbClient)(cacheData);
|
|
76
|
-
logger.debug({
|
|
77
|
-
conversationId: entry.conversationId,
|
|
78
|
-
contextConfigId: entry.contextConfigId,
|
|
79
|
-
contextVariableKey: entry.contextVariableKey
|
|
80
|
-
}, "Cache entry set successfully");
|
|
81
|
-
} catch (error) {
|
|
82
|
-
logger.error({
|
|
83
|
-
conversationId: entry.conversationId,
|
|
84
|
-
contextConfigId: entry.contextConfigId,
|
|
85
|
-
contextVariableKey: entry.contextVariableKey,
|
|
86
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
87
|
-
}, "Failed to set cache entry");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Clear cache entries for a specific conversation
|
|
92
|
-
*/
|
|
93
|
-
async clearConversation(tenantId, projectId, conversationId) {
|
|
94
|
-
try {
|
|
95
|
-
const result = await clearConversationCache(this.dbClient)({
|
|
96
|
-
scopes: {
|
|
97
|
-
tenantId,
|
|
98
|
-
projectId
|
|
99
|
-
},
|
|
100
|
-
conversationId
|
|
101
|
-
});
|
|
102
|
-
logger.info({
|
|
103
|
-
conversationId,
|
|
104
|
-
rowsCleared: result
|
|
105
|
-
}, "Conversation cache cleared successfully");
|
|
106
|
-
} catch (error) {
|
|
107
|
-
logger.error({
|
|
108
|
-
conversationId,
|
|
109
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
110
|
-
}, "Failed to clear conversation cache");
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Clear all cache entries for a specific context configuration
|
|
116
|
-
*/
|
|
117
|
-
async clearContextConfig(tenantId, projectId, contextConfigId) {
|
|
118
|
-
try {
|
|
119
|
-
const result = await clearContextConfigCache(this.dbClient)({
|
|
120
|
-
scopes: {
|
|
121
|
-
tenantId,
|
|
122
|
-
projectId
|
|
123
|
-
},
|
|
124
|
-
contextConfigId
|
|
125
|
-
});
|
|
126
|
-
logger.info({
|
|
127
|
-
contextConfigId,
|
|
128
|
-
rowsCleared: result
|
|
129
|
-
}, "Context config cache cleared successfully");
|
|
130
|
-
} catch (error) {
|
|
131
|
-
logger.error({
|
|
132
|
-
contextConfigId,
|
|
133
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
134
|
-
}, "Failed to clear context config cache");
|
|
135
|
-
throw error;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Clean up expired or orphaned cache entries
|
|
140
|
-
*/
|
|
141
|
-
async cleanup() {
|
|
142
|
-
try {
|
|
143
|
-
const result = await cleanupTenantCache(this.dbClient)({ scopes: {
|
|
144
|
-
tenantId: this.tenantId,
|
|
145
|
-
projectId: this.projectId
|
|
146
|
-
} });
|
|
147
|
-
logger.info({ rowsCleared: result }, "Cache cleanup completed");
|
|
148
|
-
} catch (error) {
|
|
149
|
-
logger.error({ error: error instanceof Error ? error.message : "Unknown error" }, "Failed to cleanup cache");
|
|
150
|
-
throw error;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
async invalidateInvocationDefinitions(tenantId, projectId, conversationId, contextConfigId, definitionIds) {
|
|
154
|
-
await invalidateInvocationDefinitionsCache(this.dbClient)({
|
|
155
|
-
scopes: {
|
|
156
|
-
tenantId,
|
|
157
|
-
projectId
|
|
158
|
-
},
|
|
159
|
-
conversationId,
|
|
160
|
-
contextConfigId,
|
|
161
|
-
invocationDefinitionIds: definitionIds
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
async invalidateHeaders(tenantId, projectId, conversationId, contextConfigId) {
|
|
165
|
-
await invalidateHeadersCache(this.dbClient)({
|
|
166
|
-
scopes: {
|
|
167
|
-
tenantId,
|
|
168
|
-
projectId
|
|
169
|
-
},
|
|
170
|
-
conversationId,
|
|
171
|
-
contextConfigId
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
//#endregion
|
|
177
|
-
export { ContextCache };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { FullAgentDefinition } from "../types/entities.js";
|
|
2
|
-
import { AgentScopeConfig, ProjectScopeConfig } from "../types/utility.js";
|
|
3
|
-
import { DatabaseClient } from "../db/client.js";
|
|
4
|
-
|
|
5
|
-
//#region src/data-access/agentFull.d.ts
|
|
6
|
-
interface AgentLogger {
|
|
7
|
-
info(obj: Record<string, any>, msg?: string): void;
|
|
8
|
-
error(obj: Record<string, any>, msg?: string): void;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Server-side implementation of createFullAgent that performs actual database operations.
|
|
12
|
-
* This function creates a complete agent with all agents, tools, and relationships.
|
|
13
|
-
*/
|
|
14
|
-
declare const createFullAgentServerSide: (db: DatabaseClient, logger?: AgentLogger) => (scopes: ProjectScopeConfig, agentData: FullAgentDefinition) => Promise<FullAgentDefinition>;
|
|
15
|
-
/**
|
|
16
|
-
* Server-side implementation of updateFullAgent that performs actual database operations.
|
|
17
|
-
* This function updates a complete agent with all agents, tools, and relationships.
|
|
18
|
-
*/
|
|
19
|
-
declare const updateFullAgentServerSide: (db: DatabaseClient, logger?: AgentLogger) => (scopes: ProjectScopeConfig, agentData: FullAgentDefinition) => Promise<FullAgentDefinition>;
|
|
20
|
-
/**
|
|
21
|
-
* Get a complete agent definition by ID
|
|
22
|
-
*/
|
|
23
|
-
declare const getFullAgent: (db: DatabaseClient, logger?: AgentLogger) => (params: {
|
|
24
|
-
scopes: AgentScopeConfig;
|
|
25
|
-
}) => Promise<FullAgentDefinition | null>;
|
|
26
|
-
/**
|
|
27
|
-
* Delete a complete agent and cascade to all related entities
|
|
28
|
-
*/
|
|
29
|
-
declare const deleteFullAgent: (db: DatabaseClient, logger?: AgentLogger) => (params: {
|
|
30
|
-
scopes: AgentScopeConfig;
|
|
31
|
-
}) => Promise<boolean>;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { AgentLogger, createFullAgentServerSide, deleteFullAgent, getFullAgent, updateFullAgentServerSide };
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { FunctionToolApiInsert, FunctionToolApiUpdate } from "../types/entities.js";
|
|
2
|
-
import { AgentScopeConfig, PaginationConfig } from "../types/utility.js";
|
|
3
|
-
import { DatabaseClient } from "../db/client.js";
|
|
4
|
-
|
|
5
|
-
//#region src/data-access/functionTools.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Get a function tool by ID (agent-scoped)
|
|
9
|
-
*/
|
|
10
|
-
declare const getFunctionToolById: (db: DatabaseClient) => (params: {
|
|
11
|
-
scopes: AgentScopeConfig;
|
|
12
|
-
functionToolId: string;
|
|
13
|
-
}) => Promise<{
|
|
14
|
-
createdAt: string;
|
|
15
|
-
updatedAt: string;
|
|
16
|
-
name: string;
|
|
17
|
-
description: string | null;
|
|
18
|
-
functionId: string;
|
|
19
|
-
agentId: string;
|
|
20
|
-
projectId: string;
|
|
21
|
-
tenantId: string;
|
|
22
|
-
id: string;
|
|
23
|
-
}>;
|
|
24
|
-
/**
|
|
25
|
-
* List function tools (agent-scoped)
|
|
26
|
-
*/
|
|
27
|
-
declare const listFunctionTools: (db: DatabaseClient) => (params: {
|
|
28
|
-
scopes: AgentScopeConfig;
|
|
29
|
-
pagination?: PaginationConfig;
|
|
30
|
-
}) => Promise<{
|
|
31
|
-
data: {
|
|
32
|
-
createdAt: string;
|
|
33
|
-
updatedAt: string;
|
|
34
|
-
name: string;
|
|
35
|
-
description: string | null;
|
|
36
|
-
functionId: string;
|
|
37
|
-
agentId: string;
|
|
38
|
-
projectId: string;
|
|
39
|
-
tenantId: string;
|
|
40
|
-
id: string;
|
|
41
|
-
}[];
|
|
42
|
-
pagination: {
|
|
43
|
-
page: number;
|
|
44
|
-
limit: number;
|
|
45
|
-
total: number;
|
|
46
|
-
pages: number;
|
|
47
|
-
};
|
|
48
|
-
}>;
|
|
49
|
-
/**
|
|
50
|
-
* Create a function tool (agent-scoped)
|
|
51
|
-
*/
|
|
52
|
-
declare const createFunctionTool: (db: DatabaseClient) => (params: {
|
|
53
|
-
data: FunctionToolApiInsert;
|
|
54
|
-
scopes: AgentScopeConfig;
|
|
55
|
-
}) => Promise<{
|
|
56
|
-
tenantId: string;
|
|
57
|
-
projectId: string;
|
|
58
|
-
id: string;
|
|
59
|
-
name: string;
|
|
60
|
-
description: string | null;
|
|
61
|
-
agentId: string;
|
|
62
|
-
createdAt: string;
|
|
63
|
-
updatedAt: string;
|
|
64
|
-
functionId: string;
|
|
65
|
-
}>;
|
|
66
|
-
/**
|
|
67
|
-
* Update a function tool (agent-scoped)
|
|
68
|
-
*/
|
|
69
|
-
declare const updateFunctionTool: (db: DatabaseClient) => (params: {
|
|
70
|
-
scopes: AgentScopeConfig;
|
|
71
|
-
functionToolId: string;
|
|
72
|
-
data: FunctionToolApiUpdate;
|
|
73
|
-
}) => Promise<{
|
|
74
|
-
createdAt: string;
|
|
75
|
-
updatedAt: string;
|
|
76
|
-
name: string;
|
|
77
|
-
description: string | null;
|
|
78
|
-
functionId: string;
|
|
79
|
-
agentId: string;
|
|
80
|
-
projectId: string;
|
|
81
|
-
tenantId: string;
|
|
82
|
-
id: string;
|
|
83
|
-
}>;
|
|
84
|
-
/**
|
|
85
|
-
* Delete a function tool (agent-scoped)
|
|
86
|
-
*/
|
|
87
|
-
declare const deleteFunctionTool: (db: DatabaseClient) => (params: {
|
|
88
|
-
scopes: AgentScopeConfig;
|
|
89
|
-
functionToolId: string;
|
|
90
|
-
}) => Promise<boolean>;
|
|
91
|
-
/**
|
|
92
|
-
* Upsert a function tool (create if it doesn't exist, update if it does)
|
|
93
|
-
*/
|
|
94
|
-
declare const upsertFunctionTool: (db: DatabaseClient) => (params: {
|
|
95
|
-
data: FunctionToolApiInsert;
|
|
96
|
-
scopes: AgentScopeConfig;
|
|
97
|
-
}) => Promise<{
|
|
98
|
-
tenantId: string;
|
|
99
|
-
projectId: string;
|
|
100
|
-
id: string;
|
|
101
|
-
name: string;
|
|
102
|
-
description: string | null;
|
|
103
|
-
agentId: string;
|
|
104
|
-
createdAt: string;
|
|
105
|
-
updatedAt: string;
|
|
106
|
-
functionId: string;
|
|
107
|
-
}>;
|
|
108
|
-
declare const getFunctionToolsForSubAgent: (db: DatabaseClient) => (params: {
|
|
109
|
-
scopes: {
|
|
110
|
-
tenantId: string;
|
|
111
|
-
projectId: string;
|
|
112
|
-
agentId: string;
|
|
113
|
-
};
|
|
114
|
-
subAgentId: string;
|
|
115
|
-
}) => Promise<{
|
|
116
|
-
data: {
|
|
117
|
-
createdAt: string;
|
|
118
|
-
updatedAt: string;
|
|
119
|
-
name: string;
|
|
120
|
-
description: string | null;
|
|
121
|
-
functionId: string;
|
|
122
|
-
agentId: string;
|
|
123
|
-
projectId: string;
|
|
124
|
-
tenantId: string;
|
|
125
|
-
id: string;
|
|
126
|
-
}[];
|
|
127
|
-
pagination: {
|
|
128
|
-
page: number;
|
|
129
|
-
limit: number;
|
|
130
|
-
total: number;
|
|
131
|
-
pages: number;
|
|
132
|
-
};
|
|
133
|
-
}>;
|
|
134
|
-
/**
|
|
135
|
-
* Upsert a sub_agent-function tool relation (create if it doesn't exist, update if it does)
|
|
136
|
-
*/
|
|
137
|
-
declare const upsertSubAgentFunctionToolRelation: (db: DatabaseClient) => (params: {
|
|
138
|
-
scopes: AgentScopeConfig;
|
|
139
|
-
subAgentId: string;
|
|
140
|
-
functionToolId: string;
|
|
141
|
-
relationId?: string;
|
|
142
|
-
}) => Promise<{
|
|
143
|
-
id: string;
|
|
144
|
-
}>;
|
|
145
|
-
/**
|
|
146
|
-
* Add a function tool to an agent
|
|
147
|
-
*/
|
|
148
|
-
declare const addFunctionToolToSubAgent: (db: DatabaseClient) => (params: {
|
|
149
|
-
scopes: AgentScopeConfig;
|
|
150
|
-
subAgentId: string;
|
|
151
|
-
functionToolId: string;
|
|
152
|
-
}) => Promise<{
|
|
153
|
-
id: string;
|
|
154
|
-
}>;
|
|
155
|
-
/**
|
|
156
|
-
* Update an agent-function tool relation
|
|
157
|
-
*/
|
|
158
|
-
declare const updateSubAgentFunctionToolRelation: (db: DatabaseClient) => (params: {
|
|
159
|
-
scopes: AgentScopeConfig;
|
|
160
|
-
relationId: string;
|
|
161
|
-
data: {
|
|
162
|
-
subAgentId: string;
|
|
163
|
-
functionToolId: string;
|
|
164
|
-
};
|
|
165
|
-
}) => Promise<{
|
|
166
|
-
id: string;
|
|
167
|
-
}>;
|
|
168
|
-
//#endregion
|
|
169
|
-
export { addFunctionToolToSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, listFunctionTools, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FullProjectDefinition } from "../types/entities.js";
|
|
2
|
-
import { getLogger } from "../utils/logger.js";
|
|
3
|
-
import { ProjectScopeConfig } from "../types/utility.js";
|
|
4
|
-
import { DatabaseClient } from "../db/client.js";
|
|
5
|
-
|
|
6
|
-
//#region src/data-access/projectFull.d.ts
|
|
7
|
-
|
|
8
|
-
type ProjectLogger = ReturnType<typeof getLogger>;
|
|
9
|
-
/**
|
|
10
|
-
* Server-side implementation of createFullProject that performs actual database operations.
|
|
11
|
-
* This function creates a complete project with all agent and their nested resources.
|
|
12
|
-
*/
|
|
13
|
-
declare const createFullProjectServerSide: (db: DatabaseClient, logger?: ProjectLogger) => (scopes: ProjectScopeConfig, projectData: FullProjectDefinition) => Promise<FullProjectDefinition>;
|
|
14
|
-
/**
|
|
15
|
-
* Server-side implementation of updateFullProject that performs actual database operations.
|
|
16
|
-
* This function updates a complete project with all agent and their nested resources.
|
|
17
|
-
*/
|
|
18
|
-
declare const updateFullProjectServerSide: (db: DatabaseClient, logger?: ProjectLogger) => (scopes: ProjectScopeConfig, projectData: FullProjectDefinition) => Promise<FullProjectDefinition>;
|
|
19
|
-
/**
|
|
20
|
-
* Get a complete project definition with all nested resources
|
|
21
|
-
*/
|
|
22
|
-
declare const getFullProject: (db: DatabaseClient, logger?: ProjectLogger) => (params: {
|
|
23
|
-
scopes: ProjectScopeConfig;
|
|
24
|
-
}) => Promise<FullProjectDefinition | null>;
|
|
25
|
-
/**
|
|
26
|
-
* Delete a complete project and cascade to all related entities
|
|
27
|
-
*/
|
|
28
|
-
declare const deleteFullProject: (db: DatabaseClient, logger?: ProjectLogger) => (params: {
|
|
29
|
-
scopes: ProjectScopeConfig;
|
|
30
|
-
}) => Promise<boolean>;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { ProjectLogger, createFullProjectServerSide, deleteFullProject, getFullProject, updateFullProjectServerSide };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ProjectInsert, ProjectSelect, ProjectUpdate } from "../types/entities.js";
|
|
2
|
-
import { PaginationConfig, PaginationResult, ProjectInfo, ProjectResourceCounts, ProjectScopeConfig } from "../types/utility.js";
|
|
3
|
-
import { DatabaseClient } from "../db/client.js";
|
|
4
|
-
|
|
5
|
-
//#region src/data-access/projects.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* List all unique project IDs within a tenant by scanning all resource tables
|
|
9
|
-
*/
|
|
10
|
-
declare const listProjects: (db: DatabaseClient) => (params: {
|
|
11
|
-
tenantId: string;
|
|
12
|
-
}) => Promise<ProjectInfo[]>;
|
|
13
|
-
/**
|
|
14
|
-
* List all unique project IDs within a tenant with pagination
|
|
15
|
-
*/
|
|
16
|
-
declare const listProjectsPaginated: (db: DatabaseClient) => (params: {
|
|
17
|
-
tenantId: string;
|
|
18
|
-
pagination?: PaginationConfig;
|
|
19
|
-
}) => Promise<{
|
|
20
|
-
data: ProjectSelect[];
|
|
21
|
-
pagination: PaginationResult;
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* Get resource counts for a specific project
|
|
25
|
-
*/
|
|
26
|
-
declare const getProjectResourceCounts: (db: DatabaseClient) => (params: ProjectScopeConfig) => Promise<ProjectResourceCounts>;
|
|
27
|
-
/**
|
|
28
|
-
* Check if a project exists (has any resources)
|
|
29
|
-
*/
|
|
30
|
-
declare const projectExists: (db: DatabaseClient) => (params: ProjectScopeConfig) => Promise<boolean>;
|
|
31
|
-
/**
|
|
32
|
-
* Count total projects for a tenant
|
|
33
|
-
*/
|
|
34
|
-
declare const countProjects: (db: DatabaseClient) => (params: {
|
|
35
|
-
tenantId: string;
|
|
36
|
-
}) => Promise<number>;
|
|
37
|
-
/**
|
|
38
|
-
* Get a single project by ID
|
|
39
|
-
*/
|
|
40
|
-
declare const getProject: (db: DatabaseClient) => (params: {
|
|
41
|
-
scopes: ProjectScopeConfig;
|
|
42
|
-
}) => Promise<ProjectSelect | null>;
|
|
43
|
-
/**
|
|
44
|
-
* Create a new project
|
|
45
|
-
*/
|
|
46
|
-
declare const createProject: (db: DatabaseClient) => (params: ProjectInsert) => Promise<ProjectSelect>;
|
|
47
|
-
/**
|
|
48
|
-
* Update an existing project
|
|
49
|
-
*/
|
|
50
|
-
declare const updateProject: (db: DatabaseClient) => (params: {
|
|
51
|
-
scopes: ProjectScopeConfig;
|
|
52
|
-
data: ProjectUpdate;
|
|
53
|
-
}) => Promise<ProjectSelect | null>;
|
|
54
|
-
/**
|
|
55
|
-
* Check if a project exists in the projects table
|
|
56
|
-
*/
|
|
57
|
-
declare const projectExistsInTable: (db: DatabaseClient) => (params: {
|
|
58
|
-
scopes: ProjectScopeConfig;
|
|
59
|
-
}) => Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Check if a project has any resources (used before deletion)
|
|
62
|
-
*/
|
|
63
|
-
declare const projectHasResources: (db: DatabaseClient) => (params: ProjectScopeConfig) => Promise<boolean>;
|
|
64
|
-
/**
|
|
65
|
-
* Delete a project (with validation for existing resources)
|
|
66
|
-
*/
|
|
67
|
-
declare const deleteProject: (db: DatabaseClient) => (params: {
|
|
68
|
-
scopes: ProjectScopeConfig;
|
|
69
|
-
}) => Promise<boolean>;
|
|
70
|
-
//#endregion
|
|
71
|
-
export { countProjects, createProject, deleteProject, getProject, getProjectResourceCounts, listProjects, listProjectsPaginated, projectExists, projectExistsInTable, projectHasResources, updateProject };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { TaskInsert, TaskSelect } from "../types/entities.js";
|
|
2
|
-
import "../types/index.js";
|
|
3
|
-
import "../index.js";
|
|
4
|
-
import { TaskMetadataConfig } from "../types/utility.js";
|
|
5
|
-
import { DatabaseClient } from "../db/client.js";
|
|
6
|
-
|
|
7
|
-
//#region src/data-access/tasks.d.ts
|
|
8
|
-
declare const createTask: (db: DatabaseClient) => (params: TaskInsert) => Promise<{
|
|
9
|
-
tenantId: string;
|
|
10
|
-
projectId: string;
|
|
11
|
-
id: string;
|
|
12
|
-
agentId: string;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
updatedAt: string;
|
|
15
|
-
metadata: TaskMetadataConfig | null;
|
|
16
|
-
status: string;
|
|
17
|
-
subAgentId: string;
|
|
18
|
-
contextId: string;
|
|
19
|
-
}>;
|
|
20
|
-
declare const getTask: (db: DatabaseClient) => (params: {
|
|
21
|
-
id: string;
|
|
22
|
-
}) => Promise<TaskSelect | null>;
|
|
23
|
-
declare const updateTask: (db: DatabaseClient) => (params: {
|
|
24
|
-
taskId: string;
|
|
25
|
-
data: {
|
|
26
|
-
status?: string;
|
|
27
|
-
metadata?: any;
|
|
28
|
-
};
|
|
29
|
-
}) => Promise<{
|
|
30
|
-
createdAt: string;
|
|
31
|
-
updatedAt: string;
|
|
32
|
-
contextId: string;
|
|
33
|
-
status: string;
|
|
34
|
-
metadata: TaskMetadataConfig | null;
|
|
35
|
-
subAgentId: string;
|
|
36
|
-
agentId: string;
|
|
37
|
-
projectId: string;
|
|
38
|
-
tenantId: string;
|
|
39
|
-
id: string;
|
|
40
|
-
}>;
|
|
41
|
-
declare const listTaskIdsByContextId: (db: DatabaseClient) => (params: {
|
|
42
|
-
contextId: string;
|
|
43
|
-
}) => Promise<string[]>;
|
|
44
|
-
//#endregion
|
|
45
|
-
export { createTask, getTask, listTaskIdsByContextId, updateTask };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { User } from "../auth/auth-validation-schemas.js";
|
|
2
|
-
import { DatabaseClient } from "../db/client.js";
|
|
3
|
-
|
|
4
|
-
//#region src/data-access/users.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* User data access layer
|
|
8
|
-
* All database queries for Better Auth's user table
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Get user by ID
|
|
12
|
-
*/
|
|
13
|
-
declare const getUserById: (db: DatabaseClient) => (userId: string) => Promise<User | null>;
|
|
14
|
-
/**
|
|
15
|
-
* Get user by email
|
|
16
|
-
*/
|
|
17
|
-
declare const getUserByEmail: (db: DatabaseClient) => (email: string) => Promise<User | null>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { getUserByEmail, getUserById };
|
package/dist/db/client.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { schema_d_exports } from "./schema.js";
|
|
2
|
-
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
-
import { PgliteDatabase } from "drizzle-orm/pglite";
|
|
4
|
-
|
|
5
|
-
//#region src/db/client.d.ts
|
|
6
|
-
type DatabaseClient = NodePgDatabase<typeof schema_d_exports> | PgliteDatabase<typeof schema_d_exports>;
|
|
7
|
-
interface DatabaseConfig {
|
|
8
|
-
connectionString?: string;
|
|
9
|
-
poolSize?: number;
|
|
10
|
-
ssl?: boolean;
|
|
11
|
-
logger?: {
|
|
12
|
-
logQuery: (query: string, params: unknown[]) => void;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Creates a PostgreSQL database client with connection pooling
|
|
17
|
-
*/
|
|
18
|
-
declare function createDatabaseClient(config?: DatabaseConfig): DatabaseClient;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { DatabaseClient, DatabaseConfig, createDatabaseClient };
|
package/dist/db/client.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { schema_exports } from "./schema.js";
|
|
2
|
-
import { env, loadEnvironmentFiles } from "../env.js";
|
|
3
|
-
import { drizzle } from "drizzle-orm/node-postgres";
|
|
4
|
-
import { Pool } from "pg";
|
|
5
|
-
|
|
6
|
-
//#region src/db/client.ts
|
|
7
|
-
loadEnvironmentFiles();
|
|
8
|
-
/**
|
|
9
|
-
* Creates a PostgreSQL database client with connection pooling
|
|
10
|
-
*/
|
|
11
|
-
function createDatabaseClient(config = {}) {
|
|
12
|
-
const connectionString = config.connectionString || process.env.DATABASE_URL;
|
|
13
|
-
if (!connectionString) throw new Error("DATABASE_URL environment variable is required. Please set it to your PostgreSQL connection string.");
|
|
14
|
-
const pool = new Pool({
|
|
15
|
-
connectionString,
|
|
16
|
-
max: config.poolSize || Number(env.POSTGRES_POOL_SIZE) || 10
|
|
17
|
-
});
|
|
18
|
-
pool.on("error", (err) => {
|
|
19
|
-
console.error("Unexpected PostgreSQL pool error:", err);
|
|
20
|
-
});
|
|
21
|
-
return drizzle(pool, {
|
|
22
|
-
schema: schema_exports,
|
|
23
|
-
logger: config.logger
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { createDatabaseClient };
|
package/dist/db/test-client.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { DatabaseClient } from "./client.js";
|
|
2
|
-
|
|
3
|
-
//#region src/db/test-client.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Creates a test database client using an in-memory PostgreSQL database (PGlite)
|
|
7
|
-
* This provides real database operations for integration testing with perfect isolation
|
|
8
|
-
* Each call creates a fresh database with all migrations applied
|
|
9
|
-
*/
|
|
10
|
-
declare function createTestDatabaseClient(drizzleDir?: string): Promise<DatabaseClient>;
|
|
11
|
-
/**
|
|
12
|
-
* Cleans up test database by removing all data but keeping schema
|
|
13
|
-
* Dynamically gets all tables from the public schema and truncates them
|
|
14
|
-
*/
|
|
15
|
-
declare function cleanupTestDatabase(db: DatabaseClient): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Closes the test database and removes the file
|
|
18
|
-
*/
|
|
19
|
-
declare function closeTestDatabase(db: DatabaseClient): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a test organization in the database
|
|
22
|
-
* This is a helper for tests that need organization records before creating projects/agents
|
|
23
|
-
*/
|
|
24
|
-
declare function createTestOrganization(db: DatabaseClient, tenantId: string): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a test project in the database
|
|
27
|
-
* Ensures the organization exists first
|
|
28
|
-
*/
|
|
29
|
-
declare function createTestProject(db: DatabaseClient, tenantId: string, projectId?: string): Promise<void>;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { cleanupTestDatabase, closeTestDatabase, createTestDatabaseClient, createTestOrganization, createTestProject };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { CredentialStoreRegistry } from "../credential-stores/CredentialStoreRegistry.js";
|
|
2
|
-
import { DatabaseClient } from "../db/client.js";
|
|
3
|
-
import { ValidateFunction } from "ajv";
|
|
4
|
-
import { Context, Next } from "hono";
|
|
5
|
-
|
|
6
|
-
//#region src/middleware/contextValidation.d.ts
|
|
7
|
-
declare const HTTP_REQUEST_PARTS: readonly ["headers"];
|
|
8
|
-
type HttpRequestPart = (typeof HTTP_REQUEST_PARTS)[number];
|
|
9
|
-
interface ContextValidationError {
|
|
10
|
-
field: string;
|
|
11
|
-
message: string;
|
|
12
|
-
value?: unknown;
|
|
13
|
-
}
|
|
14
|
-
interface ContextValidationResult {
|
|
15
|
-
valid: boolean;
|
|
16
|
-
errors: ContextValidationError[];
|
|
17
|
-
validatedContext?: Record<string, unknown> | ParsedHttpRequest;
|
|
18
|
-
}
|
|
19
|
-
interface ParsedHttpRequest {
|
|
20
|
-
headers?: Record<string, string>;
|
|
21
|
-
}
|
|
22
|
-
declare function isValidHttpRequest(obj: any): obj is ParsedHttpRequest;
|
|
23
|
-
declare function getCachedValidator(schema: Record<string, unknown>): ValidateFunction;
|
|
24
|
-
declare function validationHelper(jsonSchema: Record<string, unknown>): ValidateFunction<unknown>;
|
|
25
|
-
declare function validateAgainstJsonSchema(jsonSchema: Record<string, unknown>, context: unknown): boolean;
|
|
26
|
-
declare function validateHttpRequestHeaders(headersSchema: any, httpRequest: ParsedHttpRequest): Promise<ContextValidationResult>;
|
|
27
|
-
declare function validateHeaders({
|
|
28
|
-
tenantId,
|
|
29
|
-
projectId,
|
|
30
|
-
agentId,
|
|
31
|
-
conversationId,
|
|
32
|
-
parsedRequest,
|
|
33
|
-
dbClient,
|
|
34
|
-
credentialStores
|
|
35
|
-
}: {
|
|
36
|
-
tenantId: string;
|
|
37
|
-
projectId: string;
|
|
38
|
-
agentId: string;
|
|
39
|
-
conversationId: string;
|
|
40
|
-
parsedRequest: ParsedHttpRequest;
|
|
41
|
-
dbClient: DatabaseClient;
|
|
42
|
-
credentialStores?: CredentialStoreRegistry;
|
|
43
|
-
}): Promise<ContextValidationResult>;
|
|
44
|
-
declare function contextValidationMiddleware(dbClient: DatabaseClient): (c: Context, next: Next) => Promise<void>;
|
|
45
|
-
//#endregion
|
|
46
|
-
export { ContextValidationError, ContextValidationResult, HTTP_REQUEST_PARTS, HttpRequestPart, ParsedHttpRequest, contextValidationMiddleware, getCachedValidator, isValidHttpRequest, validateAgainstJsonSchema, validateHeaders, validateHttpRequestHeaders, validationHelper };
|