From 4557e93844f17103d117fda90168cc400ca5eaf1 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 12 Jun 2026 12:21:40 +0000 Subject: [PATCH] Regenerate client from commit 05ffaef of spec repo --- .generator/schemas/v2/openapi.yaml | 338 ++++++++++++++++++ features/v2/ai_guard.feature | 21 ++ features/v2/undo.json | 6 + packages/datadog-api-client/README.md | 1 + .../src/support/scenarios_model_mapping.ts | 7 + services/ai_guard/.yarnrc.yml | 1 + services/ai_guard/README.md | 37 ++ services/ai_guard/package.json | 43 +++ services/ai_guard/src/index.ts | 3 + services/ai_guard/src/v2/AIGuardApi.ts | 222 ++++++++++++ services/ai_guard/src/v2/index.ts | 22 ++ .../ai_guard/src/v2/models/AIGuardAction.ts | 13 + .../src/v2/models/AIGuardContentPart.ts | 63 ++++ .../src/v2/models/AIGuardEvaluateRequest.ts | 56 +++ .../src/v2/models/AIGuardEvaluateResponse.ts | 101 ++++++ .../ai_guard/src/v2/models/AIGuardImageURL.ts | 45 +++ .../ai_guard/src/v2/models/AIGuardMessage.ts | 73 ++++ .../src/v2/models/AIGuardMessageContent.ts | 11 + .../src/v2/models/AIGuardMessageRole.ts | 17 + .../ai_guard/src/v2/models/AIGuardMeta.ts | 77 ++++ .../src/v2/models/AIGuardSdsFinding.ts | 74 ++++ .../v2/models/AIGuardSdsFindingLocation.ts | 65 ++++ .../ai_guard/src/v2/models/AIGuardToolCall.ts | 56 +++ .../src/v2/models/AIGuardToolCallFunction.ts | 54 +++ .../src/v2/models/APIErrorResponse.ts | 45 +++ .../src/v2/models/JSONAPIErrorItem.ts | 78 ++++ .../src/v2/models/JSONAPIErrorItemSource.ts | 60 ++++ .../src/v2/models/JSONAPIErrorResponse.ts | 47 +++ services/ai_guard/src/v2/models/TypingInfo.ts | 42 +++ services/ai_guard/tsconfig.json | 28 ++ yarn.lock | 9 + 31 files changed, 1715 insertions(+) create mode 100644 features/v2/ai_guard.feature create mode 100644 services/ai_guard/.yarnrc.yml create mode 100644 services/ai_guard/README.md create mode 100644 services/ai_guard/package.json create mode 100644 services/ai_guard/src/index.ts create mode 100644 services/ai_guard/src/v2/AIGuardApi.ts create mode 100644 services/ai_guard/src/v2/index.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardAction.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardContentPart.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardEvaluateRequest.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardEvaluateResponse.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardImageURL.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardMessage.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardMessageContent.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardMessageRole.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardMeta.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardSdsFinding.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardSdsFindingLocation.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardToolCall.ts create mode 100644 services/ai_guard/src/v2/models/AIGuardToolCallFunction.ts create mode 100644 services/ai_guard/src/v2/models/APIErrorResponse.ts create mode 100644 services/ai_guard/src/v2/models/JSONAPIErrorItem.ts create mode 100644 services/ai_guard/src/v2/models/JSONAPIErrorItemSource.ts create mode 100644 services/ai_guard/src/v2/models/JSONAPIErrorResponse.ts create mode 100644 services/ai_guard/src/v2/models/TypingInfo.ts create mode 100644 services/ai_guard/tsconfig.json diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ce0ea5b8443f..d582c8e1385f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2066,6 +2066,256 @@ components: $ref: "#/components/schemas/JSONAPIErrorResponse" description: The server cannot process the request because it contains invalid data. schemas: + AIGuardAction: + description: The action recommendation from the AI Guard evaluation. + enum: + - ALLOW + - DENY + - ABORT + example: ALLOW + type: string + x-enum-varnames: + - ALLOW + - DENY + - ABORT + AIGuardContentPart: + description: A single part of a multipart message content. + properties: + image_url: + $ref: "#/components/schemas/AIGuardImageURL" + text: + description: The text content of this part, required when type is text. + example: "How do I delete all files?" + type: string + type: + description: The type of content part, either text or image_url. + example: text + type: string + required: + - type + type: object + AIGuardContentPartList: + description: A list of content parts forming a multipart message. + items: + $ref: "#/components/schemas/AIGuardContentPart" + type: array + AIGuardEvaluateRequest: + description: The evaluation request payload containing conversation messages and optional metadata. + example: + messages: + - content: How do I delete all files on the system? + role: user + meta: + env: production + service: my-llm-service + properties: + messages: + description: The list of conversation messages to evaluate. Must contain at least one message. + example: + - content: How do I delete all files on the system? + role: user + items: + $ref: "#/components/schemas/AIGuardMessage" + type: array + meta: + $ref: "#/components/schemas/AIGuardMeta" + required: + - messages + type: object + AIGuardEvaluateResponse: + description: The result of the AI Guard evaluation. + properties: + action: + $ref: "#/components/schemas/AIGuardAction" + global_prob: + description: The overall threat probability score across all evaluated tags. + example: 0.02 + format: double + type: number + is_blocking_enabled: + description: Whether blocking mode is enabled for this organization. + example: false + type: boolean + reason: + description: A human-readable explanation of the action recommendation. + example: No threats detected. + type: string + sds_findings: + description: Sensitive data findings detected in the evaluated conversation. + items: + $ref: "#/components/schemas/AIGuardSdsFinding" + type: array + tag_probs: + additionalProperties: + format: double + type: number + description: Probability scores for each evaluated threat tag. + example: + indirect-prompt-injection: 0.01 + jailbreak: 0.02 + type: object + tags: + description: Security threat tags detected in the evaluated conversation. + example: [] + items: + type: string + type: array + required: + - action + - reason + - tags + - tag_probs + - is_blocking_enabled + type: object + AIGuardImageURL: + description: An image URL reference for multimodal content. + properties: + url: + description: The URL pointing to the image. + example: "https://example.com/image.png" + type: string + required: + - url + type: object + AIGuardMessage: + description: A single message in the conversation to evaluate. + properties: + content: + $ref: "#/components/schemas/AIGuardMessageContent" + role: + $ref: "#/components/schemas/AIGuardMessageRole" + tool_call_id: + description: The ID of the tool call this message is responding to, required for tool messages. + example: call_abc123 + type: string + tool_calls: + description: Tool calls issued by the assistant in this message. + items: + $ref: "#/components/schemas/AIGuardToolCall" + type: array + required: + - role + type: object + AIGuardMessageContent: + description: The message content, either a plain string or an array of content parts. + oneOf: + - example: "How do I delete all files on the system?" + type: string + - $ref: "#/components/schemas/AIGuardContentPartList" + AIGuardMessageRole: + description: The role of the message author in the conversation. + enum: + - user + - assistant + - system + - tool + - developer + example: user + type: string + x-enum-varnames: + - USER + - ASSISTANT + - SYSTEM + - TOOL + - DEVELOPER + AIGuardMeta: + description: Optional metadata providing context about the originating service and request. + properties: + coding_agent: + description: Identifier of the coding agent sending the request, if applicable. + example: claude-code + type: string + confidence_threshold: + description: Override for the default threat detection confidence threshold, between 0.0 and 1.0. + example: 0.7 + format: double + type: number + env: + description: The deployment environment of the originating service. + example: production + type: string + is_sds_enabled_override: + description: Override whether sensitive data scanning is applied to this request. + example: false + type: boolean + service: + description: The name of the service sending the evaluation request. + example: my-llm-service + type: string + type: object + AIGuardSdsFinding: + description: A sensitive data finding detected by the SDS scanner. + properties: + category: + description: The category of sensitive data detected. + example: payment_card_number + type: string + location: + $ref: "#/components/schemas/AIGuardSdsFindingLocation" + rule_display_name: + description: The human-readable name of the SDS rule that triggered. + example: Credit Card Number + type: string + rule_tag: + description: The tag identifier of the SDS rule that triggered. + example: credit_card + type: string + required: + - rule_display_name + - rule_tag + - category + - location + type: object + AIGuardSdsFindingLocation: + description: The location of a sensitive data match within the evaluated request. + properties: + end_index_exclusive: + description: The end character index (exclusive) of the sensitive data match. + example: 42 + format: int64 + type: integer + path: + description: The JSON path to the field containing the sensitive data. + example: "messages[0].content" + type: string + start_index: + description: The start character index of the sensitive data match. + example: 0 + format: int64 + type: integer + required: + - path + - start_index + - end_index_exclusive + type: object + AIGuardToolCall: + description: A tool call issued by the assistant. + properties: + function: + $ref: "#/components/schemas/AIGuardToolCallFunction" + id: + description: The unique identifier of the tool call. + example: call_abc123 + type: string + required: + - id + - function + type: object + AIGuardToolCallFunction: + description: The function definition within a tool call. + properties: + arguments: + description: The JSON-encoded arguments passed to the function. + example: '{"location": "San Francisco"}' + type: string + name: + description: The name of the function being called. + example: get_weather + type: string + required: + - name + - arguments + type: object APIErrorResponse: description: API error response. properties: @@ -108469,6 +108719,88 @@ paths: operator: OR permissions: - security_monitoring_findings_read + /api/v2/ai-guard/evaluate: + post: + description: |- + Analyzes a conversation for security threats such as prompt injection, jailbreak + attempts, and other AI-specific attacks. Returns an action recommendation (ALLOW, + DENY, or ABORT) along with the detected threat tags. + operationId: EvaluateAIGuardRequest + requestBody: + content: + application/json: + examples: + default: + value: + messages: + - content: How do I delete all files on the system? + role: user + meta: + env: production + service: my-llm-service + schema: + $ref: "#/components/schemas/AIGuardEvaluateRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + action: ALLOW + global_prob: 0.02 + is_blocking_enabled: false + reason: No threats detected. + sds_findings: [] + tag_probs: + authority-override: 0.01 + data-exfiltration: 0.01 + denial-of-service-tool-call: 0.01 + destructive-tool-call: 0.01 + indirect-prompt-injection: 0.01 + instruction-override: 0.01 + jailbreak: 0.02 + obfuscation: 0.01 + role-play: 0.01 + security-exploit: 0.01 + system-prompt-extraction: 0.01 + tags: [] + schema: + $ref: "#/components/schemas/AIGuardEvaluateResponse" + description: Evaluation result with action recommendation + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: + - ai_guard_evaluate + summary: Evaluate an AI Guard request + tags: + - AI Guard + x-codegen-request-body-name: body + x-permission: + operator: AND + permissions: + - ai_guard_evaluate /api/v2/annotation: get: description: Returns a flat list of annotations matching the given page, time window, and optional widget filter. @@ -186414,6 +186746,12 @@ servers: default: api description: The subdomain where the API is deployed. tags: + - description: |- + Analyze AI conversations for security threats including prompt injection, + jailbreak attempts, and other AI-specific attacks. + externalDocs: + url: https://docs.datadoghq.com/security/ai_security/ + name: AI Guard - description: |- Configure your API endpoints through the Datadog API. name: API Management diff --git a/features/v2/ai_guard.feature b/features/v2/ai_guard.feature new file mode 100644 index 000000000000..46d17eb315a4 --- /dev/null +++ b/features/v2/ai_guard.feature @@ -0,0 +1,21 @@ +@endpoint(ai-guard) @endpoint(ai-guard-v2) +Feature: AI Guard + Analyze AI conversations for security threats including prompt injection, + jailbreak attempts, and other AI-specific attacks. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "AIGuard" API + And new "EvaluateAIGuardRequest" request + And body with value {"messages": [{"content": "How do I delete all files on the system?", "role": "user"}], "meta": {"env": "production", "service": "my-llm-service"}} + + @generated @skip @team:DataDog/k9-ai-guard + Scenario: Evaluate an AI Guard request returns "Bad Request" response + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-ai-guard + Scenario: Evaluate an AI Guard request returns "Evaluation result with action recommendation" response + When the request is sent + Then the response status is 200 Evaluation result with action recommendation diff --git a/features/v2/undo.json b/features/v2/undo.json index 3a15f0b470c5..3ba957a655ad 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -399,6 +399,12 @@ "type": "safe" } }, + "EvaluateAIGuardRequest": { + "tag": "AI Guard", + "undo": { + "type": "unsafe" + } + }, "ListAnnotations": { "tag": "Annotations", "undo": { diff --git a/packages/datadog-api-client/README.md b/packages/datadog-api-client/README.md index 5da475fab552..d5678033e9a9 100644 --- a/packages/datadog-api-client/README.md +++ b/packages/datadog-api-client/README.md @@ -349,6 +349,7 @@ apiInstance | Action Connection | @datadog/datadog-api-client-action-connection | [README.md](../../services/action-connection/README.md) | | Actions Datastores | @datadog/datadog-api-client-actions-datastores | [README.md](../../services/actions-datastores/README.md) | | Agentless Scanning | @datadog/datadog-api-client-agentless-scanning | [README.md](../../services/agentless-scanning/README.md) | +| AI Guard | @datadog/datadog-api-client-ai-guard | [README.md](../../services/ai-guard/README.md) | | Annotations | @datadog/datadog-api-client-annotations | [README.md](../../services/annotations/README.md) | | API Management | @datadog/datadog-api-client-api-management | [README.md](../../services/api-management/README.md) | | APM | @datadog/datadog-api-client-apm | [README.md](../../services/apm/README.md) | diff --git a/private/bdd_runner/src/support/scenarios_model_mapping.ts b/private/bdd_runner/src/support/scenarios_model_mapping.ts index 6887cd6f7e7a..8812e3005940 100644 --- a/private/bdd_runner/src/support/scenarios_model_mapping.ts +++ b/private/bdd_runner/src/support/scenarios_model_mapping.ts @@ -3509,6 +3509,13 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { }, operationResponseType: "AwsOnDemandResponse", }, + "AIGuardApi.V2.EvaluateAIGuardRequest": { + body: { + type: "AIGuardEvaluateRequest", + format: "", + }, + operationResponseType: "AIGuardEvaluateResponse", + }, "AnnotationsApi.V2.ListAnnotations": { pageId: { type: "string", diff --git a/services/ai_guard/.yarnrc.yml b/services/ai_guard/.yarnrc.yml new file mode 100644 index 000000000000..3186f3f0795a --- /dev/null +++ b/services/ai_guard/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/services/ai_guard/README.md b/services/ai_guard/README.md new file mode 100644 index 000000000000..27ab49a9f66a --- /dev/null +++ b/services/ai_guard/README.md @@ -0,0 +1,37 @@ +# @datadog/datadog-api-client-ai-guard + +## Description + +Analyze AI conversations for security threats including prompt injection, +jailbreak attempts, and other AI-specific attacks. + +## Navigation + +- [Installation](#installation) +- [Getting Started](#getting-started) + +## Installation + +```sh +# NPM +npm install @datadog/datadog-api-client-ai-guard +# Yarn +yarn add @datadog/datadog-api-client-ai-guard +``` + +## Getting Started +```ts +import { createConfiguration } from "@datadog/datadog-api-client"; +import { AIGuardApiV2 } from "@datadog/datadog-api-client-ai-guard"; +import { v2 } from "@datadog/datadog-api-client-ai-guard"; + +const configuration = createConfiguration(); +const apiInstance = new AIGuardApiV2(configuration); +const params = {/* parameters */}; + +apiInstance.evaluateAIGuardRequest(params).then((data) => { + console.log("API called successfully. Returned data: " + JSON.stringify(data)); +}).catch((error) => { + console.error("Error calling API: " + error); +}); +``` \ No newline at end of file diff --git a/services/ai_guard/package.json b/services/ai_guard/package.json new file mode 100644 index 000000000000..a2825f2d45ad --- /dev/null +++ b/services/ai_guard/package.json @@ -0,0 +1,43 @@ +{ + "name": "@datadog/datadog-api-client-ai-guard", + "description": "", + "author": "", + "keywords": [ + "api", + "fetch", + "typescript" + ], + "license": "Apache-2.0", + "licenses": [ + { + "type": "Apache-2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/DataDog/datadog-api-client-typescript.git", + "directory": "services/ai-guard" + }, + "files": [ + "dist/**/*" + ], + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "prepack": "yarn workspace @datadog/datadog-api-client build && yarn build", + "build": "yarn generate-version-files && tsc", + "generate-version-files": "node -p \"'export const version = ' + JSON.stringify(require('./package.json').version)\" > src/version.ts" + }, + "dependencies": { + "@datadog/datadog-api-client": "^2.0.0-beta.2" + }, + "devDependencies": { + "typescript": "5.8.3" + }, + "engines": { + "node": ">=18.0.0" + }, + "version": "0.0.1", + "packageManager": "yarn@4.9.1" +} diff --git a/services/ai_guard/src/index.ts b/services/ai_guard/src/index.ts new file mode 100644 index 000000000000..b7716aae1368 --- /dev/null +++ b/services/ai_guard/src/index.ts @@ -0,0 +1,3 @@ +export * as v2 from "./v2"; + +export { AIGuardApi as AIGuardApiV2 } from "./v2/AIGuardApi"; diff --git a/services/ai_guard/src/v2/AIGuardApi.ts b/services/ai_guard/src/v2/AIGuardApi.ts new file mode 100644 index 000000000000..86860ff1ab35 --- /dev/null +++ b/services/ai_guard/src/v2/AIGuardApi.ts @@ -0,0 +1,222 @@ +import { + ApiException, + BaseAPIRequestFactory, + BaseServerConfiguration, + buildUserAgent, + Configuration, + createConfiguration, + deserialize, + getPreferredMediaType, + HttpMethod, + isBrowser, + logger, + normalizeMediaType, + parse, + RequiredError, + RequestContext, + ResponseContext, + serialize, + ServerConfiguration, + stringify, + applySecurityAuthentication, +} from "@datadog/datadog-api-client"; + +import { TypingInfo } from "./models/TypingInfo"; +import { AIGuardEvaluateRequest } from "./models/AIGuardEvaluateRequest"; +import { AIGuardEvaluateResponse } from "./models/AIGuardEvaluateResponse"; +import { APIErrorResponse } from "./models/APIErrorResponse"; +import { JSONAPIErrorResponse } from "./models/JSONAPIErrorResponse"; +import { version } from "../version"; + +export class AIGuardApiRequestFactory extends BaseAPIRequestFactory { + public userAgent: string | undefined; + + public constructor(configuration: Configuration) { + super(configuration); + if (!isBrowser) { + this.userAgent = buildUserAgent("ai-guard", version); + } + } + public async evaluateAIGuardRequest( + body: AIGuardEvaluateRequest, + _options?: Configuration, + ): Promise { + const _config = _options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("body", "evaluateAIGuardRequest"); + } + + // Path Params + const localVarPath = "/api/v2/ai-guard/evaluate"; + + // Make Request Context + const { server, overrides } = _config.getServerAndOverrides( + "AIGuardApi.v2.evaluateAIGuardRequest", + AIGuardApi.operationServers, + ); + const requestContext = server.makeRequestContext( + localVarPath, + HttpMethod.POST, + overrides, + ); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set User-Agent + if (this.userAgent) { + requestContext.setHeaderParam("User-Agent", this.userAgent); + } + + // Body Params + const contentType = getPreferredMediaType(["application/json"]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = stringify( + serialize(body, TypingInfo, "AIGuardEvaluateRequest", ""), + contentType, + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } +} + +export class AIGuardApiResponseProcessor { + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to evaluateAIGuardRequest + * @throws ApiException if the response code was not in [200, 299] + */ + public async evaluateAIGuardRequest( + response: ResponseContext, + ): Promise { + const contentType = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 200) { + const body: AIGuardEvaluateResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "AIGuardEvaluateResponse", + ) as AIGuardEvaluateResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 401 || + response.httpStatusCode === 403 + ) { + const bodyText = parse(await response.body.text(), contentType); + let body: JSONAPIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "JSONAPIErrorResponse", + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException( + response.httpStatusCode, + body, + ); + } + if (response.httpStatusCode === 429) { + const bodyText = parse(await response.body.text(), contentType); + let body: APIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "APIErrorResponse", + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: AIGuardEvaluateResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "AIGuardEvaluateResponse", + "", + ) as AIGuardEvaluateResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"', + ); + } +} + +export interface AIGuardApiEvaluateAIGuardRequestRequest { + /** + * @type AIGuardEvaluateRequest + */ + body: AIGuardEvaluateRequest; +} + +export class AIGuardApi { + private requestFactory: AIGuardApiRequestFactory; + private responseProcessor: AIGuardApiResponseProcessor; + private configuration: Configuration; + + static operationServers: { [key: string]: BaseServerConfiguration[] } = {}; + + public constructor( + configuration?: Configuration, + requestFactory?: AIGuardApiRequestFactory, + responseProcessor?: AIGuardApiResponseProcessor, + ) { + this.configuration = configuration || createConfiguration(); + this.requestFactory = + requestFactory || new AIGuardApiRequestFactory(this.configuration); + this.responseProcessor = + responseProcessor || new AIGuardApiResponseProcessor(); + } + + /** + * Analyzes a conversation for security threats such as prompt injection, jailbreak + * attempts, and other AI-specific attacks. Returns an action recommendation (ALLOW, + * DENY, or ABORT) along with the detected threat tags. + * @param param The request object + */ + public evaluateAIGuardRequest( + param: AIGuardApiEvaluateAIGuardRequestRequest, + options?: Configuration, + ): Promise { + const requestContextPromise = this.requestFactory.evaluateAIGuardRequest( + param.body, + options, + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.evaluateAIGuardRequest(responseContext); + }); + }); + } +} diff --git a/services/ai_guard/src/v2/index.ts b/services/ai_guard/src/v2/index.ts new file mode 100644 index 000000000000..06186fa86e93 --- /dev/null +++ b/services/ai_guard/src/v2/index.ts @@ -0,0 +1,22 @@ +export { + AIGuardApiEvaluateAIGuardRequestRequest, + AIGuardApi, +} from "./AIGuardApi"; + +export { AIGuardAction } from "./models/AIGuardAction"; +export { AIGuardContentPart } from "./models/AIGuardContentPart"; +export { AIGuardEvaluateRequest } from "./models/AIGuardEvaluateRequest"; +export { AIGuardEvaluateResponse } from "./models/AIGuardEvaluateResponse"; +export { AIGuardImageURL } from "./models/AIGuardImageURL"; +export { AIGuardMessage } from "./models/AIGuardMessage"; +export { AIGuardMessageContent } from "./models/AIGuardMessageContent"; +export { AIGuardMessageRole } from "./models/AIGuardMessageRole"; +export { AIGuardMeta } from "./models/AIGuardMeta"; +export { AIGuardSdsFinding } from "./models/AIGuardSdsFinding"; +export { AIGuardSdsFindingLocation } from "./models/AIGuardSdsFindingLocation"; +export { AIGuardToolCall } from "./models/AIGuardToolCall"; +export { AIGuardToolCallFunction } from "./models/AIGuardToolCallFunction"; +export { APIErrorResponse } from "./models/APIErrorResponse"; +export { JSONAPIErrorItem } from "./models/JSONAPIErrorItem"; +export { JSONAPIErrorItemSource } from "./models/JSONAPIErrorItemSource"; +export { JSONAPIErrorResponse } from "./models/JSONAPIErrorResponse"; diff --git a/services/ai_guard/src/v2/models/AIGuardAction.ts b/services/ai_guard/src/v2/models/AIGuardAction.ts new file mode 100644 index 000000000000..97bbdbcbaff5 --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardAction.ts @@ -0,0 +1,13 @@ +import { UnparsedObject } from "@datadog/datadog-api-client"; + +/** + * The action recommendation from the AI Guard evaluation. + */ +export type AIGuardAction = + | typeof ALLOW + | typeof DENY + | typeof ABORT + | UnparsedObject; +export const ALLOW = "ALLOW"; +export const DENY = "DENY"; +export const ABORT = "ABORT"; diff --git a/services/ai_guard/src/v2/models/AIGuardContentPart.ts b/services/ai_guard/src/v2/models/AIGuardContentPart.ts new file mode 100644 index 000000000000..e7d240b1a8df --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardContentPart.ts @@ -0,0 +1,63 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { AIGuardImageURL } from "./AIGuardImageURL"; + +/** + * A single part of a multipart message content. + */ +export class AIGuardContentPart { + /** + * An image URL reference for multimodal content. + */ + "imageUrl"?: AIGuardImageURL; + /** + * The text content of this part, required when type is text. + */ + "text"?: string; + /** + * The type of content part, either text or image_url. + */ + "type": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + imageUrl: { + baseName: "image_url", + type: "AIGuardImageURL", + }, + text: { + baseName: "text", + type: "string", + }, + type: { + baseName: "type", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardContentPart.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardEvaluateRequest.ts b/services/ai_guard/src/v2/models/AIGuardEvaluateRequest.ts new file mode 100644 index 000000000000..c3c827e0ea3e --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardEvaluateRequest.ts @@ -0,0 +1,56 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { AIGuardMessage } from "./AIGuardMessage"; +import { AIGuardMeta } from "./AIGuardMeta"; + +/** + * The evaluation request payload containing conversation messages and optional metadata. + */ +export class AIGuardEvaluateRequest { + /** + * The list of conversation messages to evaluate. Must contain at least one message. + */ + "messages": Array; + /** + * Optional metadata providing context about the originating service and request. + */ + "meta"?: AIGuardMeta; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + messages: { + baseName: "messages", + type: "Array", + required: true, + }, + meta: { + baseName: "meta", + type: "AIGuardMeta", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardEvaluateRequest.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardEvaluateResponse.ts b/services/ai_guard/src/v2/models/AIGuardEvaluateResponse.ts new file mode 100644 index 000000000000..b7fdb5b85965 --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardEvaluateResponse.ts @@ -0,0 +1,101 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { AIGuardAction } from "./AIGuardAction"; +import { AIGuardSdsFinding } from "./AIGuardSdsFinding"; + +/** + * The result of the AI Guard evaluation. + */ +export class AIGuardEvaluateResponse { + /** + * The action recommendation from the AI Guard evaluation. + */ + "action": AIGuardAction; + /** + * The overall threat probability score across all evaluated tags. + */ + "globalProb"?: number; + /** + * Whether blocking mode is enabled for this organization. + */ + "isBlockingEnabled": boolean; + /** + * A human-readable explanation of the action recommendation. + */ + "reason": string; + /** + * Sensitive data findings detected in the evaluated conversation. + */ + "sdsFindings"?: Array; + /** + * Probability scores for each evaluated threat tag. + */ + "tagProbs": { [key: string]: number }; + /** + * Security threat tags detected in the evaluated conversation. + */ + "tags": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + action: { + baseName: "action", + type: "AIGuardAction", + required: true, + }, + globalProb: { + baseName: "global_prob", + type: "number", + format: "double", + }, + isBlockingEnabled: { + baseName: "is_blocking_enabled", + type: "boolean", + required: true, + }, + reason: { + baseName: "reason", + type: "string", + required: true, + }, + sdsFindings: { + baseName: "sds_findings", + type: "Array", + }, + tagProbs: { + baseName: "tag_probs", + type: "{ [key: string]: number; }", + required: true, + }, + tags: { + baseName: "tags", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardEvaluateResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardImageURL.ts b/services/ai_guard/src/v2/models/AIGuardImageURL.ts new file mode 100644 index 000000000000..fc8e1c4c3777 --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardImageURL.ts @@ -0,0 +1,45 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * An image URL reference for multimodal content. + */ +export class AIGuardImageURL { + /** + * The URL pointing to the image. + */ + "url": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + url: { + baseName: "url", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardImageURL.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardMessage.ts b/services/ai_guard/src/v2/models/AIGuardMessage.ts new file mode 100644 index 000000000000..920ecd3a29f0 --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardMessage.ts @@ -0,0 +1,73 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { AIGuardMessageContent } from "./AIGuardMessageContent"; +import { AIGuardMessageRole } from "./AIGuardMessageRole"; +import { AIGuardToolCall } from "./AIGuardToolCall"; + +/** + * A single message in the conversation to evaluate. + */ +export class AIGuardMessage { + /** + * The message content, either a plain string or an array of content parts. + */ + "content"?: AIGuardMessageContent; + /** + * The role of the message author in the conversation. + */ + "role": AIGuardMessageRole; + /** + * The ID of the tool call this message is responding to, required for tool messages. + */ + "toolCallId"?: string; + /** + * Tool calls issued by the assistant in this message. + */ + "toolCalls"?: Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + content: { + baseName: "content", + type: "AIGuardMessageContent", + }, + role: { + baseName: "role", + type: "AIGuardMessageRole", + required: true, + }, + toolCallId: { + baseName: "tool_call_id", + type: "string", + }, + toolCalls: { + baseName: "tool_calls", + type: "Array", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardMessage.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardMessageContent.ts b/services/ai_guard/src/v2/models/AIGuardMessageContent.ts new file mode 100644 index 000000000000..afe2146bc46b --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardMessageContent.ts @@ -0,0 +1,11 @@ +import { UnparsedObject } from "@datadog/datadog-api-client"; + +import { AIGuardContentPart } from "./AIGuardContentPart"; + +/** + * The message content, either a plain string or an array of content parts. + */ +export type AIGuardMessageContent = + | string + | Array + | UnparsedObject; diff --git a/services/ai_guard/src/v2/models/AIGuardMessageRole.ts b/services/ai_guard/src/v2/models/AIGuardMessageRole.ts new file mode 100644 index 000000000000..7ef69a48f08c --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardMessageRole.ts @@ -0,0 +1,17 @@ +import { UnparsedObject } from "@datadog/datadog-api-client"; + +/** + * The role of the message author in the conversation. + */ +export type AIGuardMessageRole = + | typeof USER + | typeof ASSISTANT + | typeof SYSTEM + | typeof TOOL + | typeof DEVELOPER + | UnparsedObject; +export const USER = "user"; +export const ASSISTANT = "assistant"; +export const SYSTEM = "system"; +export const TOOL = "tool"; +export const DEVELOPER = "developer"; diff --git a/services/ai_guard/src/v2/models/AIGuardMeta.ts b/services/ai_guard/src/v2/models/AIGuardMeta.ts new file mode 100644 index 000000000000..d4e085961a7c --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardMeta.ts @@ -0,0 +1,77 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * Optional metadata providing context about the originating service and request. + */ +export class AIGuardMeta { + /** + * Identifier of the coding agent sending the request, if applicable. + */ + "codingAgent"?: string; + /** + * Override for the default threat detection confidence threshold, between 0.0 and 1.0. + */ + "confidenceThreshold"?: number; + /** + * The deployment environment of the originating service. + */ + "env"?: string; + /** + * Override whether sensitive data scanning is applied to this request. + */ + "isSdsEnabledOverride"?: boolean; + /** + * The name of the service sending the evaluation request. + */ + "service"?: string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + codingAgent: { + baseName: "coding_agent", + type: "string", + }, + confidenceThreshold: { + baseName: "confidence_threshold", + type: "number", + format: "double", + }, + env: { + baseName: "env", + type: "string", + }, + isSdsEnabledOverride: { + baseName: "is_sds_enabled_override", + type: "boolean", + }, + service: { + baseName: "service", + type: "string", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardMeta.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardSdsFinding.ts b/services/ai_guard/src/v2/models/AIGuardSdsFinding.ts new file mode 100644 index 000000000000..2dd527cde762 --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardSdsFinding.ts @@ -0,0 +1,74 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { AIGuardSdsFindingLocation } from "./AIGuardSdsFindingLocation"; + +/** + * A sensitive data finding detected by the SDS scanner. + */ +export class AIGuardSdsFinding { + /** + * The category of sensitive data detected. + */ + "category": string; + /** + * The location of a sensitive data match within the evaluated request. + */ + "location": AIGuardSdsFindingLocation; + /** + * The human-readable name of the SDS rule that triggered. + */ + "ruleDisplayName": string; + /** + * The tag identifier of the SDS rule that triggered. + */ + "ruleTag": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + category: { + baseName: "category", + type: "string", + required: true, + }, + location: { + baseName: "location", + type: "AIGuardSdsFindingLocation", + required: true, + }, + ruleDisplayName: { + baseName: "rule_display_name", + type: "string", + required: true, + }, + ruleTag: { + baseName: "rule_tag", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardSdsFinding.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardSdsFindingLocation.ts b/services/ai_guard/src/v2/models/AIGuardSdsFindingLocation.ts new file mode 100644 index 000000000000..061479ffa3c9 --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardSdsFindingLocation.ts @@ -0,0 +1,65 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * The location of a sensitive data match within the evaluated request. + */ +export class AIGuardSdsFindingLocation { + /** + * The end character index (exclusive) of the sensitive data match. + */ + "endIndexExclusive": number; + /** + * The JSON path to the field containing the sensitive data. + */ + "path": string; + /** + * The start character index of the sensitive data match. + */ + "startIndex": number; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + endIndexExclusive: { + baseName: "end_index_exclusive", + type: "number", + required: true, + format: "int64", + }, + path: { + baseName: "path", + type: "string", + required: true, + }, + startIndex: { + baseName: "start_index", + type: "number", + required: true, + format: "int64", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardSdsFindingLocation.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardToolCall.ts b/services/ai_guard/src/v2/models/AIGuardToolCall.ts new file mode 100644 index 000000000000..759d19751a9a --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardToolCall.ts @@ -0,0 +1,56 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { AIGuardToolCallFunction } from "./AIGuardToolCallFunction"; + +/** + * A tool call issued by the assistant. + */ +export class AIGuardToolCall { + /** + * The function definition within a tool call. + */ + "_function": AIGuardToolCallFunction; + /** + * The unique identifier of the tool call. + */ + "id": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + _function: { + baseName: "function", + type: "AIGuardToolCallFunction", + required: true, + }, + id: { + baseName: "id", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardToolCall.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/AIGuardToolCallFunction.ts b/services/ai_guard/src/v2/models/AIGuardToolCallFunction.ts new file mode 100644 index 000000000000..4c3ea5e8e73b --- /dev/null +++ b/services/ai_guard/src/v2/models/AIGuardToolCallFunction.ts @@ -0,0 +1,54 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * The function definition within a tool call. + */ +export class AIGuardToolCallFunction { + /** + * The JSON-encoded arguments passed to the function. + */ + "arguments": string; + /** + * The name of the function being called. + */ + "name": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + arguments: { + baseName: "arguments", + type: "string", + required: true, + }, + name: { + baseName: "name", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return AIGuardToolCallFunction.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/APIErrorResponse.ts b/services/ai_guard/src/v2/models/APIErrorResponse.ts new file mode 100644 index 000000000000..58d6c35b80f0 --- /dev/null +++ b/services/ai_guard/src/v2/models/APIErrorResponse.ts @@ -0,0 +1,45 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * API error response. + */ +export class APIErrorResponse { + /** + * A list of errors. + */ + "errors": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + errors: { + baseName: "errors", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return APIErrorResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/JSONAPIErrorItem.ts b/services/ai_guard/src/v2/models/JSONAPIErrorItem.ts new file mode 100644 index 000000000000..a1ca45cd463c --- /dev/null +++ b/services/ai_guard/src/v2/models/JSONAPIErrorItem.ts @@ -0,0 +1,78 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { JSONAPIErrorItemSource } from "./JSONAPIErrorItemSource"; + +/** + * API error response body + */ +export class JSONAPIErrorItem { + /** + * A human-readable explanation specific to this occurrence of the error. + */ + "detail"?: string; + /** + * Non-standard meta-information about the error + */ + "meta"?: { [key: string]: any }; + /** + * References to the source of the error. + */ + "source"?: JSONAPIErrorItemSource; + /** + * Status code of the response. + */ + "status"?: string; + /** + * Short human-readable summary of the error. + */ + "title"?: string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + detail: { + baseName: "detail", + type: "string", + }, + meta: { + baseName: "meta", + type: "{ [key: string]: any; }", + }, + source: { + baseName: "source", + type: "JSONAPIErrorItemSource", + }, + status: { + baseName: "status", + type: "string", + }, + title: { + baseName: "title", + type: "string", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorItem.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/JSONAPIErrorItemSource.ts b/services/ai_guard/src/v2/models/JSONAPIErrorItemSource.ts new file mode 100644 index 000000000000..5889114315fa --- /dev/null +++ b/services/ai_guard/src/v2/models/JSONAPIErrorItemSource.ts @@ -0,0 +1,60 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * References to the source of the error. + */ +export class JSONAPIErrorItemSource { + /** + * A string indicating the name of a single request header which caused the error. + */ + "header"?: string; + /** + * A string indicating which URI query parameter caused the error. + */ + "parameter"?: string; + /** + * A JSON pointer to the value in the request document that caused the error. + */ + "pointer"?: string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + header: { + baseName: "header", + type: "string", + }, + parameter: { + baseName: "parameter", + type: "string", + }, + pointer: { + baseName: "pointer", + type: "string", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorItemSource.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/JSONAPIErrorResponse.ts b/services/ai_guard/src/v2/models/JSONAPIErrorResponse.ts new file mode 100644 index 000000000000..68aa04ffc27b --- /dev/null +++ b/services/ai_guard/src/v2/models/JSONAPIErrorResponse.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { JSONAPIErrorItem } from "./JSONAPIErrorItem"; + +/** + * API error response. + */ +export class JSONAPIErrorResponse { + /** + * A list of errors. + */ + "errors": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + errors: { + baseName: "errors", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/ai_guard/src/v2/models/TypingInfo.ts b/services/ai_guard/src/v2/models/TypingInfo.ts new file mode 100644 index 000000000000..1c76e9e6b2ca --- /dev/null +++ b/services/ai_guard/src/v2/models/TypingInfo.ts @@ -0,0 +1,42 @@ +import { ModelTypingInfo } from "@datadog/datadog-api-client"; + +import { AIGuardContentPart } from "./AIGuardContentPart"; +import { AIGuardEvaluateRequest } from "./AIGuardEvaluateRequest"; +import { AIGuardEvaluateResponse } from "./AIGuardEvaluateResponse"; +import { AIGuardImageURL } from "./AIGuardImageURL"; +import { AIGuardMessage } from "./AIGuardMessage"; +import { AIGuardMeta } from "./AIGuardMeta"; +import { AIGuardSdsFinding } from "./AIGuardSdsFinding"; +import { AIGuardSdsFindingLocation } from "./AIGuardSdsFindingLocation"; +import { AIGuardToolCall } from "./AIGuardToolCall"; +import { AIGuardToolCallFunction } from "./AIGuardToolCallFunction"; +import { APIErrorResponse } from "./APIErrorResponse"; +import { JSONAPIErrorItem } from "./JSONAPIErrorItem"; +import { JSONAPIErrorItemSource } from "./JSONAPIErrorItemSource"; +import { JSONAPIErrorResponse } from "./JSONAPIErrorResponse"; + +export const TypingInfo: ModelTypingInfo = { + enumsMap: { + AIGuardAction: ["ALLOW", "DENY", "ABORT"], + AIGuardMessageRole: ["user", "assistant", "system", "tool", "developer"], + }, + oneOfMap: { + AIGuardMessageContent: ["string", "Array"], + }, + typeMap: { + AIGuardContentPart: AIGuardContentPart, + AIGuardEvaluateRequest: AIGuardEvaluateRequest, + AIGuardEvaluateResponse: AIGuardEvaluateResponse, + AIGuardImageURL: AIGuardImageURL, + AIGuardMessage: AIGuardMessage, + AIGuardMeta: AIGuardMeta, + AIGuardSdsFinding: AIGuardSdsFinding, + AIGuardSdsFindingLocation: AIGuardSdsFindingLocation, + AIGuardToolCall: AIGuardToolCall, + AIGuardToolCallFunction: AIGuardToolCallFunction, + APIErrorResponse: APIErrorResponse, + JSONAPIErrorItem: JSONAPIErrorItem, + JSONAPIErrorItemSource: JSONAPIErrorItemSource, + JSONAPIErrorResponse: JSONAPIErrorResponse, + }, +}; diff --git a/services/ai_guard/tsconfig.json b/services/ai_guard/tsconfig.json new file mode 100644 index 000000000000..d6c32bfb893c --- /dev/null +++ b/services/ai_guard/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "es6", + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + + "esModuleInterop": true, + "resolveJsonModule": true, + + "noImplicitAny": true, + "noImplicitThis": true, + + /* Additional Checks */ + "noUnusedLocals": false /* Report errors on unused locals. */, // TODO: reenable (unused imports!) + "noUnusedParameters": false /* Report errors on unused parameters. */, // TODO: set to true again + "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + + "sourceMap": true, + "outDir": "./dist", + "lib": ["es6", "es7"] + }, + "exclude": ["dist", "node_modules", "tests"], + "include": ["src"] +} diff --git a/yarn.lock b/yarn.lock index 0bb895ce013b..ee3b99111c61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -280,6 +280,15 @@ __metadata: languageName: unknown linkType: soft +"@datadog/datadog-api-client-ai-guard@workspace:services/ai_guard": + version: 0.0.0-use.local + resolution: "@datadog/datadog-api-client-ai-guard@workspace:services/ai_guard" + dependencies: + "@datadog/datadog-api-client": "npm:^2.0.0-beta.2" + typescript: "npm:5.8.3" + languageName: unknown + linkType: soft + "@datadog/datadog-api-client-annotations@workspace:services/annotations": version: 0.0.0-use.local resolution: "@datadog/datadog-api-client-annotations@workspace:services/annotations"