@inkeep/agents-core 0.0.0-dev-20250916190005 → 0.0.0-dev-20250917200022
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/index.cjs +59 -2
- package/dist/index.js +55 -3
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -23,12 +23,22 @@ var ai = require('ai');
|
|
|
23
23
|
var exitHook = require('exit-hook');
|
|
24
24
|
var tsPattern = require('ts-pattern');
|
|
25
25
|
var node = require('@nangohq/node');
|
|
26
|
+
var fs = require('fs');
|
|
27
|
+
var os = require('os');
|
|
28
|
+
var path = require('path');
|
|
29
|
+
var dotenv = require('dotenv');
|
|
30
|
+
var dotenvExpand = require('dotenv-expand');
|
|
31
|
+
var findUp = require('find-up');
|
|
26
32
|
|
|
27
33
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
34
|
|
|
29
35
|
var jmespath__default = /*#__PURE__*/_interopDefault(jmespath);
|
|
30
36
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
31
37
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
38
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
39
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
40
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
41
|
+
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
32
42
|
|
|
33
43
|
var __defProp = Object.defineProperty;
|
|
34
44
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -1939,8 +1949,8 @@ var _TemplateEngine = class _TemplateEngine {
|
|
|
1939
1949
|
* Process variable substitutions {{variable.path}} using JMESPath
|
|
1940
1950
|
*/
|
|
1941
1951
|
static processVariables(template, context, options) {
|
|
1942
|
-
return template.replace(/\{\{([^}]+)\}\}/g, (match2,
|
|
1943
|
-
const trimmedPath =
|
|
1952
|
+
return template.replace(/\{\{([^}]+)\}\}/g, (match2, path2) => {
|
|
1953
|
+
const trimmedPath = path2.trim();
|
|
1944
1954
|
try {
|
|
1945
1955
|
if (trimmedPath.startsWith("$")) {
|
|
1946
1956
|
return _TemplateEngine.processBuiltinVariable(trimmedPath);
|
|
@@ -10190,6 +10200,52 @@ function createDefaultCredentialStores() {
|
|
|
10190
10200
|
stores.push(createKeyChainStore("keychain-default"));
|
|
10191
10201
|
return stores;
|
|
10192
10202
|
}
|
|
10203
|
+
var loadEnvironmentFiles = () => {
|
|
10204
|
+
const environmentFiles = [];
|
|
10205
|
+
const currentEnv = path__default.default.resolve(process.cwd(), ".env");
|
|
10206
|
+
if (fs__default.default.existsSync(currentEnv)) {
|
|
10207
|
+
environmentFiles.push(currentEnv);
|
|
10208
|
+
}
|
|
10209
|
+
const rootEnv = findUp.findUpSync(".env", { cwd: path__default.default.dirname(process.cwd()) });
|
|
10210
|
+
if (rootEnv) {
|
|
10211
|
+
if (rootEnv !== currentEnv) {
|
|
10212
|
+
environmentFiles.push(rootEnv);
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
const userConfigPath = path__default.default.join(os__default.default.homedir(), ".inkeep", "config");
|
|
10216
|
+
if (fs__default.default.existsSync(userConfigPath)) {
|
|
10217
|
+
dotenv__default.default.config({ path: userConfigPath, override: true });
|
|
10218
|
+
}
|
|
10219
|
+
if (environmentFiles.length > 0) {
|
|
10220
|
+
dotenv__default.default.config({
|
|
10221
|
+
path: environmentFiles,
|
|
10222
|
+
override: false
|
|
10223
|
+
});
|
|
10224
|
+
dotenvExpand.expand({ processEnv: process.env });
|
|
10225
|
+
}
|
|
10226
|
+
};
|
|
10227
|
+
loadEnvironmentFiles();
|
|
10228
|
+
var envSchema = zod.z.object({
|
|
10229
|
+
ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional(),
|
|
10230
|
+
DB_FILE_NAME: zod.z.string(),
|
|
10231
|
+
OTEL_TRACES_FORCE_FLUSH_ENABLED: zod.z.coerce.boolean().optional()
|
|
10232
|
+
});
|
|
10233
|
+
var parseEnv = () => {
|
|
10234
|
+
try {
|
|
10235
|
+
const parsedEnv = envSchema.parse(process.env);
|
|
10236
|
+
return parsedEnv;
|
|
10237
|
+
} catch (error) {
|
|
10238
|
+
if (error instanceof zod.z.ZodError) {
|
|
10239
|
+
const missingVars = error.issues.map((issue) => issue.path.join("."));
|
|
10240
|
+
throw new Error(
|
|
10241
|
+
`\u274C Invalid environment variables: ${missingVars.join(", ")}
|
|
10242
|
+
${error.message}`
|
|
10243
|
+
);
|
|
10244
|
+
}
|
|
10245
|
+
throw error;
|
|
10246
|
+
}
|
|
10247
|
+
};
|
|
10248
|
+
parseEnv();
|
|
10193
10249
|
|
|
10194
10250
|
// src/validation/id-validation.ts
|
|
10195
10251
|
function isValidResourceId(id) {
|
|
@@ -10613,6 +10669,7 @@ exports.listProjectsPaginated = listProjectsPaginated;
|
|
|
10613
10669
|
exports.listTaskIdsByContextId = listTaskIdsByContextId;
|
|
10614
10670
|
exports.listTools = listTools;
|
|
10615
10671
|
exports.listToolsByStatus = listToolsByStatus;
|
|
10672
|
+
exports.loadEnvironmentFiles = loadEnvironmentFiles;
|
|
10616
10673
|
exports.loggerFactory = loggerFactory;
|
|
10617
10674
|
exports.maskApiKey = maskApiKey;
|
|
10618
10675
|
exports.messages = messages;
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,12 @@ import { tool } from 'ai';
|
|
|
29
29
|
import { asyncExitHook, gracefulExit } from 'exit-hook';
|
|
30
30
|
import { match } from 'ts-pattern';
|
|
31
31
|
import { Nango } from '@nangohq/node';
|
|
32
|
+
import fs from 'fs';
|
|
33
|
+
import os from 'os';
|
|
34
|
+
import path from 'path';
|
|
35
|
+
import dotenv from 'dotenv';
|
|
36
|
+
import { expand } from 'dotenv-expand';
|
|
37
|
+
import { findUpSync } from 'find-up';
|
|
32
38
|
|
|
33
39
|
// src/utils/logger.ts
|
|
34
40
|
var ConsoleLogger = class {
|
|
@@ -418,8 +424,8 @@ var _TemplateEngine = class _TemplateEngine {
|
|
|
418
424
|
* Process variable substitutions {{variable.path}} using JMESPath
|
|
419
425
|
*/
|
|
420
426
|
static processVariables(template, context, options) {
|
|
421
|
-
return template.replace(/\{\{([^}]+)\}\}/g, (match2,
|
|
422
|
-
const trimmedPath =
|
|
427
|
+
return template.replace(/\{\{([^}]+)\}\}/g, (match2, path2) => {
|
|
428
|
+
const trimmedPath = path2.trim();
|
|
423
429
|
try {
|
|
424
430
|
if (trimmedPath.startsWith("$")) {
|
|
425
431
|
return _TemplateEngine.processBuiltinVariable(trimmedPath);
|
|
@@ -8550,5 +8556,51 @@ function createDefaultCredentialStores() {
|
|
|
8550
8556
|
stores.push(createKeyChainStore("keychain-default"));
|
|
8551
8557
|
return stores;
|
|
8552
8558
|
}
|
|
8559
|
+
var loadEnvironmentFiles = () => {
|
|
8560
|
+
const environmentFiles = [];
|
|
8561
|
+
const currentEnv = path.resolve(process.cwd(), ".env");
|
|
8562
|
+
if (fs.existsSync(currentEnv)) {
|
|
8563
|
+
environmentFiles.push(currentEnv);
|
|
8564
|
+
}
|
|
8565
|
+
const rootEnv = findUpSync(".env", { cwd: path.dirname(process.cwd()) });
|
|
8566
|
+
if (rootEnv) {
|
|
8567
|
+
if (rootEnv !== currentEnv) {
|
|
8568
|
+
environmentFiles.push(rootEnv);
|
|
8569
|
+
}
|
|
8570
|
+
}
|
|
8571
|
+
const userConfigPath = path.join(os.homedir(), ".inkeep", "config");
|
|
8572
|
+
if (fs.existsSync(userConfigPath)) {
|
|
8573
|
+
dotenv.config({ path: userConfigPath, override: true });
|
|
8574
|
+
}
|
|
8575
|
+
if (environmentFiles.length > 0) {
|
|
8576
|
+
dotenv.config({
|
|
8577
|
+
path: environmentFiles,
|
|
8578
|
+
override: false
|
|
8579
|
+
});
|
|
8580
|
+
expand({ processEnv: process.env });
|
|
8581
|
+
}
|
|
8582
|
+
};
|
|
8583
|
+
loadEnvironmentFiles();
|
|
8584
|
+
var envSchema = z$1.object({
|
|
8585
|
+
ENVIRONMENT: z$1.enum(["development", "production", "pentest", "test"]).optional(),
|
|
8586
|
+
DB_FILE_NAME: z$1.string(),
|
|
8587
|
+
OTEL_TRACES_FORCE_FLUSH_ENABLED: z$1.coerce.boolean().optional()
|
|
8588
|
+
});
|
|
8589
|
+
var parseEnv = () => {
|
|
8590
|
+
try {
|
|
8591
|
+
const parsedEnv = envSchema.parse(process.env);
|
|
8592
|
+
return parsedEnv;
|
|
8593
|
+
} catch (error) {
|
|
8594
|
+
if (error instanceof z$1.ZodError) {
|
|
8595
|
+
const missingVars = error.issues.map((issue) => issue.path.join("."));
|
|
8596
|
+
throw new Error(
|
|
8597
|
+
`\u274C Invalid environment variables: ${missingVars.join(", ")}
|
|
8598
|
+
${error.message}`
|
|
8599
|
+
);
|
|
8600
|
+
}
|
|
8601
|
+
throw error;
|
|
8602
|
+
}
|
|
8603
|
+
};
|
|
8604
|
+
parseEnv();
|
|
8553
8605
|
|
|
8554
|
-
export { ConsoleLogger, ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, NoOpLogger, TemplateEngine, addLedgerArtifacts, addToolToAgent, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, configureLogging, 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, getAgentGraph, getAgentGraphById, getAgentGraphWithDefaultAgent, getAgentInGraphContext, 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, listAgentToolRelationsByAgent, listAgents, listAgentsPaginated, listApiKeys, listApiKeysPaginated, listArtifactComponents, listArtifactComponentsPaginated, listContextConfigs, listContextConfigsPaginated, listConversations, listCredentialReferences, listCredentialReferencesPaginated, listDataComponents, listDataComponentsPaginated, listExternalAgents, listExternalAgentsPaginated, listMessages, listProjects, listProjectsPaginated, listTaskIdsByContextId, listTools, listToolsByStatus, loggerFactory, maskApiKey, problemDetailsSchema, projectExists, projectExistsInTable, projectHasResources, removeArtifactComponentFromAgent, removeDataComponentFromAgent, removeToolFromAgent, 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 };
|
|
8606
|
+
export { ConsoleLogger, ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, NoOpLogger, TemplateEngine, addLedgerArtifacts, addToolToAgent, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, configureLogging, 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, getAgentGraph, getAgentGraphById, getAgentGraphWithDefaultAgent, getAgentInGraphContext, 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, listAgentToolRelationsByAgent, 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, 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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-core",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20250917200022",
|
|
4
4
|
"description": "Agents Core contains the database schema, types, and validation schemas for Inkeep Agent Framework, along with core components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -37,9 +37,11 @@
|
|
|
37
37
|
"ajv": "^8.17.1",
|
|
38
38
|
"ajv-formats": "^3.0.1",
|
|
39
39
|
"dotenv": "^17.2.1",
|
|
40
|
+
"dotenv-expand": "^12.0.3",
|
|
40
41
|
"drizzle-orm": "^0.44.4",
|
|
41
42
|
"drizzle-zod": "^0.8.2",
|
|
42
43
|
"exit-hook": "^4.0.0",
|
|
44
|
+
"find-up": "^7.0.0",
|
|
43
45
|
"hono": "^4.9.7",
|
|
44
46
|
"jmespath": "^0.16.0",
|
|
45
47
|
"keytar": "^7.9.0",
|