@inkeep/agents-api 0.0.0-dev-20260325103346 → 0.0.0-dev-20260325193448
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 +86 -86
- package/dist/createApp.d.ts +2 -2
- package/dist/data/db/manageDbClient.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/scheduled-triggers.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/relationTools.d.ts +2 -2
- package/dist/domains/run/handlers/executionHandler.d.ts +1 -1
- package/dist/domains/run/routes/auth.d.ts +2 -2
- package/dist/domains/run/routes/chat.js +7 -2
- package/dist/domains/run/routes/chatDataStream.js +7 -2
- package/dist/domains/run/services/blob-storage/external-file-downloader.d.ts +8 -2
- package/dist/domains/run/services/blob-storage/external-file-downloader.js +24 -21
- package/dist/domains/run/services/blob-storage/file-content-security.d.ts +2 -2
- package/dist/domains/run/services/blob-storage/file-content-security.js +8 -3
- package/dist/domains/run/services/blob-storage/file-security-errors.d.ts +5 -4
- package/dist/domains/run/services/blob-storage/file-security-errors.js +8 -6
- package/dist/domains/run/services/blob-storage/file-upload-helpers.d.ts +8 -1
- package/dist/domains/run/services/blob-storage/file-upload-helpers.js +44 -1
- package/dist/domains/run/services/blob-storage/file-upload.js +15 -4
- package/dist/domains/run/services/blob-storage/file-url-security.d.ts +2 -1
- package/dist/domains/run/services/blob-storage/file-url-security.js +8 -2
- package/dist/domains/run/tools/distill-conversation-history-tool.d.ts +1 -1
- package/dist/domains/run/types/chat.d.ts +16 -19
- package/dist/domains/run/types/chat.js +7 -8
- package/dist/domains/run/utils/message-parts.js +7 -4
- package/dist/domains/run/utils/token-estimator.d.ts +2 -2
- package/dist/factory.d.ts +3 -3
- 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
|
@@ -59,11 +59,12 @@ declare class BlockedInlineUnsupportedFileBytesError extends FileSecurityError {
|
|
|
59
59
|
declare class BlockedExternalUnsupportedBytesError extends FileSecurityError {
|
|
60
60
|
constructor(contentType: string);
|
|
61
61
|
}
|
|
62
|
-
declare class BlockedExternalPdfUrlNotSupportedError extends FileSecurityError {
|
|
63
|
-
constructor();
|
|
64
|
-
}
|
|
65
62
|
declare class InvalidInlineFileMalformedBase64Error extends FileSecurityError {
|
|
66
63
|
constructor();
|
|
67
64
|
}
|
|
65
|
+
declare class PdfUrlIngestionError extends FileSecurityError {
|
|
66
|
+
readonly sourceUrl: string;
|
|
67
|
+
constructor(sourceUrl: string, options?: ErrorOptions);
|
|
68
|
+
}
|
|
68
69
|
//#endregion
|
|
69
|
-
export { BlockedConnectionToPrivateIpError, BlockedDisallowedPortError, BlockedEmbeddedCredentialsError, BlockedExternalFileExceedingError, BlockedExternalFileLargerThanError,
|
|
70
|
+
export { BlockedConnectionToPrivateIpError, BlockedDisallowedPortError, BlockedEmbeddedCredentialsError, BlockedExternalFileExceedingError, BlockedExternalFileLargerThanError, BlockedExternalUnsupportedBytesError, BlockedInlineFileExceedingError, BlockedInlineUnsupportedFileBytesError, BlockedUnsupportedSchemeError, BlockedUrlResolvingToPrivateIpError, ExternalFileResponseBodyEmptyError, FailedToDownloadError, FileSecurityError, InvalidExternalFileUrlError, InvalidInlineFileMalformedBase64Error, NoIpResolvedError, PdfUrlIngestionError, RedirectMissingLocationError, TimedOutDownloadingError, TooManyRedirectsError, UnableToResolveHostError, UnexpectedRedirectStateError };
|
|
@@ -100,16 +100,18 @@ var BlockedExternalUnsupportedBytesError = class extends FileSecurityError {
|
|
|
100
100
|
super(`Blocked external file with unsupported bytes signature (content-type: ${contentType})`);
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
var BlockedExternalPdfUrlNotSupportedError = class extends FileSecurityError {
|
|
104
|
-
constructor() {
|
|
105
|
-
super("External PDF URLs are not supported; provide PDFs as data URIs");
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
103
|
var InvalidInlineFileMalformedBase64Error = class extends FileSecurityError {
|
|
109
104
|
constructor() {
|
|
110
105
|
super("Invalid inline file: malformed base64 payload");
|
|
111
106
|
}
|
|
112
107
|
};
|
|
108
|
+
var PdfUrlIngestionError = class extends FileSecurityError {
|
|
109
|
+
sourceUrl;
|
|
110
|
+
constructor(sourceUrl, options) {
|
|
111
|
+
super(`Failed to ingest PDF URL: ${sourceUrl}`, options);
|
|
112
|
+
this.sourceUrl = sourceUrl;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
113
115
|
|
|
114
116
|
//#endregion
|
|
115
|
-
export { BlockedConnectionToPrivateIpError, BlockedDisallowedPortError, BlockedEmbeddedCredentialsError, BlockedExternalFileExceedingError, BlockedExternalFileLargerThanError,
|
|
117
|
+
export { BlockedConnectionToPrivateIpError, BlockedDisallowedPortError, BlockedEmbeddedCredentialsError, BlockedExternalFileExceedingError, BlockedExternalFileLargerThanError, BlockedExternalUnsupportedBytesError, BlockedInlineFileExceedingError, BlockedInlineUnsupportedFileBytesError, BlockedUnsupportedSchemeError, BlockedUrlResolvingToPrivateIpError, ExternalFileResponseBodyEmptyError, FailedToDownloadError, FileSecurityError, InvalidExternalFileUrlError, InvalidInlineFileMalformedBase64Error, NoIpResolvedError, PdfUrlIngestionError, RedirectMissingLocationError, TimedOutDownloadingError, TooManyRedirectsError, UnableToResolveHostError, UnexpectedRedirectStateError };
|
|
@@ -2,6 +2,13 @@ import { UploadContext } from "./file-upload.js";
|
|
|
2
2
|
import { MessageContent, Part } from "@inkeep/agents-core";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/run/services/blob-storage/file-upload-helpers.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fetches each remote `application/pdf` file part (http(s) `uri`), replaces it with an inline
|
|
8
|
+
* base64 `bytes` part. Full response bodies are buffered in memory up to the same limit as
|
|
9
|
+
* `downloadExternalFile` (see `MAX_FILE_BYTES`); streaming ingestion is not supported yet.
|
|
10
|
+
*/
|
|
11
|
+
declare function inlineExternalPdfUrlParts(parts: Part[]): Promise<Part[]>;
|
|
5
12
|
declare function buildPersistedMessageContent(text: string, parts: Part[], ctx: UploadContext): Promise<MessageContent>;
|
|
6
13
|
//#endregion
|
|
7
|
-
export { buildPersistedMessageContent };
|
|
14
|
+
export { buildPersistedMessageContent, inlineExternalPdfUrlParts };
|
|
@@ -1,8 +1,51 @@
|
|
|
1
1
|
import { getLogger } from "../../../../logger.js";
|
|
2
|
+
import { PdfUrlIngestionError } from "./file-security-errors.js";
|
|
3
|
+
import { makeSanitizedSourceUrl } from "./file-url-security.js";
|
|
4
|
+
import { downloadExternalFile } from "./external-file-downloader.js";
|
|
2
5
|
import { hasFileParts, makeMessageContentParts, uploadPartsFiles } from "./file-upload.js";
|
|
3
6
|
|
|
4
7
|
//#region src/domains/run/services/blob-storage/file-upload-helpers.ts
|
|
5
8
|
const logger = getLogger("file-upload-helpers");
|
|
9
|
+
function isRemoteHttpOrHttpsUrl(uri) {
|
|
10
|
+
const lower = uri.toLowerCase();
|
|
11
|
+
return lower.startsWith("https://") || lower.startsWith("http://");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Fetches each remote `application/pdf` file part (http(s) `uri`), replaces it with an inline
|
|
15
|
+
* base64 `bytes` part. Full response bodies are buffered in memory up to the same limit as
|
|
16
|
+
* `downloadExternalFile` (see `MAX_FILE_BYTES`); streaming ingestion is not supported yet.
|
|
17
|
+
*/
|
|
18
|
+
async function inlineExternalPdfUrlParts(parts) {
|
|
19
|
+
const result = [];
|
|
20
|
+
for (const part of parts) {
|
|
21
|
+
if (part.kind !== "file") {
|
|
22
|
+
result.push(part);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const file = part.file;
|
|
26
|
+
if (!("uri" in file) || !file.uri || file.mimeType?.toLowerCase() !== "application/pdf" || !isRemoteHttpOrHttpsUrl(file.uri)) {
|
|
27
|
+
result.push(part);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const downloaded = await downloadExternalFile(file.uri, { expectedMimeType: "application/pdf" });
|
|
32
|
+
result.push({
|
|
33
|
+
kind: "file",
|
|
34
|
+
file: {
|
|
35
|
+
bytes: Buffer.from(downloaded.data).toString("base64"),
|
|
36
|
+
mimeType: downloaded.mimeType
|
|
37
|
+
},
|
|
38
|
+
metadata: {
|
|
39
|
+
...part.metadata || {},
|
|
40
|
+
sourceUrl: makeSanitizedSourceUrl(file.uri)
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new PdfUrlIngestionError(makeSanitizedSourceUrl(file.uri), { cause: error instanceof Error ? error : new Error(String(error)) });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
6
49
|
async function buildPersistedMessageContent(text, parts, ctx) {
|
|
7
50
|
if (!hasFileParts(parts)) return { text };
|
|
8
51
|
try {
|
|
@@ -27,4 +70,4 @@ async function buildPersistedMessageContent(text, parts, ctx) {
|
|
|
27
70
|
}
|
|
28
71
|
|
|
29
72
|
//#endregion
|
|
30
|
-
export { buildPersistedMessageContent };
|
|
73
|
+
export { buildPersistedMessageContent, inlineExternalPdfUrlParts };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getLogger } from "../../../../logger.js";
|
|
2
2
|
import { getBlobStorageProvider, toBlobUri } from "./index.js";
|
|
3
3
|
import { buildStorageKey } from "./storage-keys.js";
|
|
4
|
-
import { BlockedExternalPdfUrlNotSupportedError } from "./file-security-errors.js";
|
|
5
4
|
import { normalizeInlineFileBytes } from "./file-content-security.js";
|
|
5
|
+
import { makeSanitizedSourceUrl } from "./file-url-security.js";
|
|
6
6
|
import { downloadExternalFile } from "./external-file-downloader.js";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
import { getExtensionFromMimeType } from "@inkeep/agents-core/constants/allowed-file-formats";
|
|
@@ -10,6 +10,14 @@ import { getExtensionFromMimeType } from "@inkeep/agents-core/constants/allowed-
|
|
|
10
10
|
//#region src/domains/run/services/blob-storage/file-upload.ts
|
|
11
11
|
const logger = getLogger("file-upload");
|
|
12
12
|
const FILE_UPLOAD_CONCURRENCY = 3;
|
|
13
|
+
const isRemoteHttpAttachmentUrl = (rawUrl) => {
|
|
14
|
+
try {
|
|
15
|
+
const { protocol } = new URL(rawUrl);
|
|
16
|
+
return protocol === "http:" || protocol === "https:";
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
13
21
|
async function uploadFilePart(part, ctx, index) {
|
|
14
22
|
const storage = getBlobStorageProvider();
|
|
15
23
|
const file = part.file;
|
|
@@ -20,8 +28,7 @@ async function uploadFilePart(part, ctx, index) {
|
|
|
20
28
|
data = normalized.data;
|
|
21
29
|
mimeType = normalized.mimeType;
|
|
22
30
|
} else if ("uri" in file && file.uri) {
|
|
23
|
-
|
|
24
|
-
const downloaded = await downloadExternalFile(file.uri);
|
|
31
|
+
const downloaded = await downloadExternalFile(file.uri, { expectedMimeType: file.mimeType });
|
|
25
32
|
data = downloaded.data;
|
|
26
33
|
mimeType = downloaded.mimeType;
|
|
27
34
|
} else {
|
|
@@ -49,13 +56,17 @@ async function uploadFilePart(part, ctx, index) {
|
|
|
49
56
|
mimeType,
|
|
50
57
|
size: data.length
|
|
51
58
|
}, "Uploaded file to blob storage");
|
|
59
|
+
const remoteAttachmentSourceUrl = "uri" in file && file.uri && isRemoteHttpAttachmentUrl(file.uri) ? file.uri : void 0;
|
|
52
60
|
return {
|
|
53
61
|
kind: "file",
|
|
54
62
|
file: {
|
|
55
63
|
uri: toBlobUri(key),
|
|
56
64
|
mimeType
|
|
57
65
|
},
|
|
58
|
-
...part.metadata
|
|
66
|
+
...part.metadata || remoteAttachmentSourceUrl ? { metadata: {
|
|
67
|
+
...part.metadata || {},
|
|
68
|
+
...remoteAttachmentSourceUrl ? { sourceUrl: makeSanitizedSourceUrl(remoteAttachmentSourceUrl) } : {}
|
|
69
|
+
} } : {}
|
|
59
70
|
};
|
|
60
71
|
}
|
|
61
72
|
async function uploadPartsFiles(parts, ctx) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/domains/run/services/blob-storage/file-url-security.d.ts
|
|
2
|
+
declare function makeSanitizedSourceUrl(rawUrl: string): string;
|
|
2
3
|
declare function validateExternalFileUrl(rawUrl: string): URL;
|
|
3
4
|
declare function validateUrlResolvesToPublicIp(url: URL): Promise<void>;
|
|
4
5
|
declare function isBlockedIpAddress(ipAddress: string): boolean;
|
|
5
6
|
//#endregion
|
|
6
|
-
export { isBlockedIpAddress, validateExternalFileUrl, validateUrlResolvesToPublicIp };
|
|
7
|
+
export { isBlockedIpAddress, makeSanitizedSourceUrl, validateExternalFileUrl, validateUrlResolvesToPublicIp };
|
|
@@ -3,10 +3,16 @@ import { ALLOWED_HTTP_PORTS } from "./file-security-constants.js";
|
|
|
3
3
|
import { BlockedDisallowedPortError, BlockedEmbeddedCredentialsError, BlockedUnsupportedSchemeError, BlockedUrlResolvingToPrivateIpError, FileSecurityError, InvalidExternalFileUrlError, NoIpResolvedError, UnableToResolveHostError } from "./file-security-errors.js";
|
|
4
4
|
import { lookup } from "node:dns/promises";
|
|
5
5
|
import { isIP } from "node:net";
|
|
6
|
-
import
|
|
6
|
+
import ipaddr from "ipaddr.js";
|
|
7
7
|
|
|
8
8
|
//#region src/domains/run/services/blob-storage/file-url-security.ts
|
|
9
9
|
const logger = getLogger("file-security");
|
|
10
|
+
function makeSanitizedSourceUrl(rawUrl) {
|
|
11
|
+
const parsed = new URL(rawUrl);
|
|
12
|
+
parsed.search = "";
|
|
13
|
+
parsed.hash = "";
|
|
14
|
+
return parsed.toString();
|
|
15
|
+
}
|
|
10
16
|
function validateExternalFileUrl(rawUrl) {
|
|
11
17
|
let parsed;
|
|
12
18
|
try {
|
|
@@ -66,4 +72,4 @@ function isBlockedIpAddress(ipAddress) {
|
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
//#endregion
|
|
69
|
-
export { isBlockedIpAddress, validateExternalFileUrl, validateUrlResolvesToPublicIp };
|
|
75
|
+
export { isBlockedIpAddress, makeSanitizedSourceUrl, validateExternalFileUrl, validateUrlResolvesToPublicIp };
|
|
@@ -29,9 +29,9 @@ declare const ConversationHistorySummarySchema: z.ZodObject<{
|
|
|
29
29
|
tool_call_id: z.ZodString;
|
|
30
30
|
content_summary: z.ZodString;
|
|
31
31
|
relevance: z.ZodEnum<{
|
|
32
|
-
low: "low";
|
|
33
32
|
high: "high";
|
|
34
33
|
medium: "medium";
|
|
34
|
+
low: "low";
|
|
35
35
|
}>;
|
|
36
36
|
}, z.core.$strip>>>;
|
|
37
37
|
conversation_flow: z.ZodObject<{
|
|
@@ -6,12 +6,13 @@ type TextContentItem = {
|
|
|
6
6
|
text: string;
|
|
7
7
|
};
|
|
8
8
|
declare const ImageUrlSchema: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
9
|
+
declare const PdfDataOrUrlSchema: z.ZodUnion<readonly [z.ZodString, z.ZodURL]>;
|
|
9
10
|
/** OpenAI-specific image detail level. Has no effect on other providers. */
|
|
10
11
|
declare const ImageDetailEnum: readonly ["auto", "low", "high"];
|
|
11
12
|
declare const ImageDetailSchema: z.ZodEnum<{
|
|
12
|
-
auto: "auto";
|
|
13
|
-
low: "low";
|
|
14
13
|
high: "high";
|
|
14
|
+
low: "low";
|
|
15
|
+
auto: "auto";
|
|
15
16
|
}>;
|
|
16
17
|
type ImageDetail = z.infer<typeof ImageDetailSchema>;
|
|
17
18
|
declare const ImageContentItemSchema: z.ZodObject<{
|
|
@@ -19,9 +20,9 @@ declare const ImageContentItemSchema: z.ZodObject<{
|
|
|
19
20
|
image_url: z.ZodObject<{
|
|
20
21
|
url: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
21
22
|
detail: z.ZodOptional<z.ZodEnum<{
|
|
22
|
-
auto: "auto";
|
|
23
|
-
low: "low";
|
|
24
23
|
high: "high";
|
|
24
|
+
low: "low";
|
|
25
|
+
auto: "auto";
|
|
25
26
|
}>>;
|
|
26
27
|
}, z.core.$strip>;
|
|
27
28
|
}, z.core.$strip>;
|
|
@@ -29,7 +30,7 @@ type ImageContentItem = z.infer<typeof ImageContentItemSchema>;
|
|
|
29
30
|
declare const FileContentItemSchema: z.ZodObject<{
|
|
30
31
|
type: z.ZodLiteral<"file">;
|
|
31
32
|
file: z.ZodObject<{
|
|
32
|
-
file_data: z.ZodString
|
|
33
|
+
file_data: z.ZodUnion<readonly [z.ZodString, z.ZodURL]>;
|
|
33
34
|
filename: z.ZodOptional<z.ZodString>;
|
|
34
35
|
}, z.core.$strip>;
|
|
35
36
|
}, z.core.$strip>;
|
|
@@ -50,9 +51,8 @@ declare const VercelImagePartSchema: z.ZodObject<{
|
|
|
50
51
|
}, z.core.$strip>;
|
|
51
52
|
declare const VercelFilePartSchema: z.ZodObject<{
|
|
52
53
|
type: z.ZodLiteral<"file">;
|
|
53
|
-
|
|
54
|
-
mediaType: z.
|
|
55
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
|
54
|
+
url: z.ZodString;
|
|
55
|
+
mediaType: z.ZodString;
|
|
56
56
|
filename: z.ZodOptional<z.ZodString>;
|
|
57
57
|
}, z.core.$strip>;
|
|
58
58
|
declare const VercelAudioVideoPartSchema: z.ZodObject<{
|
|
@@ -85,9 +85,8 @@ declare const VercelMessagePartSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
85
85
|
text: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
86
86
|
}, z.core.$strip>, z.ZodObject<{
|
|
87
87
|
type: z.ZodLiteral<"file">;
|
|
88
|
-
|
|
89
|
-
mediaType: z.
|
|
90
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
|
88
|
+
url: z.ZodString;
|
|
89
|
+
mediaType: z.ZodString;
|
|
91
90
|
filename: z.ZodOptional<z.ZodString>;
|
|
92
91
|
}, z.core.$strip>, z.ZodObject<{
|
|
93
92
|
type: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -112,8 +111,8 @@ declare const VercelMessagePartSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
112
111
|
declare const VercelMessageSchema: z.ZodObject<{
|
|
113
112
|
role: z.ZodEnum<{
|
|
114
113
|
function: "function";
|
|
115
|
-
user: "user";
|
|
116
114
|
system: "system";
|
|
115
|
+
user: "user";
|
|
117
116
|
assistant: "assistant";
|
|
118
117
|
tool: "tool";
|
|
119
118
|
}>;
|
|
@@ -126,9 +125,8 @@ declare const VercelMessageSchema: z.ZodObject<{
|
|
|
126
125
|
text: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
127
126
|
}, z.core.$strip>, z.ZodObject<{
|
|
128
127
|
type: z.ZodLiteral<"file">;
|
|
129
|
-
|
|
130
|
-
mediaType: z.
|
|
131
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
|
128
|
+
url: z.ZodString;
|
|
129
|
+
mediaType: z.ZodString;
|
|
132
130
|
filename: z.ZodOptional<z.ZodString>;
|
|
133
131
|
}, z.core.$strip>, z.ZodObject<{
|
|
134
132
|
type: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -159,9 +157,8 @@ declare const VercelContentPartSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
159
157
|
text: z.ZodUnion<readonly [z.ZodURL, z.ZodString]>;
|
|
160
158
|
}, z.core.$strip>, z.ZodObject<{
|
|
161
159
|
type: z.ZodLiteral<"file">;
|
|
162
|
-
|
|
163
|
-
mediaType: z.
|
|
164
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
|
160
|
+
url: z.ZodString;
|
|
161
|
+
mediaType: z.ZodString;
|
|
165
162
|
filename: z.ZodOptional<z.ZodString>;
|
|
166
163
|
}, z.core.$strip>]>;
|
|
167
164
|
type ChatCompletionRequest = {
|
|
@@ -180,4 +177,4 @@ type ChatCompletionRequest = {
|
|
|
180
177
|
runConfig?: Record<string, unknown>;
|
|
181
178
|
};
|
|
182
179
|
//#endregion
|
|
183
|
-
export { ChatCompletionRequest, ContentItem, FileContentItem, FileContentItemSchema, ImageContentItem, ImageContentItemSchema, ImageDetail, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema, Message, TextContentItem, VercelAudioVideoPartSchema, VercelContentPartSchema, VercelFilePartSchema, VercelImagePartSchema, VercelMessagePartSchema, VercelMessageSchema, VercelStepStartPartSchema, VercelTextPartSchema, VercelToolApprovalPartSchema };
|
|
180
|
+
export { ChatCompletionRequest, ContentItem, FileContentItem, FileContentItemSchema, ImageContentItem, ImageContentItemSchema, ImageDetail, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema, Message, PdfDataOrUrlSchema, TextContentItem, VercelAudioVideoPartSchema, VercelContentPartSchema, VercelFilePartSchema, VercelImagePartSchema, VercelMessagePartSchema, VercelMessageSchema, VercelStepStartPartSchema, VercelTextPartSchema, VercelToolApprovalPartSchema };
|
|
@@ -9,6 +9,7 @@ const hasValidBase64Payload = (val) => {
|
|
|
9
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
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
11
|
const ImageUrlSchema = z.union([z.httpUrl(), ImageDataUriSchema]);
|
|
12
|
+
const PdfDataOrUrlSchema = z.union([PdfDataUriSchema, z.httpUrl()]);
|
|
12
13
|
/** OpenAI-specific image detail level. Has no effect on other providers. */
|
|
13
14
|
const ImageDetailEnum = [
|
|
14
15
|
"auto",
|
|
@@ -26,7 +27,7 @@ const ImageContentItemSchema = z.object({
|
|
|
26
27
|
const FileContentItemSchema = z.object({
|
|
27
28
|
type: z.literal("file"),
|
|
28
29
|
file: z.object({
|
|
29
|
-
file_data:
|
|
30
|
+
file_data: PdfDataOrUrlSchema,
|
|
30
31
|
filename: z.string().optional()
|
|
31
32
|
})
|
|
32
33
|
});
|
|
@@ -38,14 +39,12 @@ const VercelImagePartSchema = z.object({
|
|
|
38
39
|
type: z.literal("image"),
|
|
39
40
|
text: ImageUrlSchema
|
|
40
41
|
});
|
|
41
|
-
const
|
|
42
|
+
const VercelFilePartSchema = z.object({
|
|
42
43
|
type: z.literal("file"),
|
|
43
|
-
|
|
44
|
-
mediaType: z.string()
|
|
45
|
-
mimeType: z.string().optional(),
|
|
44
|
+
url: z.string(),
|
|
45
|
+
mediaType: z.string(),
|
|
46
46
|
filename: z.string().optional()
|
|
47
47
|
});
|
|
48
|
-
const VercelFilePartSchema = VercelFilePartBaseSchema.refine((value) => Boolean(value.mediaType || value.mimeType), { message: "Either mediaType or mimeType is required for file parts" });
|
|
49
48
|
const VercelAudioVideoPartSchema = z.object({
|
|
50
49
|
type: z.union([z.enum(["audio", "video"]), z.string().regex(/^data-/, "Type must start with \"data-\"")]),
|
|
51
50
|
text: z.string().optional()
|
|
@@ -85,8 +84,8 @@ const VercelMessageSchema = z.object({
|
|
|
85
84
|
const VercelContentPartSchema = z.union([
|
|
86
85
|
VercelTextPartSchema,
|
|
87
86
|
VercelImagePartSchema,
|
|
88
|
-
|
|
87
|
+
VercelFilePartSchema
|
|
89
88
|
]);
|
|
90
89
|
|
|
91
90
|
//#endregion
|
|
92
|
-
export { FileContentItemSchema, ImageContentItemSchema, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema, VercelAudioVideoPartSchema, VercelContentPartSchema, VercelFilePartSchema, VercelImagePartSchema, VercelMessagePartSchema, VercelMessageSchema, VercelStepStartPartSchema, VercelTextPartSchema, VercelToolApprovalPartSchema };
|
|
91
|
+
export { FileContentItemSchema, ImageContentItemSchema, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema, PdfDataOrUrlSchema, VercelAudioVideoPartSchema, VercelContentPartSchema, VercelFilePartSchema, VercelImagePartSchema, VercelMessagePartSchema, VercelMessageSchema, VercelStepStartPartSchema, VercelTextPartSchema, VercelToolApprovalPartSchema };
|
|
@@ -45,7 +45,7 @@ const buildFilePart = (uri, options) => {
|
|
|
45
45
|
try {
|
|
46
46
|
new URL(uri);
|
|
47
47
|
} catch {
|
|
48
|
-
throw new Error(`Invalid
|
|
48
|
+
throw new Error(`Invalid file URI: expected valid data URI or HTTP URL`);
|
|
49
49
|
}
|
|
50
50
|
const metadata = {};
|
|
51
51
|
if (options?.detail) metadata.detail = options.detail;
|
|
@@ -69,7 +69,10 @@ const getMessagePartsFromOpenAIContent = (content) => {
|
|
|
69
69
|
let skipped = 0;
|
|
70
70
|
for (const item of content) if (isTextContentItem(item)) textChunks.push(item.text);
|
|
71
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, {
|
|
72
|
+
else if (isFileContentItem(item)) fileParts.push(buildFilePart(item.file.file_data, {
|
|
73
|
+
filename: item.file.filename,
|
|
74
|
+
mimeType: "application/pdf"
|
|
75
|
+
}));
|
|
73
76
|
else skipped += 1;
|
|
74
77
|
if (skipped > 0) logger.warn({
|
|
75
78
|
total: content.length,
|
|
@@ -91,8 +94,8 @@ const getMessagePartsFromVercelContent = (content, parts) => {
|
|
|
91
94
|
const partsFromPayload = parsedParts.map((part) => {
|
|
92
95
|
if (part.type === "text") return buildTextPart(part.text);
|
|
93
96
|
if (part.type === "image") return buildFilePart(part.text);
|
|
94
|
-
if (part.type === "file") return buildFilePart(part.
|
|
95
|
-
mimeType: part.mediaType
|
|
97
|
+
if (part.type === "file") return buildFilePart(part.url, {
|
|
98
|
+
mimeType: part.mediaType,
|
|
96
99
|
filename: part.filename
|
|
97
100
|
});
|
|
98
101
|
return assertNever(part);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core8 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_core8.ContextBreakdown;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { AssembleResult, type BreakdownComponentDef, type ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown, estimateTokens };
|
package/dist/factory.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { SandboxConfig } from "./types/app.js";
|
|
|
2
2
|
import "./types/index.js";
|
|
3
3
|
import { createAgentsHono } from "./createApp.js";
|
|
4
4
|
import { CredentialStore, ServerConfig } from "@inkeep/agents-core";
|
|
5
|
-
import * as
|
|
5
|
+
import * as hono10 from "hono";
|
|
6
6
|
import * as zod0 from "zod";
|
|
7
7
|
import { EmailServiceConfig, SSOProviderConfig, UserAuthConfig } from "@inkeep/agents-core/auth";
|
|
8
|
-
import * as
|
|
8
|
+
import * as hono_types0 from "hono/types";
|
|
9
9
|
import * as better_auth0 from "better-auth";
|
|
10
10
|
import * as better_auth_plugins0 from "better-auth/plugins";
|
|
11
11
|
|
|
@@ -479,6 +479,6 @@ declare function createAgentsApp(config?: {
|
|
|
479
479
|
auth?: UserAuthConfig;
|
|
480
480
|
sandboxConfig?: SandboxConfig;
|
|
481
481
|
emailService?: EmailServiceConfig;
|
|
482
|
-
}):
|
|
482
|
+
}): hono10.Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
|
|
483
483
|
//#endregion
|
|
484
484
|
export { type SSOProviderConfig, type UserAuthConfig, createAgentsApp, createAgentsAuth, createAgentsHono };
|
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_types2 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_types2.BlankEnv, hono_types2.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 hono19 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/evalsAuth.d.ts
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import * as hono0 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: () => hono19.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 hono0 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: () => hono0.MiddlewareHandler<{
|
|
20
20
|
Variables: {
|
|
21
21
|
executionContext: BaseExecutionContext;
|
|
22
22
|
userId?: string;
|
|
@@ -30,6 +30,6 @@ declare const manageBearerAuth: () => hono1.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: () => hono0.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 hono1 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: hono1.MiddlewareHandler<{
|
|
9
9
|
Variables: {
|
|
10
10
|
executionContext: BaseExecutionContext;
|
|
11
11
|
resolvedRef: ResolvedRef;
|
|
@@ -15,7 +15,7 @@ declare const projectConfigMiddleware: hono3.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) => hono1.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 hono3 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) => hono3.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 hono4 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/runAuth.d.ts
|
|
5
|
-
declare const runApiKeyAuth: () =>
|
|
5
|
+
declare const runApiKeyAuth: () => hono4.MiddlewareHandler<{
|
|
6
6
|
Variables: {
|
|
7
7
|
executionContext: BaseExecutionContext;
|
|
8
8
|
};
|
|
@@ -11,7 +11,7 @@ declare const runApiKeyAuth: () => hono6.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) => hono4.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: () => hono4.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 hono17 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/sessionAuth.d.ts
|
|
5
5
|
|
|
@@ -8,12 +8,12 @@ import * as hono9 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: () => hono17.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: () => hono17.MiddlewareHandler<{
|
|
17
17
|
Variables: AppVariables;
|
|
18
18
|
}, string, {}, Response>;
|
|
19
19
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono7 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/tenantAccess.d.ts
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ import * as hono11 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: () => hono7.MiddlewareHandler<{
|
|
16
16
|
Variables: {
|
|
17
17
|
userId: string;
|
|
18
18
|
tenantId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono8 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/tracing.d.ts
|
|
4
|
-
declare const otelBaggageMiddleware: () =>
|
|
5
|
-
declare const executionBaggageMiddleware: () =>
|
|
4
|
+
declare const otelBaggageMiddleware: () => hono8.MiddlewareHandler<any, string, {}, Response>;
|
|
5
|
+
declare const executionBaggageMiddleware: () => hono8.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-20260325193448",
|
|
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-
|
|
78
|
-
"@inkeep/agents-
|
|
79
|
-
"@inkeep/agents-
|
|
76
|
+
"@inkeep/agents-core": "^0.0.0-dev-20260325193448",
|
|
77
|
+
"@inkeep/agents-mcp": "^0.0.0-dev-20260325193448",
|
|
78
|
+
"@inkeep/agents-work-apps": "^0.0.0-dev-20260325193448",
|
|
79
|
+
"@inkeep/agents-email": "^0.0.0-dev-20260325193448"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@hono/zod-openapi": "^1.1.5",
|