@inkeep/agents-core 0.6.0 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +108 -48
- package/dist/index.js +108 -49
- package/package.json +17 -5
package/dist/index.cjs
CHANGED
|
@@ -1813,6 +1813,22 @@ var PaginationQueryParamsSchema = zodOpenapi.z.object({
|
|
|
1813
1813
|
|
|
1814
1814
|
// src/context/ContextConfig.ts
|
|
1815
1815
|
var logger = getLogger("context-config");
|
|
1816
|
+
var RequestContextSchemaBuilder = class {
|
|
1817
|
+
constructor(options) {
|
|
1818
|
+
__publicField(this, "schema");
|
|
1819
|
+
this.schema = options.schema;
|
|
1820
|
+
}
|
|
1821
|
+
/** Template function for request context paths with type-safe autocomplete */
|
|
1822
|
+
toTemplate(path2) {
|
|
1823
|
+
return `{{requestContext.${path2}}}`;
|
|
1824
|
+
}
|
|
1825
|
+
getSchema() {
|
|
1826
|
+
return this.schema;
|
|
1827
|
+
}
|
|
1828
|
+
getJsonSchema() {
|
|
1829
|
+
return convertZodToJsonSchema(this.schema);
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1816
1832
|
function convertZodToJsonSchema(zodSchema) {
|
|
1817
1833
|
try {
|
|
1818
1834
|
return zod.z.toJSONSchema(zodSchema, { target: "draft-7" });
|
|
@@ -1835,23 +1851,34 @@ var ContextConfigBuilder = class {
|
|
|
1835
1851
|
this.tenantId = options.tenantId || "default";
|
|
1836
1852
|
this.projectId = options.projectId || "default";
|
|
1837
1853
|
this.baseURL = process.env.INKEEP_AGENTS_MANAGE_API_URL || "http://localhost:3002";
|
|
1838
|
-
let
|
|
1854
|
+
let requestContextSchema2;
|
|
1839
1855
|
if (options.requestContextSchema) {
|
|
1856
|
+
const actualSchema = options.requestContextSchema instanceof RequestContextSchemaBuilder ? options.requestContextSchema.getSchema() : options.requestContextSchema;
|
|
1840
1857
|
logger.info(
|
|
1841
1858
|
{
|
|
1842
1859
|
requestContextSchema: options.requestContextSchema
|
|
1843
1860
|
},
|
|
1844
1861
|
"Converting request headers schema to JSON Schema for database storage"
|
|
1845
1862
|
);
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1863
|
+
requestContextSchema2 = convertZodToJsonSchema(actualSchema);
|
|
1864
|
+
}
|
|
1865
|
+
const processedContextVariables = {};
|
|
1866
|
+
if (options.contextVariables) {
|
|
1867
|
+
for (const [key, definition] of Object.entries(options.contextVariables)) {
|
|
1868
|
+
const { credentialReference, ...rest } = definition;
|
|
1869
|
+
processedContextVariables[key] = {
|
|
1870
|
+
...rest,
|
|
1871
|
+
responseSchema: convertZodToJsonSchema(definition.responseSchema),
|
|
1872
|
+
credentialReferenceId: credentialReference?.id
|
|
1873
|
+
};
|
|
1849
1874
|
logger.debug(
|
|
1850
|
-
{
|
|
1851
|
-
|
|
1875
|
+
{
|
|
1876
|
+
contextVariableKey: key,
|
|
1877
|
+
originalSchema: definition.responseSchema
|
|
1878
|
+
},
|
|
1879
|
+
"Converting contextVariable responseSchema to JSON Schema for database storage"
|
|
1852
1880
|
);
|
|
1853
1881
|
}
|
|
1854
|
-
requestContextSchema = convertZodToJsonSchema(schema);
|
|
1855
1882
|
}
|
|
1856
1883
|
this.config = {
|
|
1857
1884
|
id: options.id,
|
|
@@ -1859,8 +1886,8 @@ var ContextConfigBuilder = class {
|
|
|
1859
1886
|
projectId: this.projectId,
|
|
1860
1887
|
name: options.name,
|
|
1861
1888
|
description: options.description || "",
|
|
1862
|
-
requestContextSchema,
|
|
1863
|
-
contextVariables:
|
|
1889
|
+
requestContextSchema: requestContextSchema2,
|
|
1890
|
+
contextVariables: processedContextVariables
|
|
1864
1891
|
};
|
|
1865
1892
|
logger.info(
|
|
1866
1893
|
{
|
|
@@ -1870,6 +1897,22 @@ var ContextConfigBuilder = class {
|
|
|
1870
1897
|
"ContextConfig builder initialized"
|
|
1871
1898
|
);
|
|
1872
1899
|
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Convert the builder to a plain object for database operations
|
|
1902
|
+
*/
|
|
1903
|
+
toObject() {
|
|
1904
|
+
return {
|
|
1905
|
+
id: this.getId(),
|
|
1906
|
+
tenantId: this.tenantId,
|
|
1907
|
+
projectId: this.projectId,
|
|
1908
|
+
name: this.getName(),
|
|
1909
|
+
description: this.getDescription(),
|
|
1910
|
+
requestContextSchema: this.getRequestContextSchema(),
|
|
1911
|
+
contextVariables: this.getContextVariables(),
|
|
1912
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1913
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1914
|
+
};
|
|
1915
|
+
}
|
|
1873
1916
|
// Getter methods
|
|
1874
1917
|
getId() {
|
|
1875
1918
|
if (!this.config.id) {
|
|
@@ -1892,35 +1935,14 @@ var ContextConfigBuilder = class {
|
|
|
1892
1935
|
getContextVariables() {
|
|
1893
1936
|
return this.config.contextVariables || {};
|
|
1894
1937
|
}
|
|
1895
|
-
/**
|
|
1896
|
-
* Convert the builder to a plain object for database operations
|
|
1897
|
-
*/
|
|
1898
|
-
toObject() {
|
|
1899
|
-
return {
|
|
1900
|
-
id: this.getId(),
|
|
1901
|
-
tenantId: this.tenantId,
|
|
1902
|
-
projectId: this.projectId,
|
|
1903
|
-
name: this.getName(),
|
|
1904
|
-
description: this.getDescription(),
|
|
1905
|
-
requestContextSchema: this.getRequestContextSchema(),
|
|
1906
|
-
contextVariables: this.getContextVariables(),
|
|
1907
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1908
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1909
|
-
};
|
|
1910
|
-
}
|
|
1911
1938
|
// Builder methods for fluent API
|
|
1912
1939
|
withRequestContextSchema(schema) {
|
|
1913
1940
|
this.config.requestContextSchema = schema;
|
|
1914
1941
|
return this;
|
|
1915
1942
|
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
return this;
|
|
1920
|
-
}
|
|
1921
|
-
withContextVariables(variables) {
|
|
1922
|
-
this.config.contextVariables = variables;
|
|
1923
|
-
return this;
|
|
1943
|
+
/** 4) The function you ship: path autocomplete + validation, returns {{path}} */
|
|
1944
|
+
toTemplate(path2) {
|
|
1945
|
+
return `{{${path2}}}`;
|
|
1924
1946
|
}
|
|
1925
1947
|
// Validation method
|
|
1926
1948
|
validate() {
|
|
@@ -2065,15 +2087,11 @@ var ContextConfigBuilder = class {
|
|
|
2065
2087
|
function contextConfig(options) {
|
|
2066
2088
|
return new ContextConfigBuilder(options);
|
|
2067
2089
|
}
|
|
2090
|
+
function requestContextSchema(options) {
|
|
2091
|
+
return new RequestContextSchemaBuilder(options);
|
|
2092
|
+
}
|
|
2068
2093
|
function fetchDefinition(options) {
|
|
2069
|
-
const fetchConfig = options.fetchConfig
|
|
2070
|
-
url: options.url,
|
|
2071
|
-
method: options.method,
|
|
2072
|
-
headers: options.headers,
|
|
2073
|
-
body: options.body,
|
|
2074
|
-
transform: options.transform,
|
|
2075
|
-
timeout: options.timeout
|
|
2076
|
-
};
|
|
2094
|
+
const fetchConfig = options.fetchConfig;
|
|
2077
2095
|
return {
|
|
2078
2096
|
id: options.id,
|
|
2079
2097
|
name: options.name,
|
|
@@ -2086,9 +2104,9 @@ function fetchDefinition(options) {
|
|
|
2086
2104
|
transform: fetchConfig.transform,
|
|
2087
2105
|
timeout: fetchConfig.timeout
|
|
2088
2106
|
},
|
|
2089
|
-
responseSchema: options.responseSchema
|
|
2107
|
+
responseSchema: options.responseSchema,
|
|
2090
2108
|
defaultValue: options.defaultValue,
|
|
2091
|
-
credentialReferenceId: options.
|
|
2109
|
+
credentialReferenceId: options.credentialReference?.id
|
|
2092
2110
|
};
|
|
2093
2111
|
}
|
|
2094
2112
|
var logger2 = getLogger("template-engine");
|
|
@@ -8786,21 +8804,62 @@ var ContextResolver = class {
|
|
|
8786
8804
|
var logger7 = getLogger("context-validation");
|
|
8787
8805
|
var ajv = new Ajv__default.default({ allErrors: true, strict: false });
|
|
8788
8806
|
var HTTP_REQUEST_PARTS = ["headers"];
|
|
8807
|
+
var MAX_SCHEMA_CACHE_SIZE = 1e3;
|
|
8789
8808
|
var schemaCache = /* @__PURE__ */ new Map();
|
|
8790
8809
|
function isValidHttpRequest(obj) {
|
|
8791
8810
|
return obj != null && typeof obj === "object" && !Array.isArray(obj) && "headers" in obj;
|
|
8792
8811
|
}
|
|
8793
8812
|
function getCachedValidator(schema) {
|
|
8794
8813
|
const key = JSON.stringify(schema);
|
|
8795
|
-
if (
|
|
8796
|
-
schemaCache.
|
|
8814
|
+
if (schemaCache.has(key)) {
|
|
8815
|
+
const validator2 = schemaCache.get(key);
|
|
8816
|
+
if (!validator2) {
|
|
8817
|
+
throw new Error("Unexpected: validator not found in cache after has() check");
|
|
8818
|
+
}
|
|
8819
|
+
schemaCache.delete(key);
|
|
8820
|
+
schemaCache.set(key, validator2);
|
|
8821
|
+
return validator2;
|
|
8797
8822
|
}
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8823
|
+
if (schemaCache.size >= MAX_SCHEMA_CACHE_SIZE) {
|
|
8824
|
+
const firstKey = schemaCache.keys().next().value;
|
|
8825
|
+
if (firstKey) {
|
|
8826
|
+
schemaCache.delete(firstKey);
|
|
8827
|
+
}
|
|
8801
8828
|
}
|
|
8829
|
+
const permissiveSchema = makeSchemaPermissive(schema);
|
|
8830
|
+
const validator = ajv.compile(permissiveSchema);
|
|
8831
|
+
schemaCache.set(key, validator);
|
|
8802
8832
|
return validator;
|
|
8803
8833
|
}
|
|
8834
|
+
function makeSchemaPermissive(schema) {
|
|
8835
|
+
if (!schema || typeof schema !== "object") {
|
|
8836
|
+
return schema;
|
|
8837
|
+
}
|
|
8838
|
+
const permissiveSchema = { ...schema };
|
|
8839
|
+
if (permissiveSchema.type === "object") {
|
|
8840
|
+
permissiveSchema.additionalProperties = true;
|
|
8841
|
+
if (permissiveSchema.properties && typeof permissiveSchema.properties === "object") {
|
|
8842
|
+
const newProperties = {};
|
|
8843
|
+
for (const [key, value] of Object.entries(permissiveSchema.properties)) {
|
|
8844
|
+
newProperties[key] = makeSchemaPermissive(value);
|
|
8845
|
+
}
|
|
8846
|
+
permissiveSchema.properties = newProperties;
|
|
8847
|
+
}
|
|
8848
|
+
}
|
|
8849
|
+
if (permissiveSchema.type === "array" && permissiveSchema.items) {
|
|
8850
|
+
permissiveSchema.items = makeSchemaPermissive(permissiveSchema.items);
|
|
8851
|
+
}
|
|
8852
|
+
if (permissiveSchema.oneOf) {
|
|
8853
|
+
permissiveSchema.oneOf = permissiveSchema.oneOf.map(makeSchemaPermissive);
|
|
8854
|
+
}
|
|
8855
|
+
if (permissiveSchema.anyOf) {
|
|
8856
|
+
permissiveSchema.anyOf = permissiveSchema.anyOf.map(makeSchemaPermissive);
|
|
8857
|
+
}
|
|
8858
|
+
if (permissiveSchema.allOf) {
|
|
8859
|
+
permissiveSchema.allOf = permissiveSchema.allOf.map(makeSchemaPermissive);
|
|
8860
|
+
}
|
|
8861
|
+
return permissiveSchema;
|
|
8862
|
+
}
|
|
8804
8863
|
function validationHelper(jsonSchema) {
|
|
8805
8864
|
return getCachedValidator(jsonSchema);
|
|
8806
8865
|
}
|
|
@@ -10702,6 +10761,7 @@ exports.projectsRelations = projectsRelations;
|
|
|
10702
10761
|
exports.removeArtifactComponentFromAgent = removeArtifactComponentFromAgent;
|
|
10703
10762
|
exports.removeDataComponentFromAgent = removeDataComponentFromAgent;
|
|
10704
10763
|
exports.removeToolFromAgent = removeToolFromAgent;
|
|
10764
|
+
exports.requestContextSchema = requestContextSchema;
|
|
10705
10765
|
exports.resourceIdSchema = resourceIdSchema;
|
|
10706
10766
|
exports.setActiveAgentForConversation = setActiveAgentForConversation;
|
|
10707
10767
|
exports.setActiveAgentForThread = setActiveAgentForThread;
|
package/dist/index.js
CHANGED
|
@@ -197,6 +197,22 @@ function getLogger(name) {
|
|
|
197
197
|
|
|
198
198
|
// src/context/ContextConfig.ts
|
|
199
199
|
var logger = getLogger("context-config");
|
|
200
|
+
var RequestContextSchemaBuilder = class {
|
|
201
|
+
constructor(options) {
|
|
202
|
+
__publicField(this, "schema");
|
|
203
|
+
this.schema = options.schema;
|
|
204
|
+
}
|
|
205
|
+
/** Template function for request context paths with type-safe autocomplete */
|
|
206
|
+
toTemplate(path2) {
|
|
207
|
+
return `{{requestContext.${path2}}}`;
|
|
208
|
+
}
|
|
209
|
+
getSchema() {
|
|
210
|
+
return this.schema;
|
|
211
|
+
}
|
|
212
|
+
getJsonSchema() {
|
|
213
|
+
return convertZodToJsonSchema(this.schema);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
200
216
|
function convertZodToJsonSchema(zodSchema) {
|
|
201
217
|
try {
|
|
202
218
|
return z$1.toJSONSchema(zodSchema, { target: "draft-7" });
|
|
@@ -219,23 +235,34 @@ var ContextConfigBuilder = class {
|
|
|
219
235
|
this.tenantId = options.tenantId || "default";
|
|
220
236
|
this.projectId = options.projectId || "default";
|
|
221
237
|
this.baseURL = process.env.INKEEP_AGENTS_MANAGE_API_URL || "http://localhost:3002";
|
|
222
|
-
let
|
|
238
|
+
let requestContextSchema2;
|
|
223
239
|
if (options.requestContextSchema) {
|
|
240
|
+
const actualSchema = options.requestContextSchema instanceof RequestContextSchemaBuilder ? options.requestContextSchema.getSchema() : options.requestContextSchema;
|
|
224
241
|
logger.info(
|
|
225
242
|
{
|
|
226
243
|
requestContextSchema: options.requestContextSchema
|
|
227
244
|
},
|
|
228
245
|
"Converting request headers schema to JSON Schema for database storage"
|
|
229
246
|
);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
247
|
+
requestContextSchema2 = convertZodToJsonSchema(actualSchema);
|
|
248
|
+
}
|
|
249
|
+
const processedContextVariables = {};
|
|
250
|
+
if (options.contextVariables) {
|
|
251
|
+
for (const [key, definition] of Object.entries(options.contextVariables)) {
|
|
252
|
+
const { credentialReference, ...rest } = definition;
|
|
253
|
+
processedContextVariables[key] = {
|
|
254
|
+
...rest,
|
|
255
|
+
responseSchema: convertZodToJsonSchema(definition.responseSchema),
|
|
256
|
+
credentialReferenceId: credentialReference?.id
|
|
257
|
+
};
|
|
233
258
|
logger.debug(
|
|
234
|
-
{
|
|
235
|
-
|
|
259
|
+
{
|
|
260
|
+
contextVariableKey: key,
|
|
261
|
+
originalSchema: definition.responseSchema
|
|
262
|
+
},
|
|
263
|
+
"Converting contextVariable responseSchema to JSON Schema for database storage"
|
|
236
264
|
);
|
|
237
265
|
}
|
|
238
|
-
requestContextSchema = convertZodToJsonSchema(schema);
|
|
239
266
|
}
|
|
240
267
|
this.config = {
|
|
241
268
|
id: options.id,
|
|
@@ -243,8 +270,8 @@ var ContextConfigBuilder = class {
|
|
|
243
270
|
projectId: this.projectId,
|
|
244
271
|
name: options.name,
|
|
245
272
|
description: options.description || "",
|
|
246
|
-
requestContextSchema,
|
|
247
|
-
contextVariables:
|
|
273
|
+
requestContextSchema: requestContextSchema2,
|
|
274
|
+
contextVariables: processedContextVariables
|
|
248
275
|
};
|
|
249
276
|
logger.info(
|
|
250
277
|
{
|
|
@@ -254,6 +281,22 @@ var ContextConfigBuilder = class {
|
|
|
254
281
|
"ContextConfig builder initialized"
|
|
255
282
|
);
|
|
256
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Convert the builder to a plain object for database operations
|
|
286
|
+
*/
|
|
287
|
+
toObject() {
|
|
288
|
+
return {
|
|
289
|
+
id: this.getId(),
|
|
290
|
+
tenantId: this.tenantId,
|
|
291
|
+
projectId: this.projectId,
|
|
292
|
+
name: this.getName(),
|
|
293
|
+
description: this.getDescription(),
|
|
294
|
+
requestContextSchema: this.getRequestContextSchema(),
|
|
295
|
+
contextVariables: this.getContextVariables(),
|
|
296
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
297
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
298
|
+
};
|
|
299
|
+
}
|
|
257
300
|
// Getter methods
|
|
258
301
|
getId() {
|
|
259
302
|
if (!this.config.id) {
|
|
@@ -276,35 +319,14 @@ var ContextConfigBuilder = class {
|
|
|
276
319
|
getContextVariables() {
|
|
277
320
|
return this.config.contextVariables || {};
|
|
278
321
|
}
|
|
279
|
-
/**
|
|
280
|
-
* Convert the builder to a plain object for database operations
|
|
281
|
-
*/
|
|
282
|
-
toObject() {
|
|
283
|
-
return {
|
|
284
|
-
id: this.getId(),
|
|
285
|
-
tenantId: this.tenantId,
|
|
286
|
-
projectId: this.projectId,
|
|
287
|
-
name: this.getName(),
|
|
288
|
-
description: this.getDescription(),
|
|
289
|
-
requestContextSchema: this.getRequestContextSchema(),
|
|
290
|
-
contextVariables: this.getContextVariables(),
|
|
291
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
292
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
322
|
// Builder methods for fluent API
|
|
296
323
|
withRequestContextSchema(schema) {
|
|
297
324
|
this.config.requestContextSchema = schema;
|
|
298
325
|
return this;
|
|
299
326
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
return this;
|
|
304
|
-
}
|
|
305
|
-
withContextVariables(variables) {
|
|
306
|
-
this.config.contextVariables = variables;
|
|
307
|
-
return this;
|
|
327
|
+
/** 4) The function you ship: path autocomplete + validation, returns {{path}} */
|
|
328
|
+
toTemplate(path2) {
|
|
329
|
+
return `{{${path2}}}`;
|
|
308
330
|
}
|
|
309
331
|
// Validation method
|
|
310
332
|
validate() {
|
|
@@ -449,15 +471,11 @@ var ContextConfigBuilder = class {
|
|
|
449
471
|
function contextConfig(options) {
|
|
450
472
|
return new ContextConfigBuilder(options);
|
|
451
473
|
}
|
|
474
|
+
function requestContextSchema(options) {
|
|
475
|
+
return new RequestContextSchemaBuilder(options);
|
|
476
|
+
}
|
|
452
477
|
function fetchDefinition(options) {
|
|
453
|
-
const fetchConfig = options.fetchConfig
|
|
454
|
-
url: options.url,
|
|
455
|
-
method: options.method,
|
|
456
|
-
headers: options.headers,
|
|
457
|
-
body: options.body,
|
|
458
|
-
transform: options.transform,
|
|
459
|
-
timeout: options.timeout
|
|
460
|
-
};
|
|
478
|
+
const fetchConfig = options.fetchConfig;
|
|
461
479
|
return {
|
|
462
480
|
id: options.id,
|
|
463
481
|
name: options.name,
|
|
@@ -470,9 +488,9 @@ function fetchDefinition(options) {
|
|
|
470
488
|
transform: fetchConfig.transform,
|
|
471
489
|
timeout: fetchConfig.timeout
|
|
472
490
|
},
|
|
473
|
-
responseSchema: options.responseSchema
|
|
491
|
+
responseSchema: options.responseSchema,
|
|
474
492
|
defaultValue: options.defaultValue,
|
|
475
|
-
credentialReferenceId: options.
|
|
493
|
+
credentialReferenceId: options.credentialReference?.id
|
|
476
494
|
};
|
|
477
495
|
}
|
|
478
496
|
var logger2 = getLogger("template-engine");
|
|
@@ -7043,21 +7061,62 @@ var ContextResolver = class {
|
|
|
7043
7061
|
var logger7 = getLogger("context-validation");
|
|
7044
7062
|
var ajv = new Ajv({ allErrors: true, strict: false });
|
|
7045
7063
|
var HTTP_REQUEST_PARTS = ["headers"];
|
|
7064
|
+
var MAX_SCHEMA_CACHE_SIZE = 1e3;
|
|
7046
7065
|
var schemaCache = /* @__PURE__ */ new Map();
|
|
7047
7066
|
function isValidHttpRequest(obj) {
|
|
7048
7067
|
return obj != null && typeof obj === "object" && !Array.isArray(obj) && "headers" in obj;
|
|
7049
7068
|
}
|
|
7050
7069
|
function getCachedValidator(schema) {
|
|
7051
7070
|
const key = JSON.stringify(schema);
|
|
7052
|
-
if (
|
|
7053
|
-
schemaCache.
|
|
7071
|
+
if (schemaCache.has(key)) {
|
|
7072
|
+
const validator2 = schemaCache.get(key);
|
|
7073
|
+
if (!validator2) {
|
|
7074
|
+
throw new Error("Unexpected: validator not found in cache after has() check");
|
|
7075
|
+
}
|
|
7076
|
+
schemaCache.delete(key);
|
|
7077
|
+
schemaCache.set(key, validator2);
|
|
7078
|
+
return validator2;
|
|
7054
7079
|
}
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7080
|
+
if (schemaCache.size >= MAX_SCHEMA_CACHE_SIZE) {
|
|
7081
|
+
const firstKey = schemaCache.keys().next().value;
|
|
7082
|
+
if (firstKey) {
|
|
7083
|
+
schemaCache.delete(firstKey);
|
|
7084
|
+
}
|
|
7058
7085
|
}
|
|
7086
|
+
const permissiveSchema = makeSchemaPermissive(schema);
|
|
7087
|
+
const validator = ajv.compile(permissiveSchema);
|
|
7088
|
+
schemaCache.set(key, validator);
|
|
7059
7089
|
return validator;
|
|
7060
7090
|
}
|
|
7091
|
+
function makeSchemaPermissive(schema) {
|
|
7092
|
+
if (!schema || typeof schema !== "object") {
|
|
7093
|
+
return schema;
|
|
7094
|
+
}
|
|
7095
|
+
const permissiveSchema = { ...schema };
|
|
7096
|
+
if (permissiveSchema.type === "object") {
|
|
7097
|
+
permissiveSchema.additionalProperties = true;
|
|
7098
|
+
if (permissiveSchema.properties && typeof permissiveSchema.properties === "object") {
|
|
7099
|
+
const newProperties = {};
|
|
7100
|
+
for (const [key, value] of Object.entries(permissiveSchema.properties)) {
|
|
7101
|
+
newProperties[key] = makeSchemaPermissive(value);
|
|
7102
|
+
}
|
|
7103
|
+
permissiveSchema.properties = newProperties;
|
|
7104
|
+
}
|
|
7105
|
+
}
|
|
7106
|
+
if (permissiveSchema.type === "array" && permissiveSchema.items) {
|
|
7107
|
+
permissiveSchema.items = makeSchemaPermissive(permissiveSchema.items);
|
|
7108
|
+
}
|
|
7109
|
+
if (permissiveSchema.oneOf) {
|
|
7110
|
+
permissiveSchema.oneOf = permissiveSchema.oneOf.map(makeSchemaPermissive);
|
|
7111
|
+
}
|
|
7112
|
+
if (permissiveSchema.anyOf) {
|
|
7113
|
+
permissiveSchema.anyOf = permissiveSchema.anyOf.map(makeSchemaPermissive);
|
|
7114
|
+
}
|
|
7115
|
+
if (permissiveSchema.allOf) {
|
|
7116
|
+
permissiveSchema.allOf = permissiveSchema.allOf.map(makeSchemaPermissive);
|
|
7117
|
+
}
|
|
7118
|
+
return permissiveSchema;
|
|
7119
|
+
}
|
|
7061
7120
|
function validationHelper(jsonSchema) {
|
|
7062
7121
|
return getCachedValidator(jsonSchema);
|
|
7063
7122
|
}
|
|
@@ -8522,4 +8581,4 @@ ${error.message}`
|
|
|
8522
8581
|
};
|
|
8523
8582
|
parseEnv();
|
|
8524
8583
|
|
|
8525
|
-
export { ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, PinoLogger, TemplateEngine, 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, 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 };
|
|
8584
|
+
export { ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, PinoLogger, TemplateEngine, 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 };
|
package/package.json
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
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",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
".":
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./schema": {
|
|
15
|
+
"types": "./dist/db/schema.d.ts",
|
|
16
|
+
"import": "./dist/db/schema.js"
|
|
17
|
+
},
|
|
18
|
+
"./types": {
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
|
+
"import": "./dist/types/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./validation": {
|
|
23
|
+
"types": "./dist/validation/index.d.ts",
|
|
24
|
+
"import": "./dist/validation/index.js"
|
|
25
|
+
},
|
|
14
26
|
"./client-exports": {
|
|
15
27
|
"types": "./dist/client-exports.d.ts",
|
|
16
28
|
"import": "./dist/client-exports.js"
|