@inkeep/agents-core 0.36.0 → 0.37.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/auth/auth-validation-schemas.js +17 -17
- package/dist/auth/auth.d.ts +29 -4
- package/dist/auth/auth.js +37 -5
- package/dist/{chunk-OEHP46F7.js → chunk-32YRH2S7.js} +67 -63
- package/dist/chunk-CUM6BY2Y.js +320 -0
- package/dist/{chunk-4OISWRFK.js → chunk-ICZLNCX7.js} +49 -30
- package/dist/{chunk-FOK3JSQN.js → chunk-MB2ZIPZS.js} +5 -5
- package/dist/chunk-OUXC23J7.js +12534 -0
- package/dist/{chunk-4RVJB4KV.js → chunk-Q5U2SVA6.js} +7 -8
- package/dist/{chunk-KMLLKRUY.js → chunk-SLQW43IV.js} +5 -4
- package/dist/{chunk-7GZHUB4J.js → chunk-SSRRHYU4.js} +5 -4
- package/dist/{chunk-ZCEKN54E.js → chunk-VQXQOGJU.js} +314 -312
- package/dist/{client-HrEgt7wv.d.ts → client-CnpNkGsH.d.ts} +1 -1
- package/dist/client-exports.d.ts +2 -2
- package/dist/client-exports.js +126 -125
- package/dist/constants/schema-validation/index.js +1 -1
- package/dist/credential-stores/index.d.ts +1 -1
- package/dist/credential-stores/index.js +1 -1
- package/dist/db/schema.d.ts +2 -2
- package/dist/db/test-client.d.ts +3 -3
- package/dist/index.d.ts +23 -6
- package/dist/index.js +16 -14
- package/dist/{schema-CoC3tYFX.d.ts → schema-Cgkp_geg.d.ts} +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/{utility-C4QAannk.d.ts → utility-C_tTZ7-k.d.ts} +5 -0
- package/dist/utils/schema-conversion.js +1 -1
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/package.json +4 -8
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { loadEnvironmentFiles, env } from './chunk-
|
|
1
|
+
import { loadEnvironmentFiles, env } from './chunk-Q5U2SVA6.js';
|
|
2
2
|
import { getLogger } from './chunk-DN4B564Y.js';
|
|
3
3
|
import { CredentialStoreType, MCPTransportType } from './chunk-YFHT5M2R.js';
|
|
4
|
-
import {
|
|
4
|
+
import { external_exports } from './chunk-OUXC23J7.js';
|
|
5
5
|
import { customAlphabet } from 'nanoid';
|
|
6
6
|
import { scrypt, randomBytes, timingSafeEqual } from 'crypto';
|
|
7
7
|
import { promisify } from 'util';
|
|
8
|
-
import { z as z$1 } from '@hono/zod-openapi';
|
|
9
8
|
import { HTTPException } from 'hono/http-exception';
|
|
10
9
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
11
10
|
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
@@ -15,6 +14,7 @@ import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
|
15
14
|
import { tool } from 'ai';
|
|
16
15
|
import { asyncExitHook, gracefulExit } from 'exit-hook';
|
|
17
16
|
import { match } from 'ts-pattern';
|
|
17
|
+
import * as jose from 'jose';
|
|
18
18
|
import { SignJWT, jwtVerify } from 'jose';
|
|
19
19
|
import { Composio } from '@composio/core';
|
|
20
20
|
import { SpanStatusCode, trace } from '@opentelemetry/api';
|
|
@@ -47,12 +47,14 @@ var executionLimitsSharedDefaults = {
|
|
|
47
47
|
// Increased from 4,000 to 8,000 to accommodate tool results in conversation history.
|
|
48
48
|
CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT: 8e3
|
|
49
49
|
};
|
|
50
|
+
|
|
51
|
+
// src/constants/execution-limits-shared/index.ts
|
|
50
52
|
loadEnvironmentFiles();
|
|
51
|
-
var constantsSchema =
|
|
53
|
+
var constantsSchema = external_exports.object(
|
|
52
54
|
Object.fromEntries(
|
|
53
55
|
Object.keys(executionLimitsSharedDefaults).map((key) => [
|
|
54
56
|
`AGENTS_${key}`,
|
|
55
|
-
|
|
57
|
+
external_exports.coerce.number().optional()
|
|
56
58
|
])
|
|
57
59
|
)
|
|
58
60
|
);
|
|
@@ -181,7 +183,7 @@ function normalizeDateString(dateString) {
|
|
|
181
183
|
}
|
|
182
184
|
return dateString;
|
|
183
185
|
}
|
|
184
|
-
var ErrorCode =
|
|
186
|
+
var ErrorCode = external_exports.enum([
|
|
185
187
|
"bad_request",
|
|
186
188
|
"unauthorized",
|
|
187
189
|
"forbidden",
|
|
@@ -200,28 +202,28 @@ var errorCodeToHttpStatus = {
|
|
|
200
202
|
internal_server_error: 500
|
|
201
203
|
};
|
|
202
204
|
var ERROR_DOCS_BASE_URL = "https://docs.inkeep.com/agents-api/errors";
|
|
203
|
-
var problemDetailsSchema =
|
|
205
|
+
var problemDetailsSchema = external_exports.object({
|
|
204
206
|
// type: z.string().url().openapi({
|
|
205
207
|
// description: "A URI reference that identifies the problem type.",
|
|
206
208
|
// example: `${ERROR_DOCS_BASE_URL}#not-found`,
|
|
207
209
|
// }),
|
|
208
|
-
title:
|
|
210
|
+
title: external_exports.string().openapi({
|
|
209
211
|
description: "A short, human-readable summary of the problem type.",
|
|
210
212
|
example: "Resource Not Found"
|
|
211
213
|
}),
|
|
212
|
-
status:
|
|
214
|
+
status: external_exports.number().int().openapi({
|
|
213
215
|
description: "The HTTP status code.",
|
|
214
216
|
example: 404
|
|
215
217
|
}),
|
|
216
|
-
detail:
|
|
218
|
+
detail: external_exports.string().openapi({
|
|
217
219
|
description: "A human-readable explanation specific to this occurrence of the problem.",
|
|
218
220
|
example: "The requested resource was not found."
|
|
219
221
|
}),
|
|
220
|
-
instance:
|
|
222
|
+
instance: external_exports.string().optional().openapi({
|
|
221
223
|
description: "A URI reference that identifies the specific occurrence of the problem.",
|
|
222
224
|
example: "/conversations/123"
|
|
223
225
|
}),
|
|
224
|
-
requestId:
|
|
226
|
+
requestId: external_exports.string().optional().openapi({
|
|
225
227
|
description: "A unique identifier for the request, useful for troubleshooting.",
|
|
226
228
|
example: "req_1234567890"
|
|
227
229
|
}),
|
|
@@ -230,13 +232,13 @@ var problemDetailsSchema = z$1.object({
|
|
|
230
232
|
example: "not_found"
|
|
231
233
|
})
|
|
232
234
|
}).openapi("ProblemDetails");
|
|
233
|
-
var errorResponseSchema =
|
|
234
|
-
error:
|
|
235
|
+
var errorResponseSchema = external_exports.object({
|
|
236
|
+
error: external_exports.object({
|
|
235
237
|
code: ErrorCode.openapi({
|
|
236
238
|
description: "A short code indicating the error code returned.",
|
|
237
239
|
example: "not_found"
|
|
238
240
|
}),
|
|
239
|
-
message:
|
|
241
|
+
message: external_exports.string().openapi({
|
|
240
242
|
description: "A human readable error message.",
|
|
241
243
|
example: "The requested resource was not found."
|
|
242
244
|
})
|
|
@@ -374,15 +376,15 @@ var errorSchemaFactory = (code, description) => ({
|
|
|
374
376
|
content: {
|
|
375
377
|
"application/problem+json": {
|
|
376
378
|
schema: problemDetailsSchema.extend({
|
|
377
|
-
code:
|
|
379
|
+
code: external_exports.literal(code).openapi({
|
|
378
380
|
description: "A short code indicating the error code returned.",
|
|
379
381
|
example: code
|
|
380
382
|
}),
|
|
381
|
-
detail:
|
|
383
|
+
detail: external_exports.string().openapi({
|
|
382
384
|
description: "A detailed explanation specific to this occurrence of the problem, providing context and specifics about what went wrong.",
|
|
383
385
|
example: description
|
|
384
386
|
}),
|
|
385
|
-
title:
|
|
387
|
+
title: external_exports.string().openapi({
|
|
386
388
|
description: "A short, human-readable summary of the problem type.",
|
|
387
389
|
example: getTitleFromCode(code)
|
|
388
390
|
}),
|
|
@@ -390,16 +392,16 @@ var errorSchemaFactory = (code, description) => ({
|
|
|
390
392
|
// description: "A URI reference that identifies the problem type.",
|
|
391
393
|
// example: `${ERROR_DOCS_BASE_URL}#${code}`,
|
|
392
394
|
// }),
|
|
393
|
-
status:
|
|
395
|
+
status: external_exports.number().int().openapi({
|
|
394
396
|
description: "The HTTP status code.",
|
|
395
397
|
example: errorCodeToHttpStatus[code]
|
|
396
398
|
}),
|
|
397
|
-
error:
|
|
398
|
-
code:
|
|
399
|
+
error: external_exports.object({
|
|
400
|
+
code: external_exports.literal(code).openapi({
|
|
399
401
|
description: "A short code indicating the error code returned.",
|
|
400
402
|
example: code
|
|
401
403
|
}),
|
|
402
|
-
message:
|
|
404
|
+
message: external_exports.string().openapi({
|
|
403
405
|
description: "A concise error message suitable for display to end users. May be truncated if the full detail is long.",
|
|
404
406
|
example: description.length > 100 ? `${description.substring(0, 97)}...` : description
|
|
405
407
|
})
|
|
@@ -577,7 +579,7 @@ var McpClient = class {
|
|
|
577
579
|
try {
|
|
578
580
|
const createZodSchema = (inputSchema) => {
|
|
579
581
|
if (!inputSchema || !inputSchema.properties) {
|
|
580
|
-
return
|
|
582
|
+
return external_exports.object({});
|
|
581
583
|
}
|
|
582
584
|
const zodProperties = {};
|
|
583
585
|
for (const [key, prop] of Object.entries(inputSchema.properties)) {
|
|
@@ -585,19 +587,19 @@ var McpClient = class {
|
|
|
585
587
|
let zodType;
|
|
586
588
|
switch (propDef.type) {
|
|
587
589
|
case "string":
|
|
588
|
-
zodType =
|
|
590
|
+
zodType = external_exports.string();
|
|
589
591
|
break;
|
|
590
592
|
case "number":
|
|
591
|
-
zodType =
|
|
593
|
+
zodType = external_exports.number();
|
|
592
594
|
break;
|
|
593
595
|
case "boolean":
|
|
594
|
-
zodType =
|
|
596
|
+
zodType = external_exports.boolean();
|
|
595
597
|
break;
|
|
596
598
|
case "array":
|
|
597
|
-
zodType =
|
|
599
|
+
zodType = external_exports.array(external_exports.any());
|
|
598
600
|
break;
|
|
599
601
|
default:
|
|
600
|
-
zodType =
|
|
602
|
+
zodType = external_exports.any();
|
|
601
603
|
}
|
|
602
604
|
if (propDef.description) {
|
|
603
605
|
zodType = zodType.describe(propDef.description);
|
|
@@ -608,7 +610,7 @@ var McpClient = class {
|
|
|
608
610
|
}
|
|
609
611
|
zodProperties[key] = zodType;
|
|
610
612
|
}
|
|
611
|
-
return
|
|
613
|
+
return external_exports.object(zodProperties);
|
|
612
614
|
};
|
|
613
615
|
const schema = createZodSchema(def.inputSchema);
|
|
614
616
|
const createdTool = tool({
|
|
@@ -774,6 +776,23 @@ async function verifyAuthorizationHeader(authHeader) {
|
|
|
774
776
|
}
|
|
775
777
|
return verifyServiceToken(token);
|
|
776
778
|
}
|
|
779
|
+
async function signTempToken(privateKeyPem, payload, userId) {
|
|
780
|
+
const privateKey = await jose.importPKCS8(privateKeyPem, "RS256");
|
|
781
|
+
const jwt = await new jose.SignJWT(payload).setProtectedHeader({ alg: "RS256", typ: "JWT" }).setIssuedAt().setExpirationTime("1h").setIssuer("inkeep-manage-api").setAudience("inkeep-run-api").setSubject(userId).setJti(generateId()).sign(privateKey);
|
|
782
|
+
const expiresAt = new Date(Date.now() + 60 * 60 * 1e3).toISOString();
|
|
783
|
+
return { token: jwt, expiresAt };
|
|
784
|
+
}
|
|
785
|
+
async function verifyTempToken(publicKeyPem, token) {
|
|
786
|
+
const publicKey = await jose.importSPKI(publicKeyPem, "RS256");
|
|
787
|
+
const { payload } = await jose.jwtVerify(token, publicKey, {
|
|
788
|
+
issuer: "inkeep-manage-api",
|
|
789
|
+
audience: "inkeep-run-api"
|
|
790
|
+
});
|
|
791
|
+
if (payload.type !== "temporary") {
|
|
792
|
+
throw new Error("Invalid token type");
|
|
793
|
+
}
|
|
794
|
+
return payload;
|
|
795
|
+
}
|
|
777
796
|
var logger3 = getLogger("composio-client");
|
|
778
797
|
var TOOLKIT_TO_CATEGORY = {
|
|
779
798
|
github: "development",
|
|
@@ -1139,4 +1158,4 @@ function getTracer(serviceName, serviceVersion) {
|
|
|
1139
1158
|
}
|
|
1140
1159
|
}
|
|
1141
1160
|
|
|
1142
|
-
export { CONVERSATION_HISTORY_DEFAULT_LIMIT, CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT, ERROR_DOCS_BASE_URL, ErrorCode, MCP_TOOL_CONNECTION_TIMEOUT_MS, MCP_TOOL_INITIAL_RECONNECTION_DELAY_MS, MCP_TOOL_MAX_RECONNECTION_DELAY_MS, MCP_TOOL_MAX_RETRIES, MCP_TOOL_RECONNECTION_DELAY_GROWTH_FACTOR, McpClient, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, createExecutionContext, errorResponseSchema, errorSchemaFactory, executionLimitsSharedDefaults, extractComposioServerId, extractPublicId, fetchComposioServers, fetchSingleComposioServer, generateApiKey, generateId, generateServiceToken, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getRequestExecutionContext, getTracer, handleApiError, hashApiKey, isApiKeyExpired, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated, maskApiKey, normalizeDateString, problemDetailsSchema, setSpanWithError, validateApiKey, validateTargetAgent, validateTenantId, verifyAuthorizationHeader, verifyServiceToken };
|
|
1161
|
+
export { CONVERSATION_HISTORY_DEFAULT_LIMIT, CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT, ERROR_DOCS_BASE_URL, ErrorCode, MCP_TOOL_CONNECTION_TIMEOUT_MS, MCP_TOOL_INITIAL_RECONNECTION_DELAY_MS, MCP_TOOL_MAX_RECONNECTION_DELAY_MS, MCP_TOOL_MAX_RETRIES, MCP_TOOL_RECONNECTION_DELAY_GROWTH_FACTOR, McpClient, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, createExecutionContext, errorResponseSchema, errorSchemaFactory, executionLimitsSharedDefaults, extractComposioServerId, extractPublicId, fetchComposioServers, fetchSingleComposioServer, generateApiKey, generateId, generateServiceToken, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getRequestExecutionContext, getTracer, handleApiError, hashApiKey, isApiKeyExpired, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated, maskApiKey, normalizeDateString, problemDetailsSchema, setSpanWithError, signTempToken, validateApiKey, validateTargetAgent, validateTenantId, verifyAuthorizationHeader, verifyServiceToken, verifyTempToken };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getLogger } from './chunk-DN4B564Y.js';
|
|
2
2
|
import { CredentialStoreType } from './chunk-YFHT5M2R.js';
|
|
3
|
+
import { external_exports } from './chunk-OUXC23J7.js';
|
|
3
4
|
import { Nango } from '@nangohq/node';
|
|
4
|
-
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
// src/credential-stores/CredentialStoreRegistry.ts
|
|
7
7
|
var CredentialStoreRegistry = class {
|
|
@@ -349,10 +349,10 @@ var InMemoryCredentialStore = class {
|
|
|
349
349
|
}
|
|
350
350
|
};
|
|
351
351
|
var logger = getLogger("nango-credential-store");
|
|
352
|
-
var CredentialKeySchema =
|
|
353
|
-
connectionId:
|
|
354
|
-
providerConfigKey:
|
|
355
|
-
integrationDisplayName:
|
|
352
|
+
var CredentialKeySchema = external_exports.object({
|
|
353
|
+
connectionId: external_exports.string().min(1, "connectionId must be a non-empty string"),
|
|
354
|
+
providerConfigKey: external_exports.string().min(1, "providerConfigKey must be a non-empty string"),
|
|
355
|
+
integrationDisplayName: external_exports.string().nullish()
|
|
356
356
|
});
|
|
357
357
|
function parseCredentialKey(key) {
|
|
358
358
|
try {
|