@inkeep/agents-core 0.41.2 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-client/base-client.d.ts +87 -8
- package/dist/api-client/base-client.js +174 -1
- package/dist/api-client/eval-api-client.d.ts +47 -0
- package/dist/api-client/eval-api-client.js +65 -0
- package/dist/api-client/index.d.ts +4 -0
- package/dist/api-client/index.js +5 -0
- package/dist/api-client/manage-api-client.d.ts +34 -0
- package/dist/api-client/manage-api-client.js +104 -0
- package/dist/auth/auth.d.ts +86 -20
- package/dist/auth/auth.js +60 -2
- package/dist/auth/authz/client.d.ts +87 -0
- package/dist/auth/authz/client.js +196 -0
- package/dist/auth/authz/config.d.ts +103 -0
- package/dist/auth/authz/config.js +93 -0
- package/dist/auth/authz/index.d.ts +5 -0
- package/dist/auth/authz/index.js +6 -0
- package/dist/auth/authz/permissions.d.ts +53 -0
- package/dist/auth/authz/permissions.js +83 -0
- package/dist/auth/authz/sync.d.ts +106 -0
- package/dist/auth/authz/sync.js +321 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/permissions.js +2 -181
- package/dist/client-exports.d.ts +9 -3
- package/dist/client-exports.js +4 -2
- package/dist/constants/context-breakdown.d.ts +61 -0
- package/dist/constants/context-breakdown.js +124 -0
- package/dist/constants/execution-limits-shared/defaults.d.ts +1 -1
- package/dist/constants/execution-limits-shared/defaults.js +1 -1
- package/dist/constants/execution-limits-shared/index.d.ts +1 -1
- package/dist/constants/otel-attributes.d.ts +4 -0
- package/dist/constants/otel-attributes.js +4 -0
- package/dist/context/ContextConfig.d.ts +2 -2
- package/dist/context/ContextConfig.js +3 -3
- package/dist/context/TemplateEngine.d.ts +0 -6
- package/dist/context/TemplateEngine.js +4 -19
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.js +1 -5
- package/dist/credential-stores/keychain-store.d.ts +20 -8
- package/dist/credential-stores/keychain-store.js +107 -43
- package/dist/credential-stuffer/CredentialStuffer.d.ts +1 -1
- package/dist/data-access/index.d.ts +34 -26
- package/dist/data-access/index.js +34 -26
- package/dist/data-access/manage/agentFull.d.ts +36 -0
- package/dist/data-access/{agentFull.js → manage/agentFull.js} +209 -7
- package/dist/data-access/{agents.d.ts → manage/agents.d.ts} +64 -63
- package/dist/data-access/{agents.js → manage/agents.js} +80 -27
- package/dist/data-access/{artifactComponents.d.ts → manage/artifactComponents.d.ts} +33 -33
- package/dist/data-access/{artifactComponents.js → manage/artifactComponents.js} +5 -5
- package/dist/data-access/{contextConfigs.d.ts → manage/contextConfigs.d.ts} +26 -26
- package/dist/data-access/{contextConfigs.js → manage/contextConfigs.js} +3 -3
- package/dist/data-access/{credentialReferences.d.ts → manage/credentialReferences.d.ts} +17 -17
- package/dist/data-access/{credentialReferences.js → manage/credentialReferences.js} +2 -2
- package/dist/data-access/{dataComponents.d.ts → manage/dataComponents.d.ts} +26 -26
- package/dist/data-access/{dataComponents.js → manage/dataComponents.js} +7 -7
- package/dist/data-access/manage/evalConfig.d.ts +221 -0
- package/dist/data-access/manage/evalConfig.js +275 -0
- package/dist/data-access/{externalAgents.d.ts → manage/externalAgents.d.ts} +16 -16
- package/dist/data-access/{externalAgents.js → manage/externalAgents.js} +2 -2
- package/dist/data-access/manage/functionTools.d.ts +242 -0
- package/dist/data-access/{functionTools.js → manage/functionTools.js} +124 -30
- package/dist/data-access/{functions.d.ts → manage/functions.d.ts} +9 -9
- package/dist/data-access/{functions.js → manage/functions.js} +3 -3
- package/dist/data-access/manage/projectFull.d.ts +38 -0
- package/dist/data-access/{projectFull.js → manage/projectFull.js} +64 -65
- package/dist/data-access/manage/projectLifecycle.d.ts +119 -0
- package/dist/data-access/manage/projectLifecycle.js +234 -0
- package/dist/data-access/manage/projects.d.ts +75 -0
- package/dist/data-access/{projects.js → manage/projects.js} +15 -16
- package/dist/data-access/{subAgentExternalAgentRelations.d.ts → manage/subAgentExternalAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentExternalAgentRelations.js → manage/subAgentExternalAgentRelations.js} +2 -2
- package/dist/data-access/{subAgentRelations.d.ts → manage/subAgentRelations.d.ts} +65 -65
- package/dist/data-access/{subAgentRelations.js → manage/subAgentRelations.js} +3 -3
- package/dist/data-access/{subAgentTeamAgentRelations.d.ts → manage/subAgentTeamAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentTeamAgentRelations.js → manage/subAgentTeamAgentRelations.js} +2 -2
- package/dist/data-access/{subAgents.d.ts → manage/subAgents.d.ts} +28 -28
- package/dist/data-access/{subAgents.js → manage/subAgents.js} +4 -4
- package/dist/data-access/{tools.d.ts → manage/tools.d.ts} +65 -52
- package/dist/data-access/{tools.js → manage/tools.js} +109 -64
- package/dist/data-access/manage/triggers.d.ts +106 -0
- package/dist/data-access/manage/triggers.js +81 -0
- package/dist/data-access/{apiKeys.d.ts → runtime/apiKeys.d.ts} +37 -37
- package/dist/data-access/{apiKeys.js → runtime/apiKeys.js} +3 -3
- package/dist/data-access/runtime/cascade-delete.d.ts +77 -0
- package/dist/data-access/runtime/cascade-delete.js +111 -0
- package/dist/data-access/{contextCache.d.ts → runtime/contextCache.d.ts} +13 -13
- package/dist/data-access/{contextCache.js → runtime/contextCache.js} +5 -5
- package/dist/data-access/{conversations.d.ts → runtime/conversations.d.ts} +80 -31
- package/dist/data-access/{conversations.js → runtime/conversations.js} +13 -7
- package/dist/data-access/runtime/evalRuns.d.ts +120 -0
- package/dist/data-access/runtime/evalRuns.js +168 -0
- package/dist/data-access/{ledgerArtifacts.d.ts → runtime/ledgerArtifacts.d.ts} +13 -13
- package/dist/data-access/{ledgerArtifacts.js → runtime/ledgerArtifacts.js} +3 -3
- package/dist/data-access/{messages.d.ts → runtime/messages.d.ts} +24 -24
- package/dist/data-access/{messages.js → runtime/messages.js} +2 -2
- package/dist/data-access/{organizations.d.ts → runtime/organizations.d.ts} +16 -7
- package/dist/data-access/{organizations.js → runtime/organizations.js} +16 -4
- package/dist/data-access/runtime/projects.d.ts +62 -0
- package/dist/data-access/runtime/projects.js +90 -0
- package/dist/data-access/runtime/tasks.d.ts +55 -0
- package/dist/data-access/{tasks.js → runtime/tasks.js} +2 -2
- package/dist/data-access/runtime/triggerInvocations.d.ts +62 -0
- package/dist/data-access/runtime/triggerInvocations.js +54 -0
- package/dist/data-access/runtime/users.d.ts +19 -0
- package/dist/data-access/{users.js → runtime/users.js} +2 -2
- package/dist/data-access/validation.d.ts +4 -4
- package/dist/data-access/validation.js +1 -1
- package/dist/db/clean.d.ts +8 -4
- package/dist/db/clean.js +14 -105
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +7 -10
- package/dist/db/manage/dolt-cleanup.d.ts +51 -0
- package/dist/db/manage/dolt-cleanup.js +132 -0
- package/dist/db/manage/manage-client.d.ts +26 -0
- package/dist/db/manage/manage-client.js +68 -0
- package/dist/db/{schema.d.ts → manage/manage-schema.d.ts} +1257 -969
- package/dist/db/{schema.js → manage/manage-schema.js} +436 -334
- package/dist/db/manage/test-manage-client.d.ts +27 -0
- package/dist/db/manage/test-manage-client.js +68 -0
- package/dist/db/runtime/runtime-client.d.ts +20 -0
- package/dist/db/runtime/runtime-client.js +30 -0
- package/dist/db/runtime/runtime-schema.d.ts +2834 -0
- package/dist/db/runtime/runtime-schema.js +483 -0
- package/dist/db/runtime/test-runtime-client.d.ts +27 -0
- package/dist/db/{test-client.js → runtime/test-runtime-client.js} +11 -25
- package/dist/db/utils.d.ts +6 -0
- package/dist/db/utils.js +42 -0
- package/dist/dolt/branch.d.ts +62 -0
- package/dist/dolt/branch.js +82 -0
- package/dist/dolt/branches-api.d.ts +108 -0
- package/dist/dolt/branches-api.js +162 -0
- package/dist/dolt/commit.d.ts +94 -0
- package/dist/dolt/commit.js +103 -0
- package/dist/dolt/diff.d.ts +27 -0
- package/dist/dolt/diff.js +21 -0
- package/dist/dolt/index.d.ts +10 -0
- package/dist/dolt/index.js +11 -0
- package/dist/dolt/merge.d.ts +63 -0
- package/dist/dolt/merge.js +81 -0
- package/dist/dolt/migrate-all-branches.d.ts +4 -0
- package/dist/dolt/migrate-all-branches.js +83 -0
- package/dist/dolt/migrate-dolt.d.ts +1 -0
- package/dist/dolt/migrate-dolt.js +25 -0
- package/dist/dolt/ref-helpers.d.ts +19 -0
- package/dist/dolt/ref-helpers.js +65 -0
- package/dist/dolt/ref-middleware.d.ts +82 -0
- package/dist/dolt/ref-middleware.js +217 -0
- package/dist/dolt/ref-scope.d.ts +101 -0
- package/dist/dolt/ref-scope.js +231 -0
- package/dist/dolt/schema-sync.d.ts +135 -0
- package/dist/dolt/schema-sync.js +255 -0
- package/dist/env.d.ts +6 -4
- package/dist/env.js +3 -2
- package/dist/index.d.ts +73 -46
- package/dist/index.js +76 -49
- package/dist/types/@napi-rs__keyring/index.d.ts +14 -0
- package/dist/types/entities.d.ts +81 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +46 -5
- package/dist/types/utility.js +2 -1
- package/dist/utils/JsonTransformer.d.ts +42 -0
- package/dist/utils/JsonTransformer.js +103 -0
- package/dist/utils/apiKeys.d.ts +5 -1
- package/dist/utils/apiKeys.js +11 -1
- package/dist/utils/colors.d.ts +34 -0
- package/dist/utils/colors.js +49 -0
- package/dist/utils/credential-store-utils.d.ts +1 -1
- package/dist/utils/format-messages.d.ts +1 -1
- package/dist/utils/index.d.ts +8 -4
- package/dist/utils/index.js +8 -4
- package/dist/utils/internal-service-auth.d.ts +79 -0
- package/dist/utils/internal-service-auth.js +140 -0
- package/dist/utils/jmespath-utils.d.ts +152 -0
- package/dist/utils/jmespath-utils.js +213 -0
- package/dist/utils/jwt-helpers.d.ts +56 -0
- package/dist/utils/jwt-helpers.js +90 -0
- package/dist/utils/mcp-client.d.ts +1 -1
- package/dist/utils/mcp-client.js +1 -1
- package/dist/utils/service-token-auth.d.ts +9 -27
- package/dist/utils/service-token-auth.js +48 -96
- package/dist/utils/signature-validation.d.ts +2 -0
- package/dist/utils/signature-validation.js +3 -0
- package/dist/utils/template-interpolation.d.ts +22 -0
- package/dist/utils/template-interpolation.js +62 -0
- package/dist/utils/third-party-mcp-servers/composio-client.d.ts +13 -1
- package/dist/utils/third-party-mcp-servers/composio-client.js +47 -29
- package/dist/utils/third-party-mcp-servers/index.d.ts +2 -2
- package/dist/utils/third-party-mcp-servers/index.js +2 -2
- package/dist/utils/trigger-auth.d.ts +85 -0
- package/dist/utils/trigger-auth.js +233 -0
- package/dist/validation/agentFull.js +2 -4
- package/dist/validation/dolt-schemas.d.ts +49 -0
- package/dist/validation/dolt-schemas.js +44 -0
- package/dist/validation/drizzle-schema-helpers.d.ts +4 -26
- package/dist/validation/drizzle-schema-helpers.js +5 -151
- package/dist/validation/index.d.ts +5 -4
- package/dist/validation/index.js +4 -3
- package/dist/validation/render-validation.js +19 -0
- package/dist/validation/schemas.d.ts +18223 -5148
- package/dist/validation/schemas.js +559 -12
- package/dist/validation/stream-event-schemas.d.ts +96 -1
- package/dist/validation/stream-event-schemas.js +67 -2
- package/drizzle/manage/0000_tearful_rhodey.sql +414 -0
- package/drizzle/manage/0001_broken_wendell_vaughn.sql +19 -0
- package/drizzle/manage/0002_bent_sunfire.sql +1 -0
- package/drizzle/manage/0003_tiny_captain_universe.sql +8 -0
- package/drizzle/manage/0004_curious_phil_sheldon.sql +2 -0
- package/drizzle/manage/0005_silent_shatterstar.sql +53 -0
- package/drizzle/manage/meta/0000_snapshot.json +2987 -0
- package/drizzle/manage/meta/0001_snapshot.json +3115 -0
- package/drizzle/manage/meta/0002_snapshot.json +3115 -0
- package/drizzle/manage/meta/0003_snapshot.json +3134 -0
- package/drizzle/manage/meta/0004_snapshot.json +3141 -0
- package/drizzle/manage/meta/0005_snapshot.json +3141 -0
- package/drizzle/manage/meta/_journal.json +48 -0
- package/drizzle/runtime/0008_silly_preak.sql +127 -0
- package/drizzle/runtime/0009_freezing_leo.sql +17 -0
- package/drizzle/runtime/meta/0008_snapshot.json +2263 -0
- package/drizzle/runtime/meta/0009_snapshot.json +2397 -0
- package/drizzle/{meta → runtime/meta}/_journal.json +14 -0
- package/package.json +56 -18
- package/spicedb/schema.zed +114 -0
- package/dist/context/ContextFetcher.d.ts +0 -73
- package/dist/context/ContextFetcher.js +0 -291
- package/dist/context/ContextResolver.d.ts +0 -60
- package/dist/context/ContextResolver.js +0 -278
- package/dist/context/context.d.ts +0 -27
- package/dist/context/context.js +0 -128
- package/dist/context/contextCache.d.ts +0 -58
- package/dist/context/contextCache.js +0 -177
- package/dist/data-access/agentFull.d.ts +0 -33
- package/dist/data-access/functionTools.d.ts +0 -169
- package/dist/data-access/projectFull.d.ts +0 -32
- package/dist/data-access/projects.d.ts +0 -71
- package/dist/data-access/tasks.d.ts +0 -45
- package/dist/data-access/users.d.ts +0 -19
- package/dist/db/client.d.ts +0 -20
- package/dist/db/client.js +0 -28
- package/dist/db/test-client.d.ts +0 -31
- package/dist/middleware/contextValidation.d.ts +0 -46
- package/dist/middleware/contextValidation.js +0 -280
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.js +0 -3
- package/dist/utils/execution.d.ts +0 -22
- package/dist/utils/execution.js +0 -25
- /package/drizzle/{0000_exotic_mysterio.sql → runtime/0000_exotic_mysterio.sql} +0 -0
- /package/drizzle/{0001_calm_sheva_callister.sql → runtime/0001_calm_sheva_callister.sql} +0 -0
- /package/drizzle/{0002_puzzling_goblin_queen.sql → runtime/0002_puzzling_goblin_queen.sql} +0 -0
- /package/drizzle/{0003_sweet_human_robot.sql → runtime/0003_sweet_human_robot.sql} +0 -0
- /package/drizzle/{0004_cuddly_shooting_star.sql → runtime/0004_cuddly_shooting_star.sql} +0 -0
- /package/drizzle/{0005_reflective_starfox.sql → runtime/0005_reflective_starfox.sql} +0 -0
- /package/drizzle/{0006_stale_thaddeus_ross.sql → runtime/0006_stale_thaddeus_ross.sql} +0 -0
- /package/drizzle/{0007_slim_karma.sql → runtime/0007_slim_karma.sql} +0 -0
- /package/drizzle/{meta → runtime/meta}/0000_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0001_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0003_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0005_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0006_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0007_snapshot.json +0 -0
|
@@ -1,11 +1,7 @@
|
|
|
1
|
+
import { InternalServiceId } from "../utils/internal-service-auth.js";
|
|
2
|
+
|
|
1
3
|
//#region src/api-client/base-client.d.ts
|
|
2
|
-
|
|
3
|
-
* Shared base API client for making HTTP requests
|
|
4
|
-
* Used by both CLI and SDK to ensure consistent API communication
|
|
5
|
-
*
|
|
6
|
-
* This is a thin wrapper around fetch that provides consistent header handling.
|
|
7
|
-
* Implementations should construct Authorization headers and pass them via options.
|
|
8
|
-
*/
|
|
4
|
+
|
|
9
5
|
/**
|
|
10
6
|
* Makes an HTTP request with consistent header defaults
|
|
11
7
|
*
|
|
@@ -31,5 +27,88 @@
|
|
|
31
27
|
* ```
|
|
32
28
|
*/
|
|
33
29
|
declare function apiFetch(url: string, options?: RequestInit): Promise<Response>;
|
|
30
|
+
declare class BaseApiError extends Error {
|
|
31
|
+
readonly statusCode: number;
|
|
32
|
+
readonly responseBody: string;
|
|
33
|
+
constructor(message: string, statusCode: number, responseBody: string);
|
|
34
|
+
get isNotFound(): boolean;
|
|
35
|
+
get isUnauthorized(): boolean;
|
|
36
|
+
get isForbidden(): boolean;
|
|
37
|
+
}
|
|
38
|
+
type BaseApiClientAuth = {
|
|
39
|
+
mode: 'internalService';
|
|
40
|
+
internalServiceName: InternalServiceId;
|
|
41
|
+
} | {
|
|
42
|
+
mode: 'apiKey';
|
|
43
|
+
apiKey: string;
|
|
44
|
+
isCI?: boolean;
|
|
45
|
+
};
|
|
46
|
+
interface BaseApiClientConfig {
|
|
47
|
+
apiUrl: string;
|
|
48
|
+
tenantId: string;
|
|
49
|
+
projectId: string;
|
|
50
|
+
auth: BaseApiClientAuth;
|
|
51
|
+
ref?: string;
|
|
52
|
+
userId?: string;
|
|
53
|
+
userEmail?: string;
|
|
54
|
+
}
|
|
55
|
+
declare abstract class BaseApiClient {
|
|
56
|
+
protected apiUrl: string;
|
|
57
|
+
protected tenantId: string | undefined;
|
|
58
|
+
protected projectId: string;
|
|
59
|
+
protected apiKey: string | undefined;
|
|
60
|
+
protected isCI: boolean;
|
|
61
|
+
protected internalServiceName?: InternalServiceId;
|
|
62
|
+
protected ref?: string;
|
|
63
|
+
protected userId?: string;
|
|
64
|
+
protected userEmail?: string;
|
|
65
|
+
protected constructor(config: BaseApiClientConfig);
|
|
66
|
+
protected checkTenantId(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Builds a URL from the base API URL and a path
|
|
69
|
+
* Supports optional ref and pagination query parameters
|
|
70
|
+
*/
|
|
71
|
+
protected buildUrl(path: string, params?: {
|
|
72
|
+
page?: number;
|
|
73
|
+
limit?: number;
|
|
74
|
+
}): string;
|
|
75
|
+
/**
|
|
76
|
+
* Gets auth headers for requests
|
|
77
|
+
* Handles both internal service JWT tokens and API key authentication
|
|
78
|
+
*/
|
|
79
|
+
protected getAuthHeaders(): Promise<Record<string, string>>;
|
|
80
|
+
/**
|
|
81
|
+
* Wrapper around fetch that automatically includes auth header
|
|
82
|
+
* Uses X-API-Key for CI mode, Authorization Bearer for interactive mode
|
|
83
|
+
* @deprecated Use getAuthHeaders() with apiFetch() instead for more flexibility
|
|
84
|
+
*/
|
|
85
|
+
protected authenticatedFetch(url: string, options?: RequestInit): Promise<Response>;
|
|
86
|
+
/**
|
|
87
|
+
* Creates an error instance for failed requests
|
|
88
|
+
* Override in subclasses to return specific error types
|
|
89
|
+
*/
|
|
90
|
+
protected createError(message: string, statusCode: number, responseBody: string): BaseApiError;
|
|
91
|
+
/**
|
|
92
|
+
* Extracts data from a successful response
|
|
93
|
+
* Override in subclasses if the API wraps responses (e.g., { data: ... })
|
|
94
|
+
*/
|
|
95
|
+
protected extractResponseData<T>(response: Response): Promise<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Makes a GET request with authentication
|
|
98
|
+
*/
|
|
99
|
+
protected makeGetRequest<T>(path: string, errorContext: string): Promise<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Makes a POST request with authentication
|
|
102
|
+
*/
|
|
103
|
+
protected makePostRequest<T>(path: string, body: unknown, errorContext: string): Promise<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Makes paginated GET requests and collects all results
|
|
106
|
+
*/
|
|
107
|
+
protected makePaginatedGetRequest<T>(path: string, errorContext: string, pageSize?: number): Promise<T[]>;
|
|
108
|
+
getTenantId(): string | undefined;
|
|
109
|
+
getProjectId(): string;
|
|
110
|
+
getApiUrl(): string;
|
|
111
|
+
getIsCI(): boolean;
|
|
112
|
+
}
|
|
34
113
|
//#endregion
|
|
35
|
-
export { apiFetch };
|
|
114
|
+
export { BaseApiClient, BaseApiClientAuth, BaseApiClientConfig, BaseApiError, apiFetch };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { generateInternalServiceToken } from "../utils/internal-service-auth.js";
|
|
2
|
+
|
|
1
3
|
//#region src/api-client/base-client.ts
|
|
2
4
|
/**
|
|
3
5
|
* Shared base API client for making HTTP requests
|
|
@@ -41,6 +43,177 @@ async function apiFetch(url, options = {}) {
|
|
|
41
43
|
headers
|
|
42
44
|
});
|
|
43
45
|
}
|
|
46
|
+
var BaseApiError = class extends Error {
|
|
47
|
+
constructor(message, statusCode, responseBody) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.statusCode = statusCode;
|
|
50
|
+
this.responseBody = responseBody;
|
|
51
|
+
this.name = "BaseApiError";
|
|
52
|
+
}
|
|
53
|
+
get isNotFound() {
|
|
54
|
+
return this.statusCode === 404;
|
|
55
|
+
}
|
|
56
|
+
get isUnauthorized() {
|
|
57
|
+
return this.statusCode === 401;
|
|
58
|
+
}
|
|
59
|
+
get isForbidden() {
|
|
60
|
+
return this.statusCode === 403;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var BaseApiClient = class {
|
|
64
|
+
apiUrl;
|
|
65
|
+
tenantId;
|
|
66
|
+
projectId;
|
|
67
|
+
apiKey;
|
|
68
|
+
isCI;
|
|
69
|
+
internalServiceName;
|
|
70
|
+
ref;
|
|
71
|
+
userId;
|
|
72
|
+
userEmail;
|
|
73
|
+
constructor(config) {
|
|
74
|
+
this.apiUrl = config.apiUrl;
|
|
75
|
+
this.tenantId = config.tenantId;
|
|
76
|
+
this.projectId = config.projectId;
|
|
77
|
+
this.apiKey = config.auth.mode === "apiKey" ? config.auth.apiKey : void 0;
|
|
78
|
+
this.isCI = config.auth.mode === "apiKey" ? config.auth.isCI ?? false : false;
|
|
79
|
+
this.internalServiceName = config.auth.mode === "internalService" ? config.auth.internalServiceName : void 0;
|
|
80
|
+
this.ref = config.ref;
|
|
81
|
+
this.userId = config.userId;
|
|
82
|
+
this.userEmail = config.userEmail;
|
|
83
|
+
}
|
|
84
|
+
checkTenantId() {
|
|
85
|
+
if (!this.tenantId) throw new Error("No tenant ID configured. Please run: inkeep init");
|
|
86
|
+
return this.tenantId;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Builds a URL from the base API URL and a path
|
|
90
|
+
* Supports optional ref and pagination query parameters
|
|
91
|
+
*/
|
|
92
|
+
buildUrl(path, params) {
|
|
93
|
+
const normalizedBase = this.apiUrl.replace(/\/$/, "");
|
|
94
|
+
const url = new URL(`${normalizedBase}${path}`);
|
|
95
|
+
if (this.ref !== void 0 && this.ref !== "main") url.searchParams.set("ref", this.ref);
|
|
96
|
+
if (params?.page !== void 0) url.searchParams.set("page", String(params.page));
|
|
97
|
+
if (params?.limit !== void 0) url.searchParams.set("limit", String(params.limit));
|
|
98
|
+
return url.toString();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Gets auth headers for requests
|
|
102
|
+
* Handles both internal service JWT tokens and API key authentication
|
|
103
|
+
*/
|
|
104
|
+
async getAuthHeaders() {
|
|
105
|
+
const tenantId = this.checkTenantId();
|
|
106
|
+
if (this.internalServiceName) return { Authorization: `Bearer ${await generateInternalServiceToken({
|
|
107
|
+
serviceId: this.internalServiceName,
|
|
108
|
+
tenantId,
|
|
109
|
+
projectId: this.projectId,
|
|
110
|
+
userId: this.userId
|
|
111
|
+
})}` };
|
|
112
|
+
if (this.apiKey) {
|
|
113
|
+
if (this.isCI) return { "X-API-Key": this.apiKey };
|
|
114
|
+
return { Authorization: `Bearer ${this.apiKey}` };
|
|
115
|
+
}
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Wrapper around fetch that automatically includes auth header
|
|
120
|
+
* Uses X-API-Key for CI mode, Authorization Bearer for interactive mode
|
|
121
|
+
* @deprecated Use getAuthHeaders() with apiFetch() instead for more flexibility
|
|
122
|
+
*/
|
|
123
|
+
async authenticatedFetch(url, options = {}) {
|
|
124
|
+
const headers = { ...options.headers || {} };
|
|
125
|
+
if (this.apiKey) if (this.isCI) headers["X-API-Key"] = this.apiKey;
|
|
126
|
+
else headers.Authorization = `Bearer ${this.apiKey}`;
|
|
127
|
+
return apiFetch(url, {
|
|
128
|
+
...options,
|
|
129
|
+
headers
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Creates an error instance for failed requests
|
|
134
|
+
* Override in subclasses to return specific error types
|
|
135
|
+
*/
|
|
136
|
+
createError(message, statusCode, responseBody) {
|
|
137
|
+
return new BaseApiError(message, statusCode, responseBody);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Extracts data from a successful response
|
|
141
|
+
* Override in subclasses if the API wraps responses (e.g., { data: ... })
|
|
142
|
+
*/
|
|
143
|
+
async extractResponseData(response) {
|
|
144
|
+
return response.json();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Makes a GET request with authentication
|
|
148
|
+
*/
|
|
149
|
+
async makeGetRequest(path, errorContext) {
|
|
150
|
+
const response = await apiFetch(this.buildUrl(path), {
|
|
151
|
+
method: "GET",
|
|
152
|
+
headers: await this.getAuthHeaders()
|
|
153
|
+
});
|
|
154
|
+
if (!response.ok) {
|
|
155
|
+
const errorBody = await response.text().catch(() => "Unknown error");
|
|
156
|
+
throw this.createError(`${errorContext}: ${response.status} ${response.statusText}`, response.status, errorBody);
|
|
157
|
+
}
|
|
158
|
+
return this.extractResponseData(response);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Makes a POST request with authentication
|
|
162
|
+
*/
|
|
163
|
+
async makePostRequest(path, body, errorContext) {
|
|
164
|
+
const response = await apiFetch(this.buildUrl(path), {
|
|
165
|
+
method: "POST",
|
|
166
|
+
headers: {
|
|
167
|
+
...await this.getAuthHeaders(),
|
|
168
|
+
"Content-Type": "application/json"
|
|
169
|
+
},
|
|
170
|
+
body: JSON.stringify(body)
|
|
171
|
+
});
|
|
172
|
+
if (!response.ok) {
|
|
173
|
+
const errorBody = await response.text().catch(() => "Unknown error");
|
|
174
|
+
throw this.createError(`${errorContext}: ${response.status} ${response.statusText}`, response.status, errorBody);
|
|
175
|
+
}
|
|
176
|
+
return this.extractResponseData(response);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Makes paginated GET requests and collects all results
|
|
180
|
+
*/
|
|
181
|
+
async makePaginatedGetRequest(path, errorContext, pageSize = 100) {
|
|
182
|
+
const allItems = [];
|
|
183
|
+
let currentPage = 1;
|
|
184
|
+
const headers = await this.getAuthHeaders();
|
|
185
|
+
while (true) {
|
|
186
|
+
const response = await apiFetch(this.buildUrl(path, {
|
|
187
|
+
page: currentPage,
|
|
188
|
+
limit: pageSize
|
|
189
|
+
}), {
|
|
190
|
+
method: "GET",
|
|
191
|
+
headers
|
|
192
|
+
});
|
|
193
|
+
if (!response.ok) {
|
|
194
|
+
const errorBody = await response.text().catch(() => "Unknown error");
|
|
195
|
+
throw this.createError(`${errorContext}: ${response.status} ${response.statusText}`, response.status, errorBody);
|
|
196
|
+
}
|
|
197
|
+
const json = await response.json();
|
|
198
|
+
allItems.push(...json.data);
|
|
199
|
+
if (currentPage >= json.pagination.pages) break;
|
|
200
|
+
currentPage++;
|
|
201
|
+
}
|
|
202
|
+
return allItems;
|
|
203
|
+
}
|
|
204
|
+
getTenantId() {
|
|
205
|
+
return this.tenantId;
|
|
206
|
+
}
|
|
207
|
+
getProjectId() {
|
|
208
|
+
return this.projectId;
|
|
209
|
+
}
|
|
210
|
+
getApiUrl() {
|
|
211
|
+
return this.apiUrl;
|
|
212
|
+
}
|
|
213
|
+
getIsCI() {
|
|
214
|
+
return this.isCI;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
44
217
|
|
|
45
218
|
//#endregion
|
|
46
|
-
export { apiFetch };
|
|
219
|
+
export { BaseApiClient, BaseApiError, apiFetch };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseApiClient, BaseApiClientConfig, BaseApiError } from "./base-client.js";
|
|
2
|
+
import { TriggerConversationEvaluationRequest, TriggerDatasetRunRequest, TriggerEvaluationJobRequest } from "../types/entities.js";
|
|
3
|
+
|
|
4
|
+
//#region src/api-client/eval-api-client.d.ts
|
|
5
|
+
declare class EvalApiError extends BaseApiError {
|
|
6
|
+
constructor(message: string, statusCode: number, responseBody: string);
|
|
7
|
+
}
|
|
8
|
+
interface TriggerDatasetRunResponse {
|
|
9
|
+
queued: number;
|
|
10
|
+
failed: number;
|
|
11
|
+
datasetRunId: string;
|
|
12
|
+
}
|
|
13
|
+
interface TriggerConversationEvaluationResponse {
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
evaluationsTriggered: number;
|
|
17
|
+
}
|
|
18
|
+
interface TriggerBatchConversationEvaluationResponse {
|
|
19
|
+
queued: number;
|
|
20
|
+
failed: number;
|
|
21
|
+
}
|
|
22
|
+
interface TriggerEvaluationJobResponse {
|
|
23
|
+
queued: number;
|
|
24
|
+
failed: number;
|
|
25
|
+
evaluationRunId: string;
|
|
26
|
+
conversationCount: number;
|
|
27
|
+
}
|
|
28
|
+
declare class EvalApiClient extends BaseApiClient {
|
|
29
|
+
constructor(config: BaseApiClientConfig);
|
|
30
|
+
/**
|
|
31
|
+
* Override to return EvalApiError
|
|
32
|
+
*/
|
|
33
|
+
protected createError(message: string, statusCode: number, responseBody: string): EvalApiError;
|
|
34
|
+
/**
|
|
35
|
+
* Trigger a dataset run workflow
|
|
36
|
+
* Enqueues dataset items for processing through the chat API
|
|
37
|
+
*/
|
|
38
|
+
triggerDatasetRun(request: TriggerDatasetRunRequest): Promise<TriggerDatasetRunResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Trigger an evaluation job
|
|
41
|
+
* Filters conversations based on job filters, creates an evaluation run, and enqueues workflows
|
|
42
|
+
*/
|
|
43
|
+
triggerEvaluationJob(request: TriggerEvaluationJobRequest): Promise<TriggerEvaluationJobResponse>;
|
|
44
|
+
triggerConversationEvaluation(request: TriggerConversationEvaluationRequest): Promise<TriggerConversationEvaluationResponse>;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { EvalApiClient, EvalApiError, TriggerBatchConversationEvaluationResponse, TriggerConversationEvaluationResponse, TriggerDatasetRunResponse, TriggerEvaluationJobResponse };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getLogger } from "../utils/logger.js";
|
|
2
|
+
import { BaseApiClient, BaseApiError } from "./base-client.js";
|
|
3
|
+
|
|
4
|
+
//#region src/api-client/eval-api-client.ts
|
|
5
|
+
const logger = getLogger("eval-api-client");
|
|
6
|
+
var EvalApiError = class extends BaseApiError {
|
|
7
|
+
constructor(message, statusCode, responseBody) {
|
|
8
|
+
super(message, statusCode, responseBody);
|
|
9
|
+
this.name = "EvalApiError";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var EvalApiClient = class extends BaseApiClient {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(config);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Override to return EvalApiError
|
|
18
|
+
*/
|
|
19
|
+
createError(message, statusCode, responseBody) {
|
|
20
|
+
return new EvalApiError(message, statusCode, responseBody);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Trigger a dataset run workflow
|
|
24
|
+
* Enqueues dataset items for processing through the chat API
|
|
25
|
+
*/
|
|
26
|
+
async triggerDatasetRun(request) {
|
|
27
|
+
const tenantId = this.checkTenantId();
|
|
28
|
+
const path = `/tenants/${tenantId}/projects/${this.projectId}/run-dataset-items`;
|
|
29
|
+
logger.info({
|
|
30
|
+
tenantId,
|
|
31
|
+
projectId: this.projectId,
|
|
32
|
+
datasetRunId: request.datasetRunId,
|
|
33
|
+
itemCount: request.items.length
|
|
34
|
+
}, "Triggering dataset run workflow");
|
|
35
|
+
return this.makePostRequest(path, request, "Failed to trigger dataset run workflow");
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Trigger an evaluation job
|
|
39
|
+
* Filters conversations based on job filters, creates an evaluation run, and enqueues workflows
|
|
40
|
+
*/
|
|
41
|
+
async triggerEvaluationJob(request) {
|
|
42
|
+
const tenantId = this.checkTenantId();
|
|
43
|
+
const path = `/tenants/${tenantId}/projects/${this.projectId}/evaluate-conversations-by-job`;
|
|
44
|
+
logger.info({
|
|
45
|
+
tenantId,
|
|
46
|
+
projectId: this.projectId,
|
|
47
|
+
evaluationJobConfigId: request.evaluationJobConfigId,
|
|
48
|
+
evaluatorCount: request.evaluatorIds.length
|
|
49
|
+
}, "Triggering evaluation job workflow");
|
|
50
|
+
return this.makePostRequest(path, request, "Failed to trigger evaluation job workflow");
|
|
51
|
+
}
|
|
52
|
+
async triggerConversationEvaluation(request) {
|
|
53
|
+
const tenantId = this.checkTenantId();
|
|
54
|
+
const path = `/tenants/${tenantId}/projects/${this.projectId}/evaluate-conversation`;
|
|
55
|
+
logger.info({
|
|
56
|
+
tenantId,
|
|
57
|
+
projectId: this.projectId,
|
|
58
|
+
conversationId: request.conversationId
|
|
59
|
+
}, "Triggering conversation evaluation workflow");
|
|
60
|
+
return this.makePostRequest(path, request, "Failed to trigger conversation evaluation workflow");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { EvalApiClient, EvalApiError };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BaseApiClient, BaseApiClientAuth, BaseApiClientConfig, BaseApiError, apiFetch } from "./base-client.js";
|
|
2
|
+
import { ManageApiError, ManagementApiClient } from "./manage-api-client.js";
|
|
3
|
+
import { EvalApiClient, EvalApiError, TriggerBatchConversationEvaluationResponse, TriggerConversationEvaluationResponse, TriggerDatasetRunResponse, TriggerEvaluationJobResponse } from "./eval-api-client.js";
|
|
4
|
+
export { BaseApiClient, BaseApiClientAuth, BaseApiClientConfig, BaseApiError, EvalApiClient, EvalApiError, ManageApiError, ManagementApiClient, TriggerBatchConversationEvaluationResponse, TriggerConversationEvaluationResponse, TriggerDatasetRunResponse, TriggerEvaluationJobResponse, apiFetch };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseApiClient, BaseApiError, apiFetch } from "./base-client.js";
|
|
2
|
+
import { EvalApiClient, EvalApiError } from "./eval-api-client.js";
|
|
3
|
+
import { ManageApiError, ManagementApiClient } from "./manage-api-client.js";
|
|
4
|
+
|
|
5
|
+
export { BaseApiClient, BaseApiError, EvalApiClient, EvalApiError, ManageApiError, ManagementApiClient, apiFetch };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseApiClient, BaseApiClientConfig, BaseApiError } from "./base-client.js";
|
|
2
|
+
import { ResolvedRef } from "../validation/dolt-schemas.js";
|
|
3
|
+
import { EvaluationJobConfigEvaluatorRelationSelect, EvaluationJobConfigSelect, EvaluationRunConfigWithSuiteConfigs, EvaluationSuiteConfigEvaluatorRelationSelect, EvaluationSuiteConfigSelect, EvaluatorSelect, FullAgentDefinition, FullProjectSelectWithRelationIds, FunctionToolApiSelect, McpTool } from "../types/entities.js";
|
|
4
|
+
|
|
5
|
+
//#region src/api-client/manage-api-client.d.ts
|
|
6
|
+
declare class ManageApiError extends BaseApiError {
|
|
7
|
+
constructor(message: string, statusCode: number, responseBody: string);
|
|
8
|
+
}
|
|
9
|
+
declare class ManagementApiClient extends BaseApiClient {
|
|
10
|
+
constructor(config: BaseApiClientConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Override to return ManageApiError
|
|
13
|
+
*/
|
|
14
|
+
protected createError(message: string, statusCode: number, responseBody: string): ManageApiError;
|
|
15
|
+
/**
|
|
16
|
+
* Override to extract data from { data: ... } wrapper
|
|
17
|
+
*/
|
|
18
|
+
protected extractResponseData<T>(response: Response): Promise<T>;
|
|
19
|
+
getFullProject(): Promise<FullProjectSelectWithRelationIds>;
|
|
20
|
+
getResolvedRef(): Promise<ResolvedRef>;
|
|
21
|
+
getFullAgent(agentId: string): Promise<FullAgentDefinition | null>;
|
|
22
|
+
getMcpTool(toolId: string): Promise<McpTool>;
|
|
23
|
+
getFunctionToolsForSubAgent(agentId: string, subAgentId: string): Promise<FunctionToolApiSelect[]>;
|
|
24
|
+
getEvaluationJobConfigById(evaluationJobConfigId: string): Promise<EvaluationJobConfigSelect | null>;
|
|
25
|
+
getEvaluationJobConfigEvaluatorRelations(evaluationJobConfigId: string): Promise<EvaluationJobConfigEvaluatorRelationSelect[]>;
|
|
26
|
+
getEvaluatorById(evaluatorId: string): Promise<EvaluatorSelect | null>;
|
|
27
|
+
getEvaluatorsByIds(evaluatorIds: string[]): Promise<EvaluatorSelect[]>;
|
|
28
|
+
listEvaluationRunConfigs(): Promise<EvaluationRunConfigWithSuiteConfigs[]>;
|
|
29
|
+
getEvaluationRunConfigById(evaluationRunConfigId: string): Promise<EvaluationRunConfigWithSuiteConfigs | null>;
|
|
30
|
+
getEvaluationSuiteConfigById(evaluationSuiteConfigId: string): Promise<EvaluationSuiteConfigSelect | null>;
|
|
31
|
+
getEvaluationSuiteConfigEvaluatorRelations(evaluationSuiteConfigId: string): Promise<EvaluationSuiteConfigEvaluatorRelationSelect[]>;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { ManageApiError, ManagementApiClient };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { getLogger } from "../utils/logger.js";
|
|
2
|
+
import { BaseApiClient, BaseApiError } from "./base-client.js";
|
|
3
|
+
|
|
4
|
+
//#region src/api-client/manage-api-client.ts
|
|
5
|
+
const logger = getLogger("manage-api-client");
|
|
6
|
+
var ManageApiError = class extends BaseApiError {
|
|
7
|
+
constructor(message, statusCode, responseBody) {
|
|
8
|
+
super(message, statusCode, responseBody);
|
|
9
|
+
this.name = "ManageApiError";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var ManagementApiClient = class extends BaseApiClient {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(config);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Override to return ManageApiError
|
|
18
|
+
*/
|
|
19
|
+
createError(message, statusCode, responseBody) {
|
|
20
|
+
return new ManageApiError(message, statusCode, responseBody);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Override to extract data from { data: ... } wrapper
|
|
24
|
+
*/
|
|
25
|
+
async extractResponseData(response) {
|
|
26
|
+
return (await response.json()).data;
|
|
27
|
+
}
|
|
28
|
+
async getFullProject() {
|
|
29
|
+
const path = `/tenants/${this.checkTenantId()}/project-full/${this.projectId}/with-relation-ids`;
|
|
30
|
+
return this.makeGetRequest(path, "Failed to fetch project config");
|
|
31
|
+
}
|
|
32
|
+
async getResolvedRef() {
|
|
33
|
+
const tenantId = this.checkTenantId();
|
|
34
|
+
logger.info({
|
|
35
|
+
tenantId,
|
|
36
|
+
projectId: this.projectId
|
|
37
|
+
}, "Resolving ref");
|
|
38
|
+
const path = `/tenants/${tenantId}/projects/${this.projectId}/refs/resolve`;
|
|
39
|
+
return this.makeGetRequest(path, "Failed to resolve ref");
|
|
40
|
+
}
|
|
41
|
+
async getFullAgent(agentId) {
|
|
42
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/agent/${agentId}`;
|
|
43
|
+
try {
|
|
44
|
+
return await this.makeGetRequest(path, "Failed to fetch full agent");
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof ManageApiError && error.isNotFound) return null;
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async getMcpTool(toolId) {
|
|
51
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/tools/${toolId}`;
|
|
52
|
+
return this.makeGetRequest(path, "Failed to fetch MCP tool");
|
|
53
|
+
}
|
|
54
|
+
async getFunctionToolsForSubAgent(agentId, subAgentId) {
|
|
55
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/agents/${agentId}/sub-agent-function-tools/sub-agent/${subAgentId}`;
|
|
56
|
+
return this.makePaginatedGetRequest(path, "Failed to fetch function tools for sub-agent");
|
|
57
|
+
}
|
|
58
|
+
async getEvaluationJobConfigById(evaluationJobConfigId) {
|
|
59
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/evals/evaluation-job-configs/${evaluationJobConfigId}`;
|
|
60
|
+
try {
|
|
61
|
+
return await this.makeGetRequest(path, "Failed to fetch evaluation job config");
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (error instanceof ManageApiError && error.isNotFound) return null;
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async getEvaluationJobConfigEvaluatorRelations(evaluationJobConfigId) {
|
|
68
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/evals/evaluation-job-configs/${evaluationJobConfigId}/evaluators`;
|
|
69
|
+
return this.makeGetRequest(path, "Failed to fetch evaluation job config evaluator relations");
|
|
70
|
+
}
|
|
71
|
+
async getEvaluatorById(evaluatorId) {
|
|
72
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/evals/evaluators/${evaluatorId}`;
|
|
73
|
+
try {
|
|
74
|
+
return await this.makeGetRequest(path, "Failed to fetch evaluator");
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (error instanceof ManageApiError && error.isNotFound) return null;
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async getEvaluatorsByIds(evaluatorIds) {
|
|
81
|
+
if (evaluatorIds.length === 0) return [];
|
|
82
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/evals/evaluators/batch`;
|
|
83
|
+
return this.makePostRequest(path, { evaluatorIds }, "Failed to fetch evaluators batch");
|
|
84
|
+
}
|
|
85
|
+
async listEvaluationRunConfigs() {
|
|
86
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/evals/evaluation-run-configs`;
|
|
87
|
+
return this.makePaginatedGetRequest(path, "Failed to list evaluation run configs");
|
|
88
|
+
}
|
|
89
|
+
async getEvaluationRunConfigById(evaluationRunConfigId) {
|
|
90
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/evals/evaluation-run-configs/${evaluationRunConfigId}`;
|
|
91
|
+
return this.makeGetRequest(path, "Failed to fetch evaluation run config");
|
|
92
|
+
}
|
|
93
|
+
async getEvaluationSuiteConfigById(evaluationSuiteConfigId) {
|
|
94
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/evals/evaluation-suite-configs/${evaluationSuiteConfigId}`;
|
|
95
|
+
return this.makeGetRequest(path, "Failed to fetch evaluation suite config");
|
|
96
|
+
}
|
|
97
|
+
async getEvaluationSuiteConfigEvaluatorRelations(evaluationSuiteConfigId) {
|
|
98
|
+
const path = `/tenants/${this.checkTenantId()}/projects/${this.projectId}/evals/evaluation-suite-configs/${evaluationSuiteConfigId}/evaluators`;
|
|
99
|
+
return this.makeGetRequest(path, "Failed to fetch evaluation suite config evaluator relations");
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { ManageApiError, ManagementApiClient };
|