@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
|
@@ -26,12 +26,144 @@ declare const ImageContentItemSchema: z.ZodObject<{
|
|
|
26
26
|
}, z.core.$strip>;
|
|
27
27
|
}, z.core.$strip>;
|
|
28
28
|
type ImageContentItem = z.infer<typeof ImageContentItemSchema>;
|
|
29
|
-
|
|
29
|
+
declare const FileContentItemSchema: z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"file">;
|
|
31
|
+
file: z.ZodObject<{
|
|
32
|
+
file_data: z.ZodString;
|
|
33
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
type FileContentItem = z.infer<typeof FileContentItemSchema>;
|
|
37
|
+
type ContentItem = TextContentItem | ImageContentItem | FileContentItem;
|
|
30
38
|
type Message = {
|
|
31
39
|
role: 'system' | 'user' | 'assistant' | 'function' | 'tool';
|
|
32
40
|
content: string | ContentItem[];
|
|
33
41
|
name?: string;
|
|
34
42
|
};
|
|
43
|
+
declare const VercelTextPartSchema: z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"text">;
|
|
45
|
+
text: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
declare const VercelImagePartSchema: z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"image">;
|
|
49
|
+
text: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
declare const VercelFilePartSchema: z.ZodObject<{
|
|
52
|
+
type: z.ZodLiteral<"file">;
|
|
53
|
+
text: z.ZodString;
|
|
54
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
55
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
56
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
declare const VercelAudioVideoPartSchema: z.ZodObject<{
|
|
59
|
+
type: z.ZodUnion<readonly [z.ZodEnum<{
|
|
60
|
+
audio: "audio";
|
|
61
|
+
video: "video";
|
|
62
|
+
}>, z.ZodString]>;
|
|
63
|
+
text: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
declare const VercelToolApprovalPartSchema: z.ZodObject<{
|
|
66
|
+
type: z.ZodString;
|
|
67
|
+
toolCallId: z.ZodString;
|
|
68
|
+
state: z.ZodAny;
|
|
69
|
+
approval: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
approved: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
input: z.ZodOptional<z.ZodAny>;
|
|
75
|
+
callProviderMetadata: z.ZodOptional<z.ZodAny>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
declare const VercelStepStartPartSchema: z.ZodObject<{
|
|
78
|
+
type: z.ZodLiteral<"step-start">;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
declare const VercelMessagePartSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
81
|
+
type: z.ZodLiteral<"text">;
|
|
82
|
+
text: z.ZodString;
|
|
83
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
+
type: z.ZodLiteral<"image">;
|
|
85
|
+
text: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
86
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
87
|
+
type: z.ZodLiteral<"file">;
|
|
88
|
+
text: z.ZodString;
|
|
89
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
90
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
91
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
93
|
+
type: z.ZodUnion<readonly [z.ZodEnum<{
|
|
94
|
+
audio: "audio";
|
|
95
|
+
video: "video";
|
|
96
|
+
}>, z.ZodString]>;
|
|
97
|
+
text: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
99
|
+
type: z.ZodString;
|
|
100
|
+
toolCallId: z.ZodString;
|
|
101
|
+
state: z.ZodAny;
|
|
102
|
+
approval: z.ZodOptional<z.ZodObject<{
|
|
103
|
+
id: z.ZodString;
|
|
104
|
+
approved: z.ZodOptional<z.ZodBoolean>;
|
|
105
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
input: z.ZodOptional<z.ZodAny>;
|
|
108
|
+
callProviderMetadata: z.ZodOptional<z.ZodAny>;
|
|
109
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
110
|
+
type: z.ZodLiteral<"step-start">;
|
|
111
|
+
}, z.core.$strip>]>;
|
|
112
|
+
declare const VercelMessageSchema: z.ZodObject<{
|
|
113
|
+
role: z.ZodEnum<{
|
|
114
|
+
function: "function";
|
|
115
|
+
user: "user";
|
|
116
|
+
system: "system";
|
|
117
|
+
assistant: "assistant";
|
|
118
|
+
tool: "tool";
|
|
119
|
+
}>;
|
|
120
|
+
content: z.ZodAny;
|
|
121
|
+
parts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
122
|
+
type: z.ZodLiteral<"text">;
|
|
123
|
+
text: z.ZodString;
|
|
124
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
125
|
+
type: z.ZodLiteral<"image">;
|
|
126
|
+
text: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
127
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
128
|
+
type: z.ZodLiteral<"file">;
|
|
129
|
+
text: z.ZodString;
|
|
130
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
131
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
132
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
type: z.ZodUnion<readonly [z.ZodEnum<{
|
|
135
|
+
audio: "audio";
|
|
136
|
+
video: "video";
|
|
137
|
+
}>, z.ZodString]>;
|
|
138
|
+
text: z.ZodOptional<z.ZodString>;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
type: z.ZodString;
|
|
141
|
+
toolCallId: z.ZodString;
|
|
142
|
+
state: z.ZodAny;
|
|
143
|
+
approval: z.ZodOptional<z.ZodObject<{
|
|
144
|
+
id: z.ZodString;
|
|
145
|
+
approved: z.ZodOptional<z.ZodBoolean>;
|
|
146
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
input: z.ZodOptional<z.ZodAny>;
|
|
149
|
+
callProviderMetadata: z.ZodOptional<z.ZodAny>;
|
|
150
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
151
|
+
type: z.ZodLiteral<"step-start">;
|
|
152
|
+
}, z.core.$strip>]>>>;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
declare const VercelContentPartSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
155
|
+
type: z.ZodLiteral<"text">;
|
|
156
|
+
text: z.ZodString;
|
|
157
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
158
|
+
type: z.ZodLiteral<"image">;
|
|
159
|
+
text: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
160
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
161
|
+
type: z.ZodLiteral<"file">;
|
|
162
|
+
text: z.ZodString;
|
|
163
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
164
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
165
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
166
|
+
}, z.core.$strip>]>;
|
|
35
167
|
type ChatCompletionRequest = {
|
|
36
168
|
model: string;
|
|
37
169
|
messages: Message[];
|
|
@@ -48,4 +180,4 @@ type ChatCompletionRequest = {
|
|
|
48
180
|
runConfig?: Record<string, unknown>;
|
|
49
181
|
};
|
|
50
182
|
//#endregion
|
|
51
|
-
export { ChatCompletionRequest, ContentItem, ImageContentItem, ImageContentItemSchema, ImageDetail, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema, Message, TextContentItem };
|
|
183
|
+
export { ChatCompletionRequest, ContentItem, FileContentItem, FileContentItemSchema, ImageContentItem, ImageContentItemSchema, ImageDetail, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema, Message, TextContentItem, VercelAudioVideoPartSchema, VercelContentPartSchema, VercelFilePartSchema, VercelImagePartSchema, VercelMessagePartSchema, VercelMessageSchema, VercelStepStartPartSchema, VercelTextPartSchema, VercelToolApprovalPartSchema };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
|
-
import { DATA_URI_IMAGE_BASE64_REGEX } from "@inkeep/agents-core/constants/allowed-
|
|
2
|
+
import { DATA_URI_IMAGE_BASE64_REGEX, DATA_URI_PDF_BASE64_REGEX } from "@inkeep/agents-core/constants/allowed-file-formats";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/run/types/chat.ts
|
|
5
|
-
const
|
|
5
|
+
const hasValidBase64Payload = (val) => {
|
|
6
6
|
const base64Part = val.split(",")[1];
|
|
7
7
|
return /^[A-Za-z0-9+/]+={0,2}$/.test(base64Part ?? "");
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
|
+
const ImageDataUriSchema = z.string().regex(DATA_URI_IMAGE_BASE64_REGEX, "Image must be PNG, JPEG, or WebP format (GIF not supported by all providers)").refine(hasValidBase64Payload, "Invalid base64 data in image data URI");
|
|
10
|
+
const PdfDataUriSchema = z.string().regex(DATA_URI_PDF_BASE64_REGEX, "File must be a PDF data URI").refine(hasValidBase64Payload, "Invalid base64 data in PDF data URI");
|
|
11
|
+
const ImageUrlSchema = z.union([z.httpUrl(), ImageDataUriSchema]);
|
|
9
12
|
/** OpenAI-specific image detail level. Has no effect on other providers. */
|
|
10
13
|
const ImageDetailEnum = [
|
|
11
14
|
"auto",
|
|
@@ -20,6 +23,70 @@ const ImageContentItemSchema = z.object({
|
|
|
20
23
|
detail: ImageDetailSchema.optional()
|
|
21
24
|
})
|
|
22
25
|
});
|
|
26
|
+
const FileContentItemSchema = z.object({
|
|
27
|
+
type: z.literal("file"),
|
|
28
|
+
file: z.object({
|
|
29
|
+
file_data: PdfDataUriSchema,
|
|
30
|
+
filename: z.string().optional()
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
const VercelTextPartSchema = z.object({
|
|
34
|
+
type: z.literal("text"),
|
|
35
|
+
text: z.string()
|
|
36
|
+
});
|
|
37
|
+
const VercelImagePartSchema = z.object({
|
|
38
|
+
type: z.literal("image"),
|
|
39
|
+
text: ImageUrlSchema
|
|
40
|
+
});
|
|
41
|
+
const VercelFilePartBaseSchema = z.object({
|
|
42
|
+
type: z.literal("file"),
|
|
43
|
+
text: z.string(),
|
|
44
|
+
mediaType: z.string().optional(),
|
|
45
|
+
mimeType: z.string().optional(),
|
|
46
|
+
filename: z.string().optional()
|
|
47
|
+
});
|
|
48
|
+
const VercelFilePartSchema = VercelFilePartBaseSchema.refine((value) => Boolean(value.mediaType || value.mimeType), { message: "Either mediaType or mimeType is required for file parts" });
|
|
49
|
+
const VercelAudioVideoPartSchema = z.object({
|
|
50
|
+
type: z.union([z.enum(["audio", "video"]), z.string().regex(/^data-/, "Type must start with \"data-\"")]),
|
|
51
|
+
text: z.string().optional()
|
|
52
|
+
});
|
|
53
|
+
const VercelToolApprovalPartSchema = z.object({
|
|
54
|
+
type: z.string().regex(/^tool-/, "Type must start with \"tool-\""),
|
|
55
|
+
toolCallId: z.string(),
|
|
56
|
+
state: z.any(),
|
|
57
|
+
approval: z.object({
|
|
58
|
+
id: z.string(),
|
|
59
|
+
approved: z.boolean().optional(),
|
|
60
|
+
reason: z.string().optional()
|
|
61
|
+
}).optional(),
|
|
62
|
+
input: z.any().optional(),
|
|
63
|
+
callProviderMetadata: z.any().optional()
|
|
64
|
+
});
|
|
65
|
+
const VercelStepStartPartSchema = z.object({ type: z.literal("step-start") });
|
|
66
|
+
const VercelMessagePartSchema = z.union([
|
|
67
|
+
VercelTextPartSchema,
|
|
68
|
+
VercelImagePartSchema,
|
|
69
|
+
VercelFilePartSchema,
|
|
70
|
+
VercelAudioVideoPartSchema,
|
|
71
|
+
VercelToolApprovalPartSchema,
|
|
72
|
+
VercelStepStartPartSchema
|
|
73
|
+
]);
|
|
74
|
+
const VercelMessageSchema = z.object({
|
|
75
|
+
role: z.enum([
|
|
76
|
+
"system",
|
|
77
|
+
"user",
|
|
78
|
+
"assistant",
|
|
79
|
+
"function",
|
|
80
|
+
"tool"
|
|
81
|
+
]),
|
|
82
|
+
content: z.any(),
|
|
83
|
+
parts: z.array(VercelMessagePartSchema).optional()
|
|
84
|
+
});
|
|
85
|
+
const VercelContentPartSchema = z.union([
|
|
86
|
+
VercelTextPartSchema,
|
|
87
|
+
VercelImagePartSchema,
|
|
88
|
+
VercelFilePartBaseSchema
|
|
89
|
+
]);
|
|
23
90
|
|
|
24
91
|
//#endregion
|
|
25
|
-
export { ImageContentItemSchema, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema };
|
|
92
|
+
export { FileContentItemSchema, ImageContentItemSchema, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema, VercelAudioVideoPartSchema, VercelContentPartSchema, VercelFilePartSchema, VercelImagePartSchema, VercelMessagePartSchema, VercelMessageSchema, VercelStepStartPartSchema, VercelTextPartSchema, VercelToolApprovalPartSchema };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
|
-
import { ImageUrlSchema } from "../types/chat.js";
|
|
3
|
-
import { z } from "@hono/zod-openapi";
|
|
2
|
+
import { ImageUrlSchema, VercelContentPartSchema } from "../types/chat.js";
|
|
4
3
|
import { FilePartSchema, TextPartSchema } from "@inkeep/agents-core";
|
|
5
4
|
|
|
6
5
|
//#region src/domains/run/utils/message-parts.ts
|
|
@@ -11,15 +10,9 @@ const isTextContentItem = (item) => {
|
|
|
11
10
|
const isImageContentItem = (item) => {
|
|
12
11
|
return item.type === "image_url" && "image_url" in item && item.image_url != null && ImageUrlSchema.safeParse(item.image_url.url).success;
|
|
13
12
|
};
|
|
14
|
-
const
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
const imageContentPartSchema = z.object({
|
|
19
|
-
type: z.literal("image"),
|
|
20
|
-
text: ImageUrlSchema
|
|
21
|
-
});
|
|
22
|
-
const vercelMessageContentPartSchema = z.union([textContentPartSchema, imageContentPartSchema]);
|
|
13
|
+
const isFileContentItem = (item) => {
|
|
14
|
+
return item.type === "file";
|
|
15
|
+
};
|
|
23
16
|
const buildTextPart = (text) => {
|
|
24
17
|
return TextPartSchema.parse({
|
|
25
18
|
kind: "text",
|
|
@@ -36,26 +29,34 @@ const parseDataUri = (dataUri) => {
|
|
|
36
29
|
};
|
|
37
30
|
const buildFilePart = (uri, options) => {
|
|
38
31
|
const parsed = parseDataUri(uri);
|
|
39
|
-
if (parsed)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
if (parsed) {
|
|
33
|
+
const metadata$1 = {};
|
|
34
|
+
if (options?.detail) metadata$1.detail = options.detail;
|
|
35
|
+
if (options?.filename) metadata$1.filename = options.filename;
|
|
36
|
+
return FilePartSchema.parse({
|
|
37
|
+
kind: "file",
|
|
38
|
+
file: {
|
|
39
|
+
bytes: parsed.base64Data,
|
|
40
|
+
mimeType: parsed.mimeType
|
|
41
|
+
},
|
|
42
|
+
...Object.keys(metadata$1).length > 0 ? { metadata: metadata$1 } : {}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
47
45
|
try {
|
|
48
46
|
new URL(uri);
|
|
49
47
|
} catch {
|
|
50
48
|
throw new Error(`Invalid image URI: expected valid data URI or HTTP URL`);
|
|
51
49
|
}
|
|
50
|
+
const metadata = {};
|
|
51
|
+
if (options?.detail) metadata.detail = options.detail;
|
|
52
|
+
if (options?.filename) metadata.filename = options.filename;
|
|
52
53
|
return FilePartSchema.parse({
|
|
53
54
|
kind: "file",
|
|
54
55
|
file: {
|
|
55
56
|
uri,
|
|
56
|
-
mimeType: "
|
|
57
|
+
mimeType: options?.mimeType || "application/octet-stream"
|
|
57
58
|
},
|
|
58
|
-
...
|
|
59
|
+
...Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
59
60
|
});
|
|
60
61
|
};
|
|
61
62
|
const extractTextFromParts = (parts) => {
|
|
@@ -64,21 +65,22 @@ const extractTextFromParts = (parts) => {
|
|
|
64
65
|
const getMessagePartsFromOpenAIContent = (content) => {
|
|
65
66
|
if (typeof content === "string") return [buildTextPart(content)];
|
|
66
67
|
const textChunks = [];
|
|
67
|
-
const
|
|
68
|
+
const fileParts = [];
|
|
68
69
|
let skipped = 0;
|
|
69
70
|
for (const item of content) if (isTextContentItem(item)) textChunks.push(item.text);
|
|
70
|
-
else if (isImageContentItem(item))
|
|
71
|
+
else if (isImageContentItem(item)) fileParts.push(buildFilePart(item.image_url.url, { detail: item.image_url.detail }));
|
|
72
|
+
else if (isFileContentItem(item)) fileParts.push(buildFilePart(item.file.file_data, { filename: item.file.filename }));
|
|
71
73
|
else skipped += 1;
|
|
72
74
|
if (skipped > 0) logger.warn({
|
|
73
75
|
total: content.length,
|
|
74
76
|
skipped,
|
|
75
77
|
accepted: content.length - skipped
|
|
76
78
|
}, "Some content items were dropped due to invalid or unsupported type");
|
|
77
|
-
return [...textChunks.length > 0 ? [buildTextPart(textChunks.join(" "))] : [], ...
|
|
79
|
+
return [...textChunks.length > 0 ? [buildTextPart(textChunks.join(" "))] : [], ...fileParts];
|
|
78
80
|
};
|
|
79
81
|
const getMessagePartsFromVercelContent = (content, parts) => {
|
|
80
82
|
const rawParts = parts ?? [];
|
|
81
|
-
const parsedParts = rawParts.map((part) =>
|
|
83
|
+
const parsedParts = rawParts.map((part) => VercelContentPartSchema.safeParse(part)).filter((result) => result.success).map((result) => result.data);
|
|
82
84
|
if (parsedParts.length < rawParts.length) logger.warn({
|
|
83
85
|
expected: rawParts.length,
|
|
84
86
|
received: parsedParts.length
|
|
@@ -89,6 +91,10 @@ const getMessagePartsFromVercelContent = (content, parts) => {
|
|
|
89
91
|
const partsFromPayload = parsedParts.map((part) => {
|
|
90
92
|
if (part.type === "text") return buildTextPart(part.text);
|
|
91
93
|
if (part.type === "image") return buildFilePart(part.text);
|
|
94
|
+
if (part.type === "file") return buildFilePart(part.text, {
|
|
95
|
+
mimeType: part.mediaType ?? part.mimeType,
|
|
96
|
+
filename: part.filename
|
|
97
|
+
});
|
|
92
98
|
return assertNever(part);
|
|
93
99
|
});
|
|
94
100
|
if (typeof content !== "string" || content === "") return partsFromPayload;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core6 from "@inkeep/agents-core";
|
|
2
2
|
import { BreakdownComponentDef, ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown } from "@inkeep/agents-core";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/run/utils/token-estimator.d.ts
|
|
@@ -17,7 +17,7 @@ interface AssembleResult {
|
|
|
17
17
|
/** The assembled prompt string */
|
|
18
18
|
prompt: string;
|
|
19
19
|
/** Token breakdown for each component */
|
|
20
|
-
breakdown:
|
|
20
|
+
breakdown: _inkeep_agents_core6.ContextBreakdown;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { AssembleResult, type BreakdownComponentDef, type ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown, estimateTokens };
|
|
@@ -108,7 +108,7 @@ declare function createInvocationIdempotentStep(params: {
|
|
|
108
108
|
projectId: string;
|
|
109
109
|
tenantId: string;
|
|
110
110
|
id: string;
|
|
111
|
-
status: "completed" | "pending" | "
|
|
111
|
+
status: "completed" | "pending" | "failed" | "running" | "cancelled";
|
|
112
112
|
ref?: {
|
|
113
113
|
type: "tag" | "commit" | "branch";
|
|
114
114
|
name: string;
|
|
@@ -153,7 +153,7 @@ declare function markRunningStep(params: {
|
|
|
153
153
|
projectId: string;
|
|
154
154
|
tenantId: string;
|
|
155
155
|
id: string;
|
|
156
|
-
status: "completed" | "pending" | "
|
|
156
|
+
status: "completed" | "pending" | "failed" | "running" | "cancelled";
|
|
157
157
|
ref?: {
|
|
158
158
|
type: "tag" | "commit" | "branch";
|
|
159
159
|
name: string;
|
|
@@ -185,7 +185,7 @@ declare function addConversationIdStep(params: {
|
|
|
185
185
|
projectId: string;
|
|
186
186
|
tenantId: string;
|
|
187
187
|
id: string;
|
|
188
|
-
status: "completed" | "pending" | "
|
|
188
|
+
status: "completed" | "pending" | "failed" | "running" | "cancelled";
|
|
189
189
|
ref?: {
|
|
190
190
|
type: "tag" | "commit" | "branch";
|
|
191
191
|
name: string;
|
|
@@ -215,7 +215,7 @@ declare function markCompletedStep(params: {
|
|
|
215
215
|
projectId: string;
|
|
216
216
|
tenantId: string;
|
|
217
217
|
id: string;
|
|
218
|
-
status: "completed" | "pending" | "
|
|
218
|
+
status: "completed" | "pending" | "failed" | "running" | "cancelled";
|
|
219
219
|
ref?: {
|
|
220
220
|
type: "tag" | "commit" | "branch";
|
|
221
221
|
name: string;
|
|
@@ -245,7 +245,7 @@ declare function markFailedStep(params: {
|
|
|
245
245
|
projectId: string;
|
|
246
246
|
tenantId: string;
|
|
247
247
|
id: string;
|
|
248
|
-
status: "completed" | "pending" | "
|
|
248
|
+
status: "completed" | "pending" | "failed" | "running" | "cancelled";
|
|
249
249
|
ref?: {
|
|
250
250
|
type: "tag" | "commit" | "branch";
|
|
251
251
|
name: string;
|
|
@@ -288,7 +288,7 @@ declare function resetInvocationToPendingStep(params: {
|
|
|
288
288
|
projectId: string;
|
|
289
289
|
tenantId: string;
|
|
290
290
|
id: string;
|
|
291
|
-
status: "completed" | "pending" | "
|
|
291
|
+
status: "completed" | "pending" | "failed" | "running" | "cancelled";
|
|
292
292
|
ref?: {
|
|
293
293
|
type: "tag" | "commit" | "branch";
|
|
294
294
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { SSOProviderConfig, UserAuthConfig, createAgentsApp } from "./factory.js
|
|
|
6
6
|
import "./sentry.js";
|
|
7
7
|
import { Hono } from "hono";
|
|
8
8
|
import * as zod32 from "zod";
|
|
9
|
-
import * as
|
|
9
|
+
import * as hono_types3 from "hono/types";
|
|
10
10
|
import * as better_auth43 from "better-auth";
|
|
11
11
|
import * as better_auth_plugins4 from "better-auth/plugins";
|
|
12
12
|
|
|
@@ -474,6 +474,6 @@ declare const auth: better_auth43.Auth<{
|
|
|
474
474
|
}>;
|
|
475
475
|
}];
|
|
476
476
|
}>;
|
|
477
|
-
declare const app: Hono<
|
|
477
|
+
declare const app: Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
|
|
478
478
|
//#endregion
|
|
479
479
|
export { type AppConfig, type AppVariables, Hono, type NativeSandboxConfig, type SSOProviderConfig, type SandboxConfig, type UserAuthConfig, type VercelSandboxConfig, auth, createAgentsApp, createAgentsHono, app as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono0 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/evalsAuth.d.ts
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import * as hono1 from "hono";
|
|
|
7
7
|
* Middleware to authenticate API requests using Bearer token authentication
|
|
8
8
|
* First checks if token matches INKEEP_AGENTS_EVAL_API_BYPASS_SECRET,
|
|
9
9
|
*/
|
|
10
|
-
declare const evalApiKeyAuth: () =>
|
|
10
|
+
declare const evalApiKeyAuth: () => hono0.MiddlewareHandler<{
|
|
11
11
|
Variables: {
|
|
12
12
|
executionContext: BaseExecutionContext;
|
|
13
13
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono15 from "hono";
|
|
3
3
|
import { createAuth } from "@inkeep/agents-core/auth";
|
|
4
4
|
|
|
5
5
|
//#region src/middleware/manageAuth.d.ts
|
|
@@ -16,7 +16,7 @@ import { createAuth } from "@inkeep/agents-core/auth";
|
|
|
16
16
|
* EXCEPT for the legacy exception on GET /manage/tenants/:t/projects/:p/conversations/:id
|
|
17
17
|
* (see isLegacyApiKeyAllowedRoute). API keys are otherwise restricted to the run domain only.
|
|
18
18
|
*/
|
|
19
|
-
declare const manageBearerAuth: () =>
|
|
19
|
+
declare const manageBearerAuth: () => hono15.MiddlewareHandler<{
|
|
20
20
|
Variables: {
|
|
21
21
|
executionContext: BaseExecutionContext;
|
|
22
22
|
userId?: string;
|
|
@@ -30,6 +30,6 @@ declare const manageBearerAuth: () => hono18.MiddlewareHandler<{
|
|
|
30
30
|
* Uses Bearer token → manage bearer auth (bypass secret, session, Slack JWT, internal service),
|
|
31
31
|
* otherwise falls back to session auth.
|
|
32
32
|
*/
|
|
33
|
-
declare const manageBearerOrSessionAuth: () =>
|
|
33
|
+
declare const manageBearerOrSessionAuth: () => hono15.MiddlewareHandler<any, string, {}, Response>;
|
|
34
34
|
//#endregion
|
|
35
35
|
export { manageBearerAuth, manageBearerOrSessionAuth };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BaseExecutionContext, ResolvedRef } from "@inkeep/agents-core";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono17 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/projectConfig.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Middleware that fetches the full project definition from the Management API
|
|
7
7
|
*/
|
|
8
|
-
declare const projectConfigMiddleware:
|
|
8
|
+
declare const projectConfigMiddleware: hono17.MiddlewareHandler<{
|
|
9
9
|
Variables: {
|
|
10
10
|
executionContext: BaseExecutionContext;
|
|
11
11
|
resolvedRef: ResolvedRef;
|
|
@@ -15,7 +15,7 @@ declare const projectConfigMiddleware: hono2.MiddlewareHandler<{
|
|
|
15
15
|
* Creates a middleware that applies project config fetching except for specified route patterns
|
|
16
16
|
* @param skipRouteCheck - Function that returns true if the route should skip the middleware
|
|
17
17
|
*/
|
|
18
|
-
declare const projectConfigMiddlewareExcept: (skipRouteCheck: (path: string) => boolean) =>
|
|
18
|
+
declare const projectConfigMiddlewareExcept: (skipRouteCheck: (path: string) => boolean) => hono17.MiddlewareHandler<{
|
|
19
19
|
Variables: {
|
|
20
20
|
executionContext: BaseExecutionContext;
|
|
21
21
|
resolvedRef: ResolvedRef;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../types/app.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono8 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/requirePermission.d.ts
|
|
5
5
|
type Permission = {
|
|
@@ -9,6 +9,6 @@ declare const requirePermission: <Env$1 extends {
|
|
|
9
9
|
Variables: ManageAppVariables;
|
|
10
10
|
} = {
|
|
11
11
|
Variables: ManageAppVariables;
|
|
12
|
-
}>(permissions: Permission) =>
|
|
12
|
+
}>(permissions: Permission) => hono8.MiddlewareHandler<Env$1, string, {}, Response>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { requirePermission };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono9 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/runAuth.d.ts
|
|
5
|
-
declare const runApiKeyAuth: () =>
|
|
5
|
+
declare const runApiKeyAuth: () => hono9.MiddlewareHandler<{
|
|
6
6
|
Variables: {
|
|
7
7
|
executionContext: BaseExecutionContext;
|
|
8
8
|
};
|
|
@@ -11,7 +11,7 @@ declare const runApiKeyAuth: () => hono4.MiddlewareHandler<{
|
|
|
11
11
|
* Creates a middleware that applies API key authentication except for specified route patterns
|
|
12
12
|
* @param skipRouteCheck - Function that returns true if the route should skip authentication
|
|
13
13
|
*/
|
|
14
|
-
declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) =>
|
|
14
|
+
declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) => hono9.MiddlewareHandler<{
|
|
15
15
|
Variables: {
|
|
16
16
|
executionContext: BaseExecutionContext;
|
|
17
17
|
};
|
|
@@ -20,7 +20,7 @@ declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) =
|
|
|
20
20
|
* Helper middleware for endpoints that optionally support API key authentication
|
|
21
21
|
* If no auth header is present, it continues without setting the executionContext
|
|
22
22
|
*/
|
|
23
|
-
declare const runOptionalAuth: () =>
|
|
23
|
+
declare const runOptionalAuth: () => hono9.MiddlewareHandler<{
|
|
24
24
|
Variables: {
|
|
25
25
|
executionContext?: BaseExecutionContext;
|
|
26
26
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppVariables } from "../types/app.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono1 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/sessionAuth.d.ts
|
|
5
5
|
|
|
@@ -8,12 +8,12 @@ import * as hono7 from "hono";
|
|
|
8
8
|
* Requires that a user has already been authenticated via Better Auth session.
|
|
9
9
|
* Used primarily for manage routes that require an active user session.
|
|
10
10
|
*/
|
|
11
|
-
declare const sessionAuth: () =>
|
|
11
|
+
declare const sessionAuth: () => hono1.MiddlewareHandler<any, string, {}, Response>;
|
|
12
12
|
/**
|
|
13
13
|
* Global session middleware - sets user and session in context for all routes
|
|
14
14
|
* Used for all routes that require an active user session.
|
|
15
15
|
*/
|
|
16
|
-
declare const sessionContext: () =>
|
|
16
|
+
declare const sessionContext: () => hono1.MiddlewareHandler<{
|
|
17
17
|
Variables: AppVariables;
|
|
18
18
|
}, string, {}, Response>;
|
|
19
19
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono12 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/tenantAccess.d.ts
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ import * as hono9 from "hono";
|
|
|
12
12
|
* - API key user: Access only to the tenant associated with the API key
|
|
13
13
|
* - Session user: Access based on organization membership
|
|
14
14
|
*/
|
|
15
|
-
declare const requireTenantAccess: () =>
|
|
15
|
+
declare const requireTenantAccess: () => hono12.MiddlewareHandler<{
|
|
16
16
|
Variables: {
|
|
17
17
|
userId: string;
|
|
18
18
|
tenantId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono13 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/tracing.d.ts
|
|
4
|
-
declare const otelBaggageMiddleware: () =>
|
|
5
|
-
declare const executionBaggageMiddleware: () =>
|
|
4
|
+
declare const otelBaggageMiddleware: () => hono13.MiddlewareHandler<any, string, {}, Response>;
|
|
5
|
+
declare const executionBaggageMiddleware: () => hono13.MiddlewareHandler<any, string, {}, Response>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { executionBaggageMiddleware, otelBaggageMiddleware };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260320150253",
|
|
4
4
|
"description": "Unified Inkeep Agents API - combines management, runtime, and evaluation capabilities",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"pg": "^8.16.3",
|
|
74
74
|
"undici": "^7.22.0",
|
|
75
75
|
"workflow": "^4.2.0-beta.64",
|
|
76
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
77
|
-
"@inkeep/agents-email": "^0.0.0-dev-
|
|
78
|
-
"@inkeep/agents-mcp": "^0.0.0-dev-
|
|
79
|
-
"@inkeep/agents-work-apps": "^0.0.0-dev-
|
|
76
|
+
"@inkeep/agents-core": "^0.0.0-dev-20260320150253",
|
|
77
|
+
"@inkeep/agents-email": "^0.0.0-dev-20260320150253",
|
|
78
|
+
"@inkeep/agents-mcp": "^0.0.0-dev-20260320150253",
|
|
79
|
+
"@inkeep/agents-work-apps": "^0.0.0-dev-20260320150253"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@hono/zod-openapi": "^1.1.5",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/domains/run/services/blob-storage/image-content-security.d.ts
|
|
2
|
-
declare function normalizeInlineImageBytes(file: {
|
|
3
|
-
bytes: string;
|
|
4
|
-
mimeType?: string;
|
|
5
|
-
}): Promise<{
|
|
6
|
-
data: Uint8Array;
|
|
7
|
-
mimeType: string;
|
|
8
|
-
}>;
|
|
9
|
-
declare function resolveDownloadedImageMimeType(data: Uint8Array, headerContentType: string): Promise<string>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { normalizeInlineImageBytes, resolveDownloadedImageMimeType };
|