@inkeep/agents-api 0.0.0-dev-20260320144657 → 0.0.0-dev-20260320150253
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/.well-known/workflow/v1/manifest.json +19 -19
- package/dist/createApp.d.ts +2 -2
- package/dist/data/db/runDbClient.d.ts +2 -2
- package/dist/data-reconciliation/handlers/agent.d.ts +2 -2
- package/dist/data-reconciliation/handlers/context-configs.d.ts +2 -2
- package/dist/data-reconciliation/handlers/sub-agents.d.ts +2 -2
- package/dist/data-reconciliation/handlers/tools.d.ts +2 -2
- package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
- package/dist/domains/evals/routes/index.d.ts +2 -2
- package/dist/domains/evals/workflow/routes.d.ts +2 -2
- package/dist/domains/manage/routes/authLookup.d.ts +2 -2
- package/dist/domains/manage/routes/availableAgents.d.ts +2 -2
- package/dist/domains/manage/routes/conversations.d.ts +2 -2
- package/dist/domains/manage/routes/index.d.ts +2 -2
- package/dist/domains/manage/routes/invitations.d.ts +2 -2
- package/dist/domains/manage/routes/passwordResetLinks.d.ts +2 -2
- package/dist/domains/manage/routes/signoz.d.ts +2 -2
- package/dist/domains/manage/routes/users.d.ts +2 -2
- package/dist/domains/mcp/routes/mcp.d.ts +2 -2
- package/dist/domains/run/agents/agent-types.d.ts +8 -2
- package/dist/domains/run/agents/generation/conversation-history.d.ts +2 -2
- package/dist/domains/run/agents/generation/conversation-history.js +34 -11
- package/dist/domains/run/agents/generation/generate.js +7 -2
- package/dist/domains/run/agents/generation/tool-result-for-conversation-history.js +2 -2
- package/dist/domains/run/agents/relationTools.d.ts +2 -2
- package/dist/domains/run/routes/auth.d.ts +2 -2
- package/dist/domains/run/routes/chat.js +10 -6
- package/dist/domains/run/routes/chatDataStream.js +3 -43
- package/dist/domains/run/services/blob-storage/external-file-downloader.d.ts +7 -0
- package/dist/domains/run/services/blob-storage/{external-image-downloader.js → external-file-downloader.js} +19 -19
- package/dist/domains/run/services/blob-storage/file-content-security.d.ts +18 -0
- package/dist/domains/run/services/blob-storage/file-content-security.js +55 -0
- package/dist/domains/run/services/blob-storage/{image-security-constants.d.ts → file-security-constants.d.ts} +3 -3
- package/dist/domains/run/services/blob-storage/{image-security-constants.js → file-security-constants.js} +4 -4
- package/dist/domains/run/services/blob-storage/file-security-errors.d.ts +69 -0
- package/dist/domains/run/services/blob-storage/file-security-errors.js +115 -0
- package/dist/domains/run/services/blob-storage/{image-upload-helpers.d.ts → file-upload-helpers.d.ts} +2 -2
- package/dist/domains/run/services/blob-storage/{image-upload-helpers.js → file-upload-helpers.js} +6 -6
- package/dist/domains/run/services/blob-storage/{image-upload.d.ts → file-upload.d.ts} +3 -3
- package/dist/domains/run/services/blob-storage/{image-upload.js → file-upload.js} +24 -12
- package/dist/domains/run/services/blob-storage/file-url-security.d.ts +6 -0
- package/dist/domains/run/services/blob-storage/{image-url-security.js → file-url-security.js} +10 -10
- package/dist/domains/run/services/blob-storage/local-provider.js +1 -1
- package/dist/domains/run/types/chat.d.ts +134 -2
- package/dist/domains/run/types/chat.js +71 -4
- package/dist/domains/run/utils/message-parts.js +31 -25
- package/dist/domains/run/utils/token-estimator.d.ts +2 -2
- package/dist/domains/run/workflow/steps/scheduledTriggerSteps.d.ts +6 -6
- package/dist/index.d.ts +2 -2
- package/dist/middleware/evalsAuth.d.ts +2 -2
- package/dist/middleware/manageAuth.d.ts +3 -3
- package/dist/middleware/projectConfig.d.ts +3 -3
- package/dist/middleware/requirePermission.d.ts +2 -2
- package/dist/middleware/runAuth.d.ts +4 -4
- package/dist/middleware/sessionAuth.d.ts +3 -3
- package/dist/middleware/tenantAccess.d.ts +2 -2
- package/dist/middleware/tracing.d.ts +3 -3
- package/package.json +5 -5
- package/dist/domains/run/services/blob-storage/external-image-downloader.d.ts +0 -7
- package/dist/domains/run/services/blob-storage/image-content-security.d.ts +0 -11
- package/dist/domains/run/services/blob-storage/image-content-security.js +0 -38
- package/dist/domains/run/services/blob-storage/image-security-errors.d.ts +0 -66
- package/dist/domains/run/services/blob-storage/image-security-errors.js +0 -110
- package/dist/domains/run/services/blob-storage/image-url-security.d.ts +0 -6
|
@@ -12,16 +12,6 @@
|
|
|
12
12
|
"stepId": "__builtin_response_text"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"node_modules/.pnpm/workflow@4.2.0-beta.68_@nestjs+common@11.1.13_reflect-metadata@0.2.2_rxjs@7.8.2__@nestj_9ec7abb8bcd1459c2bab463fccef5dfb/node_modules/workflow/dist/stdlib.js": {
|
|
16
|
-
"fetch": {
|
|
17
|
-
"stepId": "step//workflow@4.2.0-beta.68//fetch"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"src/domains/run/workflow/functions/scheduledTriggerRunner.ts": {
|
|
21
|
-
"startNextIterationStep": {
|
|
22
|
-
"stepId": "step//./src/domains/run/workflow/functions/scheduledTriggerRunner//startNextIterationStep"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
15
|
"src/domains/evals/workflow/functions/evaluateConversation.ts": {
|
|
26
16
|
"executeEvaluatorStep": {
|
|
27
17
|
"stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//executeEvaluatorStep"
|
|
@@ -50,6 +40,16 @@
|
|
|
50
40
|
"stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//logStep"
|
|
51
41
|
}
|
|
52
42
|
},
|
|
43
|
+
"node_modules/.pnpm/workflow@4.2.0-beta.68_@nestjs+common@11.1.13_reflect-metadata@0.2.2_rxjs@7.8.2__@nestj_9ec7abb8bcd1459c2bab463fccef5dfb/node_modules/workflow/dist/stdlib.js": {
|
|
44
|
+
"fetch": {
|
|
45
|
+
"stepId": "step//workflow@4.2.0-beta.68//fetch"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"src/domains/run/workflow/functions/scheduledTriggerRunner.ts": {
|
|
49
|
+
"startNextIterationStep": {
|
|
50
|
+
"stepId": "step//./src/domains/run/workflow/functions/scheduledTriggerRunner//startNextIterationStep"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
53
|
"src/domains/run/workflow/steps/scheduledTriggerSteps.ts": {
|
|
54
54
|
"addConversationIdStep": {
|
|
55
55
|
"stepId": "step//./src/domains/run/workflow/steps/scheduledTriggerSteps//addConversationIdStep"
|
|
@@ -99,15 +99,6 @@
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"workflows": {
|
|
102
|
-
"src/domains/run/workflow/functions/scheduledTriggerRunner.ts": {
|
|
103
|
-
"_scheduledTriggerRunnerWorkflow": {
|
|
104
|
-
"workflowId": "workflow//./src/domains/run/workflow/functions/scheduledTriggerRunner//_scheduledTriggerRunnerWorkflow",
|
|
105
|
-
"graph": {
|
|
106
|
-
"nodes": [],
|
|
107
|
-
"edges": []
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
102
|
"src/domains/evals/workflow/functions/evaluateConversation.ts": {
|
|
112
103
|
"_evaluateConversationWorkflow": {
|
|
113
104
|
"workflowId": "workflow//./src/domains/evals/workflow/functions/evaluateConversation//_evaluateConversationWorkflow",
|
|
@@ -125,6 +116,15 @@
|
|
|
125
116
|
"edges": []
|
|
126
117
|
}
|
|
127
118
|
}
|
|
119
|
+
},
|
|
120
|
+
"src/domains/run/workflow/functions/scheduledTriggerRunner.ts": {
|
|
121
|
+
"_scheduledTriggerRunnerWorkflow": {
|
|
122
|
+
"workflowId": "workflow//./src/domains/run/workflow/functions/scheduledTriggerRunner//_scheduledTriggerRunnerWorkflow",
|
|
123
|
+
"graph": {
|
|
124
|
+
"nodes": [],
|
|
125
|
+
"edges": []
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
130
|
"classes": {}
|
package/dist/createApp.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AppConfig } from "./types/app.js";
|
|
2
2
|
import "./types/index.js";
|
|
3
3
|
import { Hono } from "hono";
|
|
4
|
-
import * as
|
|
4
|
+
import * as hono_types1 from "hono/types";
|
|
5
5
|
|
|
6
6
|
//#region src/createApp.d.ts
|
|
7
7
|
declare const isWebhookRoute: (path: string) => boolean;
|
|
8
|
-
declare function createAgentsHono(config: AppConfig): Hono<
|
|
8
|
+
declare function createAgentsHono(config: AppConfig): Hono<hono_types1.BlankEnv, hono_types1.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { createAgentsHono, isWebhookRoute };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core0 from "@inkeep/agents-core";
|
|
2
2
|
|
|
3
3
|
//#region src/data/db/runDbClient.d.ts
|
|
4
|
-
declare const runDbClient:
|
|
4
|
+
declare const runDbClient: _inkeep_agents_core0.AgentsRunDatabaseClient;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { runDbClient as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core1 from "@inkeep/agents-core";
|
|
2
2
|
|
|
3
3
|
//#region src/data-reconciliation/handlers/agent.d.ts
|
|
4
|
-
declare const agentHandlers:
|
|
4
|
+
declare const agentHandlers: _inkeep_agents_core1.EntityEffectHandlers<"agent">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { agentHandlers };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core2 from "@inkeep/agents-core";
|
|
2
2
|
|
|
3
3
|
//#region src/data-reconciliation/handlers/context-configs.d.ts
|
|
4
|
-
declare const contextConfigsHandlers:
|
|
4
|
+
declare const contextConfigsHandlers: _inkeep_agents_core2.EntityEffectHandlers<"context_configs">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { contextConfigsHandlers };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core4 from "@inkeep/agents-core";
|
|
2
2
|
|
|
3
3
|
//#region src/data-reconciliation/handlers/sub-agents.d.ts
|
|
4
|
-
declare const subAgentsHandlers:
|
|
4
|
+
declare const subAgentsHandlers: _inkeep_agents_core4.EntityEffectHandlers<"sub_agents">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { subAgentsHandlers };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core5 from "@inkeep/agents-core";
|
|
2
2
|
|
|
3
3
|
//#region src/data-reconciliation/handlers/tools.d.ts
|
|
4
|
-
declare const toolsHandlers:
|
|
4
|
+
declare const toolsHandlers: _inkeep_agents_core5.EntityEffectHandlers<"tools">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { toolsHandlers };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono3 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/datasetTriggers.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono3.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono4 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono4.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types11 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/workflow/routes.d.ts
|
|
5
|
-
declare const workflowRoutes: Hono<
|
|
5
|
+
declare const workflowRoutes: Hono<hono_types11.BlankEnv, hono_types11.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { workflowRoutes };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types8 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/authLookup.d.ts
|
|
6
6
|
declare const authLookupRoutes: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types8.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { authLookupRoutes as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono6 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/availableAgents.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono6.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono7 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/conversations.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono7.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono5 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono5.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types6 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/invitations.d.ts
|
|
6
6
|
declare const invitationsRoutes: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types6.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { invitationsRoutes as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types5 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/passwordResetLinks.d.ts
|
|
6
6
|
declare const passwordResetLinksRoutes: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types5.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { passwordResetLinksRoutes as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types7 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/signoz.d.ts
|
|
6
6
|
declare const app: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types7.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { app as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types13 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/users.d.ts
|
|
6
6
|
declare const usersRoutes: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types13.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { usersRoutes as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types9 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/mcp/routes/mcp.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types9.BlankEnv, hono_types9.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -23,7 +23,13 @@ type AiSdkImagePart = {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
type
|
|
26
|
+
type AiSdkFilePart = {
|
|
27
|
+
type: 'file';
|
|
28
|
+
data: string | URL;
|
|
29
|
+
mediaType: string;
|
|
30
|
+
filename?: string;
|
|
31
|
+
};
|
|
32
|
+
type AiSdkContentPart = AiSdkTextPart | AiSdkImagePart | AiSdkFilePart;
|
|
27
33
|
/**
|
|
28
34
|
* Creates a stopWhen condition that stops when any tool call name starts with the given prefix
|
|
29
35
|
* @param prefix - The prefix to check for in tool call names
|
|
@@ -183,4 +189,4 @@ interface AgentRunContext {
|
|
|
183
189
|
}>;
|
|
184
190
|
}
|
|
185
191
|
//#endregion
|
|
186
|
-
export { AgentConfig, AgentRunContext, AiSdkContentPart, AiSdkImagePart, AiSdkTextPart, AiSdkToolDefinition, DelegateRelation, ExternalAgentRelationConfig, ResolvedGenerationResponse, TeamAgentRelationConfig, ToolType, hasToolCallWithPrefix, isValidTool, resolveGenerationResponse, validateModel };
|
|
192
|
+
export { AgentConfig, AgentRunContext, AiSdkContentPart, AiSdkFilePart, AiSdkImagePart, AiSdkTextPart, AiSdkToolDefinition, DelegateRelation, ExternalAgentRelationConfig, ResolvedGenerationResponse, TeamAgentRelationConfig, ToolType, hasToolCallWithPrefix, isValidTool, resolveGenerationResponse, validateModel };
|
|
@@ -7,7 +7,7 @@ declare function buildConversationHistory(ctx: AgentRunContext, contextId: strin
|
|
|
7
7
|
conversationHistory: string;
|
|
8
8
|
contextBreakdown: ContextBreakdown;
|
|
9
9
|
}>;
|
|
10
|
-
declare function buildInitialMessages(systemPrompt: string, conversationHistory: string, userMessage: string,
|
|
11
|
-
declare function buildUserMessageContent(text: string,
|
|
10
|
+
declare function buildInitialMessages(systemPrompt: string, conversationHistory: string, userMessage: string, fileParts?: FilePart[]): any[];
|
|
11
|
+
declare function buildUserMessageContent(text: string, fileParts?: FilePart[]): string | AiSdkContentPart[];
|
|
12
12
|
//#endregion
|
|
13
13
|
export { buildConversationHistory, buildInitialMessages, buildUserMessageContent };
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
+
import { getLogger } from "../../../../logger.js";
|
|
1
2
|
import { calculateBreakdownTotal, estimateTokens } from "../../utils/token-estimator.js";
|
|
2
3
|
import { createDefaultConversationHistoryConfig, getConversationHistoryWithCompression } from "../../data/conversations.js";
|
|
3
4
|
import { getPrimaryModel, getSummarizerModel } from "./model-config.js";
|
|
5
|
+
import { normalizeMimeType } from "@inkeep/agents-core/constants/allowed-file-formats";
|
|
4
6
|
|
|
5
7
|
//#region src/domains/run/agents/generation/conversation-history.ts
|
|
8
|
+
const PDF_MEDIA_TYPE = "application/pdf";
|
|
9
|
+
const logger = getLogger("conversation-history");
|
|
10
|
+
function mapFileToAiSdkContentPart(fileValue, mimeType, metadata) {
|
|
11
|
+
if (mimeType.startsWith("image/")) return {
|
|
12
|
+
type: "image",
|
|
13
|
+
image: fileValue,
|
|
14
|
+
...metadata?.detail && { experimental_providerMetadata: { openai: { imageDetail: metadata.detail } } }
|
|
15
|
+
};
|
|
16
|
+
if (mimeType === PDF_MEDIA_TYPE) return {
|
|
17
|
+
type: "file",
|
|
18
|
+
data: fileValue,
|
|
19
|
+
mediaType: PDF_MEDIA_TYPE,
|
|
20
|
+
...metadata?.filename ? { filename: metadata.filename } : {}
|
|
21
|
+
};
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
6
24
|
async function buildConversationHistory(ctx, contextId, taskId, userMessage, streamRequestId, initialContextBreakdown) {
|
|
7
25
|
let conversationHistory = "";
|
|
8
26
|
const historyConfig = ctx.config.conversationHistoryConfig ?? createDefaultConversationHistoryConfig();
|
|
@@ -56,7 +74,7 @@ async function buildConversationHistory(ctx, contextId, taskId, userMessage, str
|
|
|
56
74
|
contextBreakdown: updatedContextBreakdown
|
|
57
75
|
};
|
|
58
76
|
}
|
|
59
|
-
function buildInitialMessages(systemPrompt, conversationHistory, userMessage,
|
|
77
|
+
function buildInitialMessages(systemPrompt, conversationHistory, userMessage, fileParts) {
|
|
60
78
|
const messages = [];
|
|
61
79
|
messages.push({
|
|
62
80
|
role: "system",
|
|
@@ -66,27 +84,32 @@ function buildInitialMessages(systemPrompt, conversationHistory, userMessage, im
|
|
|
66
84
|
role: "user",
|
|
67
85
|
content: conversationHistory
|
|
68
86
|
});
|
|
69
|
-
const userContent = buildUserMessageContent(userMessage,
|
|
87
|
+
const userContent = buildUserMessageContent(userMessage, fileParts);
|
|
70
88
|
messages.push({
|
|
71
89
|
role: "user",
|
|
72
90
|
content: userContent
|
|
73
91
|
});
|
|
74
92
|
return messages;
|
|
75
93
|
}
|
|
76
|
-
function buildUserMessageContent(text,
|
|
77
|
-
if (!
|
|
94
|
+
function buildUserMessageContent(text, fileParts) {
|
|
95
|
+
if (!fileParts || fileParts.length === 0) return text;
|
|
78
96
|
const content = [{
|
|
79
97
|
type: "text",
|
|
80
98
|
text
|
|
81
99
|
}];
|
|
82
|
-
for (const part of
|
|
100
|
+
for (const part of fileParts) {
|
|
83
101
|
const file = part.file;
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
const fileValue = "uri" in file && file.uri ? new URL(file.uri) : `data:${file.mimeType || ""};base64,${file.bytes}`;
|
|
103
|
+
const mimeType = normalizeMimeType(file.mimeType ?? "");
|
|
104
|
+
const mappedPart = mapFileToAiSdkContentPart(fileValue, mimeType, {
|
|
105
|
+
detail: typeof part.metadata?.detail === "string" ? part.metadata.detail : void 0,
|
|
106
|
+
filename: typeof part.metadata?.filename === "string" ? part.metadata.filename : void 0
|
|
107
|
+
});
|
|
108
|
+
if (mappedPart) content.push(mappedPart);
|
|
109
|
+
else logger.warn({
|
|
110
|
+
mimeType,
|
|
111
|
+
source: "user-message"
|
|
112
|
+
}, "Dropping unsupported file content part");
|
|
90
113
|
}
|
|
91
114
|
return content;
|
|
92
115
|
}
|
|
@@ -88,7 +88,7 @@ async function runGenerate(ctx, userParts, runtimeContext) {
|
|
|
88
88
|
const metadata = part.metadata;
|
|
89
89
|
return `\n\n<structured_data${metadata?.source ? ` (source: ${metadata.source})` : ""}>\n${JSON.stringify(part.data, null, 2)}\n</structured_data>`;
|
|
90
90
|
}).join("") : ""}`;
|
|
91
|
-
const
|
|
91
|
+
const fileParts = userParts.filter((part) => part.kind === "file");
|
|
92
92
|
const conversationIdForSpan = runtimeContext?.metadata?.conversationId;
|
|
93
93
|
return tracer.startActiveSpan("agent.generate", { attributes: {
|
|
94
94
|
"subAgent.id": ctx.config.id,
|
|
@@ -108,9 +108,14 @@ async function runGenerate(ctx, userParts, runtimeContext) {
|
|
|
108
108
|
breakdownAttributes["context.breakdown.total_tokens"] = contextBreakdown.total;
|
|
109
109
|
span.setAttributes(breakdownAttributes);
|
|
110
110
|
const { primaryModelSettings, modelSettings, hasStructuredOutput, timeoutMs } = configureModelSettings(ctx);
|
|
111
|
+
const inlinePdfFileCount = fileParts.filter((part) => part.file.mimeType?.toLowerCase().startsWith("application/pdf") === true).length;
|
|
112
|
+
span.setAttributes({
|
|
113
|
+
"input.file_count": fileParts.length,
|
|
114
|
+
"input.pdf_file_count": inlinePdfFileCount
|
|
115
|
+
});
|
|
111
116
|
let response;
|
|
112
117
|
let textResponse;
|
|
113
|
-
const messages = buildInitialMessages(systemPrompt, conversationHistory, userMessage,
|
|
118
|
+
const messages = buildInitialMessages(systemPrompt, conversationHistory, userMessage, fileParts);
|
|
114
119
|
const { originalMessageCount, compressor } = setupCompression(ctx, messages, sessionId, contextId, primaryModelSettings);
|
|
115
120
|
const streamConfig = {
|
|
116
121
|
...modelSettings,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isToolResultDenied } from "../../utils/tool-result.js";
|
|
2
|
-
import { makeMessageContentParts } from "../../services/blob-storage/
|
|
3
|
-
import { buildPersistedMessageContent } from "../../services/blob-storage/
|
|
2
|
+
import { makeMessageContentParts } from "../../services/blob-storage/file-upload.js";
|
|
3
|
+
import { buildPersistedMessageContent } from "../../services/blob-storage/file-upload-helpers.js";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/run/agents/generation/tool-result-for-conversation-history.ts
|
|
6
6
|
function filterNonTextToolResultContentForConversationHistory(result) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentConfig, DelegateRelation } from "./agent-types.js";
|
|
2
2
|
import "./Agent.js";
|
|
3
3
|
import { InternalRelation } from "../utils/project.js";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _inkeep_agents_core7 from "@inkeep/agents-core";
|
|
5
5
|
import { CredentialStoreRegistry, FullExecutionContext } from "@inkeep/agents-core";
|
|
6
6
|
import * as ai0 from "ai";
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ declare function createDelegateToAgentTool({
|
|
|
45
45
|
message: string;
|
|
46
46
|
}, {
|
|
47
47
|
toolCallId: any;
|
|
48
|
-
result:
|
|
48
|
+
result: _inkeep_agents_core7.Message | _inkeep_agents_core7.Task;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
51
51
|
* Parameters for building a transfer relation config
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono19 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/run/routes/auth.d.ts
|
|
5
5
|
declare function getAnonJwtSecret(): Uint8Array;
|
|
6
|
-
declare const app: OpenAPIHono<
|
|
6
|
+
declare const app: OpenAPIHono<hono19.Env, {}, "/">;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { app as default, getAnonJwtSecret };
|
|
@@ -7,9 +7,9 @@ import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
|
7
7
|
import { contextValidationMiddleware } from "../context/validation.js";
|
|
8
8
|
import { handleContextResolution } from "../context/context.js";
|
|
9
9
|
import "../context/index.js";
|
|
10
|
-
import { ImageContentItemSchema } from "../types/chat.js";
|
|
10
|
+
import { FileContentItemSchema, ImageContentItemSchema } from "../types/chat.js";
|
|
11
11
|
import { extractTextFromParts, getMessagePartsFromOpenAIContent } from "../utils/message-parts.js";
|
|
12
|
-
import { buildPersistedMessageContent } from "../services/blob-storage/
|
|
12
|
+
import { buildPersistedMessageContent } from "../services/blob-storage/file-upload-helpers.js";
|
|
13
13
|
import { toolApprovalUiBus } from "../session/ToolApprovalUiBus.js";
|
|
14
14
|
import { OpenAPIHono, z } from "@hono/zod-openapi";
|
|
15
15
|
import { PartSchema, createApiError, createMessage, createOrGetConversation, generateId, getActiveAgentForConversation, getConversationId, setActiveAgentForConversation } from "@inkeep/agents-core";
|
|
@@ -39,10 +39,14 @@ const chatCompletionsRoute = createProtectedRoute({
|
|
|
39
39
|
"function",
|
|
40
40
|
"tool"
|
|
41
41
|
]).describe("The role of the message"),
|
|
42
|
-
content: z.union([z.string(), z.array(z.discriminatedUnion("type", [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
content: z.union([z.string(), z.array(z.discriminatedUnion("type", [
|
|
43
|
+
z.object({
|
|
44
|
+
type: z.literal("text"),
|
|
45
|
+
text: z.string()
|
|
46
|
+
}),
|
|
47
|
+
ImageContentItemSchema,
|
|
48
|
+
FileContentItemSchema
|
|
49
|
+
]))]).describe("The message content"),
|
|
46
50
|
name: z.string().optional().describe("The name of the message sender")
|
|
47
51
|
})).describe("The conversation messages"),
|
|
48
52
|
temperature: z.number().optional().describe("Controls randomness (0-1)"),
|
|
@@ -7,9 +7,9 @@ import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
|
7
7
|
import { contextValidationMiddleware } from "../context/validation.js";
|
|
8
8
|
import { handleContextResolution } from "../context/context.js";
|
|
9
9
|
import "../context/index.js";
|
|
10
|
-
import {
|
|
10
|
+
import { VercelMessageSchema } from "../types/chat.js";
|
|
11
11
|
import { extractTextFromParts, getMessagePartsFromVercelContent } from "../utils/message-parts.js";
|
|
12
|
-
import { buildPersistedMessageContent } from "../services/blob-storage/
|
|
12
|
+
import { buildPersistedMessageContent } from "../services/blob-storage/file-upload-helpers.js";
|
|
13
13
|
import { pendingToolApprovalManager } from "../session/PendingToolApprovalManager.js";
|
|
14
14
|
import { toolApprovalUiBus } from "../session/ToolApprovalUiBus.js";
|
|
15
15
|
import { OpenAPIHono, z } from "@hono/zod-openapi";
|
|
@@ -33,47 +33,7 @@ const chatDataStreamRoute = createProtectedRoute({
|
|
|
33
33
|
permission: inheritedRunApiKeyAuth(),
|
|
34
34
|
request: { body: { content: { "application/json": { schema: z.object({
|
|
35
35
|
model: z.string().optional(),
|
|
36
|
-
messages: z.array(
|
|
37
|
-
role: z.enum([
|
|
38
|
-
"system",
|
|
39
|
-
"user",
|
|
40
|
-
"assistant",
|
|
41
|
-
"function",
|
|
42
|
-
"tool"
|
|
43
|
-
]),
|
|
44
|
-
content: z.any(),
|
|
45
|
-
parts: z.array(z.union([
|
|
46
|
-
z.object({
|
|
47
|
-
type: z.literal("text"),
|
|
48
|
-
text: z.string()
|
|
49
|
-
}),
|
|
50
|
-
z.object({
|
|
51
|
-
type: z.literal("image"),
|
|
52
|
-
text: ImageUrlSchema
|
|
53
|
-
}),
|
|
54
|
-
z.object({
|
|
55
|
-
type: z.union([z.enum([
|
|
56
|
-
"audio",
|
|
57
|
-
"video",
|
|
58
|
-
"file"
|
|
59
|
-
]), z.string().regex(/^data-/, "Type must start with \"data-\"")]),
|
|
60
|
-
text: z.string().optional()
|
|
61
|
-
}),
|
|
62
|
-
z.object({
|
|
63
|
-
type: z.string().regex(/^tool-/, "Type must start with \"tool-\""),
|
|
64
|
-
toolCallId: z.string(),
|
|
65
|
-
state: z.any(),
|
|
66
|
-
approval: z.object({
|
|
67
|
-
id: z.string(),
|
|
68
|
-
approved: z.boolean().optional(),
|
|
69
|
-
reason: z.string().optional()
|
|
70
|
-
}).optional(),
|
|
71
|
-
input: z.any().optional(),
|
|
72
|
-
callProviderMetadata: z.any().optional()
|
|
73
|
-
}),
|
|
74
|
-
z.object({ type: z.literal("step-start") })
|
|
75
|
-
])).optional()
|
|
76
|
-
})),
|
|
36
|
+
messages: z.array(VercelMessageSchema),
|
|
77
37
|
id: z.string().optional(),
|
|
78
38
|
conversationId: z.string().optional(),
|
|
79
39
|
stream: z.boolean().optional().describe("Whether to stream the response").default(true),
|