diff --git a/.fern/metadata.json b/.fern/metadata.json index ebb0cb8b..a7f41802 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,5 +1,5 @@ { - "cliVersion": "5.75.1", + "cliVersion": "5.77.0", "generatorName": "fernapi/fern-typescript-node-sdk", "generatorVersion": "3.54.0", "generatorConfig": { @@ -34,6 +34,6 @@ } } }, - "originGitCommit": "94a714862b705ee097af1b7ef3c5d9affa7fc382", + "originGitCommit": "e051149eeb3680e201b74bc59dac5132de3df262", "sdkVersion": "0.0.0-dev" } diff --git a/src/api/errors/ConflictError.ts b/src/api/errors/ConflictError.ts index ea2acb33..58cdc0c6 100644 --- a/src/api/errors/ConflictError.ts +++ b/src/api/errors/ConflictError.ts @@ -2,10 +2,9 @@ import type * as core from "../../core/index.js"; import * as errors from "../../errors/index.js"; -import type * as Corti from "../index.js"; export class ConflictError extends errors.CortiError { - constructor(body: Corti.ErrorResponse, rawResponse?: core.RawResponse) { + constructor(body?: unknown, rawResponse?: core.RawResponse) { super({ message: "ConflictError", statusCode: 409, diff --git a/src/api/resources/agents/client/Client.ts b/src/api/resources/agents/client/Client.ts index c9b40606..9fe90217 100644 --- a/src/api/resources/agents/client/Client.ts +++ b/src/api/resources/agents/client/Client.ts @@ -15,6 +15,9 @@ export declare namespace AgentsClient { export interface RequestOptions extends BaseRequestOptions {} } +/** + * Create, read, update, and delete agents. + */ export class AgentsClient { protected readonly _options: NormalizedClientOptionsWithAuth; @@ -23,6 +26,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint retrieves a list of all agents that can be called by the Corti Agent Framework. * * @param {Corti.AgentsListRequest} request @@ -105,6 +110,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint allows the creation of a new agent that can be utilized in the `POST /agents/{id}/v1/message:send` endpoint. * * @param {Corti.AgentsCreateAgent} request @@ -197,6 +204,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint retrieves an agent by its identifier. The agent contains information about its capabilities and the experts it can call. * * @param {string} id - The identifier of the agent associated with the context. @@ -276,6 +285,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint deletes an agent by its identifier. Once deleted, the agent can no longer be used in threads. * * @param {string} id - The identifier of the agent associated with the context. @@ -343,6 +354,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint updates an existing agent. Only the fields provided in the request body will be updated; other fields will remain unchanged. * * @param {string} id - The identifier of the agent associated with the context. @@ -434,6 +447,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint retrieves the agent card in JSON format, which provides metadata about the agent, including its name, description, and the experts it can call. * * @param {string} id - The identifier of the agent associated with the context. @@ -513,10 +528,12 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint sends a message to the specified agent to start or continue a task. The agent processes the message and returns a response. If the message contains a task ID that matches an ongoing task, the agent will continue that task; otherwise, it will start a new task. * * @param {string} id - The identifier of the agent associated with the context. - * @param {Corti.AgentsMessageSendParams} request + * @param {Corti.AgentsMessageSendBody} request * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Corti.BadRequestError} @@ -540,7 +557,7 @@ export class AgentsClient { */ public messageSend( id: string, - request: Corti.AgentsMessageSendParams, + request: Corti.AgentsMessageSendBody, requestOptions?: AgentsClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__messageSend(id, request, requestOptions)); @@ -548,7 +565,7 @@ export class AgentsClient { private async __messageSend( id: string, - request: Corti.AgentsMessageSendParams, + request: Corti.AgentsMessageSendBody, requestOptions?: AgentsClient.RequestOptions, ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); @@ -569,7 +586,7 @@ export class AgentsClient { contentType: "application/json", queryParameters: requestOptions?.queryParams, requestType: "json", - body: serializers.AgentsMessageSendParams.jsonOrThrow(request, { + body: serializers.AgentsMessageSendBody.jsonOrThrow(request, { unrecognizedObjectKeys: "strip", omitUndefined: true, }), @@ -617,6 +634,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint retrieves the status and details of a specific task associated with the given agent. It provides information about the task's current state, history, and any artifacts produced during its execution. * * @param {string} id - The identifier of the agent associated with the context. @@ -714,6 +733,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint retrieves all tasks and top-level messages associated with a specific context for the given agent. * * @param {string} id - The identifier of the agent associated with the context. @@ -809,6 +830,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint deletes a context (thread) and scrubs all associated data including messages, memories, and memory chunks for the given agent. Thread and task metadata is soft-deleted for audit purposes, while content columns are irreversibly overwritten. * * @param {string} id - The identifier of the agent associated with the context. @@ -887,6 +910,8 @@ export class AgentsClient { } /** + * @deprecated + * * This endpoint retrieves the experts registry, which contains information about all available experts that can be referenced when creating agents through the AgentsCreateExpertReference schema. * * @param {Corti.AgentsGetRegistryExpertsRequest} request diff --git a/src/api/resources/agents/client/requests/AgentsMessageSendParams.ts b/src/api/resources/agents/client/requests/AgentsMessageSendBody.ts similarity index 93% rename from src/api/resources/agents/client/requests/AgentsMessageSendParams.ts rename to src/api/resources/agents/client/requests/AgentsMessageSendBody.ts index 53f9cf2e..922b0bda 100644 --- a/src/api/resources/agents/client/requests/AgentsMessageSendParams.ts +++ b/src/api/resources/agents/client/requests/AgentsMessageSendBody.ts @@ -16,7 +16,7 @@ import type * as Corti from "../../../../index.js"; * } * } */ -export interface AgentsMessageSendParams { +export interface AgentsMessageSendBody { message: Corti.AgentsMessage; configuration?: Corti.AgentsMessageSendConfiguration; /** Optional metadata that will be associated with the message. */ diff --git a/src/api/resources/agents/client/requests/index.ts b/src/api/resources/agents/client/requests/index.ts index e43b0bbc..dbc8bcb0 100644 --- a/src/api/resources/agents/client/requests/index.ts +++ b/src/api/resources/agents/client/requests/index.ts @@ -3,5 +3,5 @@ export type { AgentsGetContextRequest } from "./AgentsGetContextRequest.js"; export type { AgentsGetRegistryExpertsRequest } from "./AgentsGetRegistryExpertsRequest.js"; export type { AgentsGetTaskRequest } from "./AgentsGetTaskRequest.js"; export type { AgentsListRequest } from "./AgentsListRequest.js"; -export type { AgentsMessageSendParams } from "./AgentsMessageSendParams.js"; +export type { AgentsMessageSendBody } from "./AgentsMessageSendBody.js"; export type { AgentsUpdateAgent } from "./AgentsUpdateAgent.js"; diff --git a/src/api/resources/auth/client/Client.ts b/src/api/resources/auth/client/Client.ts index 61085918..3466e475 100644 --- a/src/api/resources/auth/client/Client.ts +++ b/src/api/resources/auth/client/Client.ts @@ -98,7 +98,7 @@ export class AuthClient { * authorization_code (with client_secret), authorization_code with PKCE (code_verifier), password (ROPC), or refresh_token. Use the returned access_token in the Authorization header when calling the Corti API. * * @param {string} tenantName - * @param {Corti.AuthTokenRequestBody} request + * @param {Corti.AuthTokenRequest} request * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Corti.BadRequestError} @@ -113,7 +113,7 @@ export class AuthClient { */ public token( tenantName: string, - request: Corti.AuthTokenRequestBody, + request: Corti.AuthTokenRequest, requestOptions?: AuthClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__token(tenantName, request, requestOptions)); @@ -121,7 +121,7 @@ export class AuthClient { private async __token( tenantName: string, - request: Corti.AuthTokenRequestBody, + request: Corti.AuthTokenRequest, requestOptions?: AuthClient.RequestOptions, ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); @@ -142,7 +142,7 @@ export class AuthClient { contentType: "application/x-www-form-urlencoded", queryParameters: requestOptions?.queryParams, requestType: "form", - body: serializers.AuthTokenRequestBody.jsonOrThrow(request, { + body: serializers.AuthTokenRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip", omitUndefined: true, }), diff --git a/src/api/resources/auth/types/AuthTokenRequestBody.ts b/src/api/resources/auth/types/AuthTokenRequest.ts similarity index 90% rename from src/api/resources/auth/types/AuthTokenRequestBody.ts rename to src/api/resources/auth/types/AuthTokenRequest.ts index 17aeb485..62bc3cad 100644 --- a/src/api/resources/auth/types/AuthTokenRequestBody.ts +++ b/src/api/resources/auth/types/AuthTokenRequest.ts @@ -2,7 +2,7 @@ import type * as Corti from "../../../index.js"; -export type AuthTokenRequestBody = +export type AuthTokenRequest = | Corti.AuthTokenRequestClientCredentials | Corti.AuthTokenRequestAuthorizationCode | Corti.AuthTokenRequestAuthorizationPkce diff --git a/src/api/resources/auth/types/index.ts b/src/api/resources/auth/types/index.ts index 536709bd..c07e19c2 100644 --- a/src/api/resources/auth/types/index.ts +++ b/src/api/resources/auth/types/index.ts @@ -1 +1 @@ -export * from "./AuthTokenRequestBody.js"; +export * from "./AuthTokenRequest.js"; diff --git a/src/api/resources/documents/client/Client.ts b/src/api/resources/documents/client/Client.ts index ed2310bb..b399cd18 100644 --- a/src/api/resources/documents/client/Client.ts +++ b/src/api/resources/documents/client/Client.ts @@ -142,7 +142,7 @@ export class DocumentsClient { * This endpoint offers different ways to generate a document. Find guides to document generation [here](/textgen/documents-standard). * * @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID. - * @param {Corti.DocumentsCreateRequest} request + * @param {Corti.CreateDocumentsRequest} request * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Corti.BadRequestError} @@ -152,19 +152,21 @@ export class DocumentsClient { * * @example * await client.documents.create("f47ac10b-58cc-4372-a567-0e02b2c3d479", { - * context: [{ - * type: "facts", - * data: [{ - * text: "text" - * }] - * }], - * templateKey: "templateKey", - * outputLanguage: "outputLanguage" + * body: { + * context: [{ + * type: "facts", + * data: [{ + * text: "text" + * }] + * }], + * templateKey: "templateKey", + * outputLanguage: "outputLanguage" + * } * }) */ public create( id: Corti.Uuid, - request: Corti.DocumentsCreateRequest, + request: Corti.CreateDocumentsRequest, requestOptions?: DocumentsClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__create(id, request, requestOptions)); @@ -172,14 +174,18 @@ export class DocumentsClient { private async __create( id: Corti.Uuid, - request: Corti.DocumentsCreateRequest, + request: Corti.CreateDocumentsRequest, requestOptions?: DocumentsClient.RequestOptions, ): Promise> { + const { cortiRetentionPolicy, body: _body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + mergeOnlyDefinedHeaders({ + "X-Corti-Retention-Policy": cortiRetentionPolicy, + "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName, + }), requestOptions?.headers, ); const _response = await core.fetcher({ @@ -193,7 +199,7 @@ export class DocumentsClient { contentType: "application/json", queryParameters: requestOptions?.queryParams, requestType: "json", - body: serializers.DocumentsCreateRequest.jsonOrThrow(request, { + body: serializers.DocumentsCreateRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip", omitUndefined: true, }), @@ -592,7 +598,7 @@ export class DocumentsClient { * Context can combine different types or reference an interactionId to automatically fetch existing context to pass to the LLM. Note that discarded facts are not passed to the LLM. * With the exception of the plain `templateRef` path (no overrides), every call creates a new auto-generated template aggregate that snapshots the resolved prompts as a drift-proof receipt, persisted for 30 days. * - * @param {Corti.GuidedDocumentsGenerateRequest} request + * @param {Corti.GenerateDocumentsRequest} request * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Corti.BadRequestError} @@ -602,28 +608,34 @@ export class DocumentsClient { * * @example * await client.documents.generate({ - * outputLanguage: "outputLanguage", - * templateRef: { - * templateId: "templateId" + * body: { + * outputLanguage: "outputLanguage", + * templateRef: { + * templateId: "templateId" + * } * } * }) */ public generate( - request: Corti.GuidedDocumentsGenerateRequest, + request: Corti.GenerateDocumentsRequest, requestOptions?: DocumentsClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__generate(request, requestOptions)); } private async __generate( - request: Corti.GuidedDocumentsGenerateRequest, + request: Corti.GenerateDocumentsRequest, requestOptions?: DocumentsClient.RequestOptions, ): Promise> { + const { cortiRetentionPolicy, body: _body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + mergeOnlyDefinedHeaders({ + "X-Corti-Retention-Policy": cortiRetentionPolicy, + "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName, + }), requestOptions?.headers, ); const _response = await core.fetcher({ @@ -637,7 +649,7 @@ export class DocumentsClient { contentType: "application/json", queryParameters: requestOptions?.queryParams, requestType: "json", - body: serializers.GuidedDocumentsGenerateRequest.jsonOrThrow(request, { + body: serializers.GuidedDocumentsGenerateRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip", omitUndefined: true, }), diff --git a/src/api/resources/documents/client/requests/CreateDocumentsRequest.ts b/src/api/resources/documents/client/requests/CreateDocumentsRequest.ts new file mode 100644 index 00000000..617419df --- /dev/null +++ b/src/api/resources/documents/client/requests/CreateDocumentsRequest.ts @@ -0,0 +1,24 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../index.js"; + +/** + * @example + * { + * body: { + * context: [{ + * type: "facts", + * data: [{ + * text: "text" + * }] + * }], + * templateKey: "templateKey", + * outputLanguage: "outputLanguage" + * } + * } + */ +export interface CreateDocumentsRequest { + /** With the optional header `X-Corti-Retention-Policy:none` the API will generate and return the document as expected, but the generated document will not be saved to the database. The response will include the header `X-Corti-Retention-Policy:acknowledged` to confirm that your retention preference was respected. If the header is omitted or set to any other value, the default retention policy will apply, and the document will be stored in the database. */ + cortiRetentionPolicy?: Corti.CreateDocumentsRequestXCortiRetentionPolicy; + body: Corti.DocumentsCreateRequest; +} diff --git a/src/api/resources/documents/client/requests/GenerateDocumentsRequest.ts b/src/api/resources/documents/client/requests/GenerateDocumentsRequest.ts new file mode 100644 index 00000000..eedcad3e --- /dev/null +++ b/src/api/resources/documents/client/requests/GenerateDocumentsRequest.ts @@ -0,0 +1,20 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../index.js"; + +/** + * @example + * { + * body: { + * outputLanguage: "outputLanguage", + * templateRef: { + * templateId: "templateId" + * } + * } + * } + */ +export interface GenerateDocumentsRequest { + /** Pass the optional `X-Corti-Retention-Policy: none` header to generate and return the document without saving it to the database. The response will be 200 with `GuidedDocumentsCreateEphemeralResponse`. Without the header the document is saved and the response is 201 with `GuidedDocumentsCreateResponse`. */ + cortiRetentionPolicy?: Corti.GenerateDocumentsRequestXCortiRetentionPolicy; + body: Corti.GuidedDocumentsGenerateRequest; +} diff --git a/src/api/resources/documents/client/requests/index.ts b/src/api/resources/documents/client/requests/index.ts index d86bd2d7..84e7f011 100644 --- a/src/api/resources/documents/client/requests/index.ts +++ b/src/api/resources/documents/client/requests/index.ts @@ -1 +1,3 @@ +export type { CreateDocumentsRequest } from "./CreateDocumentsRequest.js"; export type { DocumentsUpdateRequest } from "./DocumentsUpdateRequest.js"; +export type { GenerateDocumentsRequest } from "./GenerateDocumentsRequest.js"; diff --git a/src/api/resources/documents/index.ts b/src/api/resources/documents/index.ts index 9eb1192d..0ef16e76 100644 --- a/src/api/resources/documents/index.ts +++ b/src/api/resources/documents/index.ts @@ -1,2 +1,3 @@ export * from "./client/index.js"; export * from "./resources/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/documents/resources/sections/client/Client.ts b/src/api/resources/documents/resources/sections/client/Client.ts index c1d6d6f3..8454ef68 100644 --- a/src/api/resources/documents/resources/sections/client/Client.ts +++ b/src/api/resources/documents/resources/sections/client/Client.ts @@ -325,16 +325,7 @@ export class SectionsClient { case 404: throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); case 409: - throw new Corti.ConflictError( - serializers.ErrorResponse.parseOrThrow(_response.error.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - _response.rawResponse, - ); + throw new Corti.ConflictError(_response.error.body, _response.rawResponse); default: throw new errors.CortiError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/documents/resources/templates/client/Client.ts b/src/api/resources/documents/resources/templates/client/Client.ts index 43fecf7f..1dbead5a 100644 --- a/src/api/resources/documents/resources/templates/client/Client.ts +++ b/src/api/resources/documents/resources/templates/client/Client.ts @@ -325,16 +325,7 @@ export class TemplatesClient { case 404: throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); case 409: - throw new Corti.ConflictError( - serializers.ErrorResponse.parseOrThrow(_response.error.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - _response.rawResponse, - ); + throw new Corti.ConflictError(_response.error.body, _response.rawResponse); default: throw new errors.CortiError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/documents/types/CreateDocumentsRequestXCortiRetentionPolicy.ts b/src/api/resources/documents/types/CreateDocumentsRequestXCortiRetentionPolicy.ts new file mode 100644 index 00000000..80d0814b --- /dev/null +++ b/src/api/resources/documents/types/CreateDocumentsRequestXCortiRetentionPolicy.ts @@ -0,0 +1,7 @@ +// This file was auto-generated by Fern from our API Definition. + +export const CreateDocumentsRequestXCortiRetentionPolicy = { + None: "none", +} as const; +export type CreateDocumentsRequestXCortiRetentionPolicy = + (typeof CreateDocumentsRequestXCortiRetentionPolicy)[keyof typeof CreateDocumentsRequestXCortiRetentionPolicy]; diff --git a/src/api/resources/documents/types/GenerateDocumentsRequestXCortiRetentionPolicy.ts b/src/api/resources/documents/types/GenerateDocumentsRequestXCortiRetentionPolicy.ts new file mode 100644 index 00000000..d74cbfe4 --- /dev/null +++ b/src/api/resources/documents/types/GenerateDocumentsRequestXCortiRetentionPolicy.ts @@ -0,0 +1,7 @@ +// This file was auto-generated by Fern from our API Definition. + +export const GenerateDocumentsRequestXCortiRetentionPolicy = { + None: "none", +} as const; +export type GenerateDocumentsRequestXCortiRetentionPolicy = + (typeof GenerateDocumentsRequestXCortiRetentionPolicy)[keyof typeof GenerateDocumentsRequestXCortiRetentionPolicy]; diff --git a/src/api/resources/documents/types/index.ts b/src/api/resources/documents/types/index.ts new file mode 100644 index 00000000..f7abb7fb --- /dev/null +++ b/src/api/resources/documents/types/index.ts @@ -0,0 +1,2 @@ +export * from "./CreateDocumentsRequestXCortiRetentionPolicy.js"; +export * from "./GenerateDocumentsRequestXCortiRetentionPolicy.js"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 2e1d98c8..208f2a23 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -7,6 +7,7 @@ export * from "./codes/client/requests/index.js"; export * as codes from "./codes/index.js"; export * from "./documents/client/requests/index.js"; export * as documents from "./documents/index.js"; +export * from "./documents/types/index.js"; export * from "./facts/client/requests/index.js"; export * as facts from "./facts/index.js"; export * from "./interactions/client/requests/index.js"; diff --git a/src/custom/CortiClient.ts b/src/custom/CortiClient.ts index 67b80128..3474f68a 100644 --- a/src/custom/CortiClient.ts +++ b/src/custom/CortiClient.ts @@ -87,6 +87,7 @@ export class CortiClient extends BaseCortiClient { })); } + /** @deprecated Migrate to the Agentic API v2. See https://docs.corti.ai/agentic/guides/migrate-v1-to-v2 */ public override get agents(): CustomAgents { return (this._agents ??= new CustomAgents(this._options)); } diff --git a/src/custom/agents/CustomAgents.ts b/src/custom/agents/CustomAgents.ts index 825fe058..8a1b9d34 100644 --- a/src/custom/agents/CustomAgents.ts +++ b/src/custom/agents/CustomAgents.ts @@ -3,12 +3,13 @@ * * It extends the auto-generated Agents class and adds custom helper methods. * - * All the patches marked with `// Patch: ...` comments. + * @deprecated Migrate to the Agentic API v2. See https://docs.corti.ai/agentic/guides/migrate-v1-to-v2 */ import { AgentsClient } from "../../api/resources/agents/client/Client.js"; import * as core from "../../core/index.js"; +/** @deprecated Migrate to the Agentic API v2. See https://docs.corti.ai/agentic/guides/migrate-v1-to-v2 */ export class CustomAgents extends AgentsClient { /** * Returns the URL for the agent card JSON file. @@ -16,8 +17,10 @@ export class CustomAgents extends AgentsClient { * @param {string} agentId - The ID of the agent * @returns {Promise} A Promise that resolves to the URL for the agent card * + * @deprecated Migrate to the Agentic API v2. See https://docs.corti.ai/agentic/guides/migrate-v1-to-v2 + * * @example - * const url = await client.agents.getAgentCardUrl("agent-123"); + * const url = await client.agents.getCardUrl("agent-123"); */ public getCardUrl = async (agentId: string): Promise => { const encodedAgentId = encodeURIComponent(agentId); diff --git a/src/serialization/resources/agents/client/requests/AgentsMessageSendParams.ts b/src/serialization/resources/agents/client/requests/AgentsMessageSendBody.ts similarity index 81% rename from src/serialization/resources/agents/client/requests/AgentsMessageSendParams.ts rename to src/serialization/resources/agents/client/requests/AgentsMessageSendBody.ts index 24247fb7..0fc3860b 100644 --- a/src/serialization/resources/agents/client/requests/AgentsMessageSendParams.ts +++ b/src/serialization/resources/agents/client/requests/AgentsMessageSendBody.ts @@ -6,16 +6,16 @@ import type * as serializers from "../../../../index.js"; import { AgentsMessage } from "../../../../types/AgentsMessage.js"; import { AgentsMessageSendConfiguration } from "../../../../types/AgentsMessageSendConfiguration.js"; -export const AgentsMessageSendParams: core.serialization.Schema< - serializers.AgentsMessageSendParams.Raw, - Corti.AgentsMessageSendParams +export const AgentsMessageSendBody: core.serialization.Schema< + serializers.AgentsMessageSendBody.Raw, + Corti.AgentsMessageSendBody > = core.serialization.object({ message: AgentsMessage, configuration: AgentsMessageSendConfiguration.optional(), metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), }); -export declare namespace AgentsMessageSendParams { +export declare namespace AgentsMessageSendBody { export interface Raw { message: AgentsMessage.Raw; configuration?: AgentsMessageSendConfiguration.Raw | null; diff --git a/src/serialization/resources/agents/client/requests/index.ts b/src/serialization/resources/agents/client/requests/index.ts index 36d03a60..2ec1ca0a 100644 --- a/src/serialization/resources/agents/client/requests/index.ts +++ b/src/serialization/resources/agents/client/requests/index.ts @@ -1,3 +1,3 @@ export { AgentsCreateAgent } from "./AgentsCreateAgent.js"; -export { AgentsMessageSendParams } from "./AgentsMessageSendParams.js"; +export { AgentsMessageSendBody } from "./AgentsMessageSendBody.js"; export { AgentsUpdateAgent } from "./AgentsUpdateAgent.js"; diff --git a/src/serialization/resources/auth/types/AuthTokenRequestBody.ts b/src/serialization/resources/auth/types/AuthTokenRequest.ts similarity index 70% rename from src/serialization/resources/auth/types/AuthTokenRequestBody.ts rename to src/serialization/resources/auth/types/AuthTokenRequest.ts index cd65369e..9bb52270 100644 --- a/src/serialization/resources/auth/types/AuthTokenRequestBody.ts +++ b/src/serialization/resources/auth/types/AuthTokenRequest.ts @@ -9,18 +9,16 @@ import { AuthTokenRequestClientCredentials } from "../../../types/AuthTokenReque import { AuthTokenRequestRefresh } from "../../../types/AuthTokenRequestRefresh.js"; import { AuthTokenRequestRopc } from "../../../types/AuthTokenRequestRopc.js"; -export const AuthTokenRequestBody: core.serialization.Schema< - serializers.AuthTokenRequestBody.Raw, - Corti.AuthTokenRequestBody -> = core.serialization.undiscriminatedUnion([ - AuthTokenRequestClientCredentials, - AuthTokenRequestAuthorizationCode, - AuthTokenRequestAuthorizationPkce, - AuthTokenRequestRopc, - AuthTokenRequestRefresh, -]); +export const AuthTokenRequest: core.serialization.Schema = + core.serialization.undiscriminatedUnion([ + AuthTokenRequestClientCredentials, + AuthTokenRequestAuthorizationCode, + AuthTokenRequestAuthorizationPkce, + AuthTokenRequestRopc, + AuthTokenRequestRefresh, + ]); -export declare namespace AuthTokenRequestBody { +export declare namespace AuthTokenRequest { export type Raw = | AuthTokenRequestClientCredentials.Raw | AuthTokenRequestAuthorizationCode.Raw diff --git a/src/serialization/resources/auth/types/index.ts b/src/serialization/resources/auth/types/index.ts index 536709bd..c07e19c2 100644 --- a/src/serialization/resources/auth/types/index.ts +++ b/src/serialization/resources/auth/types/index.ts @@ -1 +1 @@ -export * from "./AuthTokenRequestBody.js"; +export * from "./AuthTokenRequest.js"; diff --git a/src/serialization/resources/documents/index.ts b/src/serialization/resources/documents/index.ts index 9eb1192d..0ef16e76 100644 --- a/src/serialization/resources/documents/index.ts +++ b/src/serialization/resources/documents/index.ts @@ -1,2 +1,3 @@ export * from "./client/index.js"; export * from "./resources/index.js"; +export * from "./types/index.js"; diff --git a/src/serialization/resources/documents/types/CreateDocumentsRequestXCortiRetentionPolicy.ts b/src/serialization/resources/documents/types/CreateDocumentsRequestXCortiRetentionPolicy.ts new file mode 100644 index 00000000..dbcc804a --- /dev/null +++ b/src/serialization/resources/documents/types/CreateDocumentsRequestXCortiRetentionPolicy.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../api/index.js"; +import * as core from "../../../../core/index.js"; +import type * as serializers from "../../../index.js"; + +export const CreateDocumentsRequestXCortiRetentionPolicy: core.serialization.Schema< + serializers.CreateDocumentsRequestXCortiRetentionPolicy.Raw, + Corti.CreateDocumentsRequestXCortiRetentionPolicy +> = core.serialization.enum_(["none"]); + +export declare namespace CreateDocumentsRequestXCortiRetentionPolicy { + export type Raw = "none"; +} diff --git a/src/serialization/resources/documents/types/GenerateDocumentsRequestXCortiRetentionPolicy.ts b/src/serialization/resources/documents/types/GenerateDocumentsRequestXCortiRetentionPolicy.ts new file mode 100644 index 00000000..8dd3fd0f --- /dev/null +++ b/src/serialization/resources/documents/types/GenerateDocumentsRequestXCortiRetentionPolicy.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../api/index.js"; +import * as core from "../../../../core/index.js"; +import type * as serializers from "../../../index.js"; + +export const GenerateDocumentsRequestXCortiRetentionPolicy: core.serialization.Schema< + serializers.GenerateDocumentsRequestXCortiRetentionPolicy.Raw, + Corti.GenerateDocumentsRequestXCortiRetentionPolicy +> = core.serialization.enum_(["none"]); + +export declare namespace GenerateDocumentsRequestXCortiRetentionPolicy { + export type Raw = "none"; +} diff --git a/src/serialization/resources/documents/types/index.ts b/src/serialization/resources/documents/types/index.ts new file mode 100644 index 00000000..f7abb7fb --- /dev/null +++ b/src/serialization/resources/documents/types/index.ts @@ -0,0 +1,2 @@ +export * from "./CreateDocumentsRequestXCortiRetentionPolicy.js"; +export * from "./GenerateDocumentsRequestXCortiRetentionPolicy.js"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts index c2b155f9..30b99be7 100644 --- a/src/serialization/resources/index.ts +++ b/src/serialization/resources/index.ts @@ -7,6 +7,7 @@ export * from "./codes/client/requests/index.js"; export * as codes from "./codes/index.js"; export * from "./documents/client/requests/index.js"; export * as documents from "./documents/index.js"; +export * from "./documents/types/index.js"; export * from "./facts/client/requests/index.js"; export * as facts from "./facts/index.js"; export * from "./interactions/client/requests/index.js"; diff --git a/tests/wire/documents.test.ts b/tests/wire/documents.test.ts index 1f3e4b3e..e2be10d7 100644 --- a/tests/wire/documents.test.ts +++ b/tests/wire/documents.test.ts @@ -235,18 +235,20 @@ describe("DocumentsClient", () => { .build(); const response = await client.documents.create("f47ac10b-58cc-4372-a567-0e02b2c3d479", { - context: [ - { - type: "facts", - data: [ - { - text: "text", - }, - ], - }, - ], - templateKey: "templateKey", - outputLanguage: "outputLanguage", + body: { + context: [ + { + type: "facts", + data: [ + { + text: "text", + }, + ], + }, + ], + templateKey: "templateKey", + outputLanguage: "outputLanguage", + }, }); expect(response).toEqual({ id: "f47ac10b-58cc-4372-a567-0e02b2c3d479", @@ -304,32 +306,34 @@ describe("DocumentsClient", () => { await expect(async () => { return await client.documents.create("id", { - context: [ - { - type: "facts", - data: [ - { - text: "text", - }, - { - text: "text", - }, - ], - }, - { - type: "facts", - data: [ - { - text: "text", - }, - { - text: "text", - }, - ], - }, - ], - templateKey: "templateKey", - outputLanguage: "outputLanguage", + body: { + context: [ + { + type: "facts", + data: [ + { + text: "text", + }, + { + text: "text", + }, + ], + }, + { + type: "facts", + data: [ + { + text: "text", + }, + { + text: "text", + }, + ], + }, + ], + templateKey: "templateKey", + outputLanguage: "outputLanguage", + }, }); }).rejects.toThrow(Corti.BadRequestError); }); @@ -366,32 +370,34 @@ describe("DocumentsClient", () => { await expect(async () => { return await client.documents.create("id", { - context: [ - { - type: "facts", - data: [ - { - text: "text", - }, - { - text: "text", - }, - ], - }, - { - type: "facts", - data: [ - { - text: "text", - }, - { - text: "text", - }, - ], - }, - ], - templateKey: "templateKey", - outputLanguage: "outputLanguage", + body: { + context: [ + { + type: "facts", + data: [ + { + text: "text", + }, + { + text: "text", + }, + ], + }, + { + type: "facts", + data: [ + { + text: "text", + }, + { + text: "text", + }, + ], + }, + ], + templateKey: "templateKey", + outputLanguage: "outputLanguage", + }, }); }).rejects.toThrow(Corti.ForbiddenError); }); @@ -428,32 +434,34 @@ describe("DocumentsClient", () => { await expect(async () => { return await client.documents.create("id", { - context: [ - { - type: "facts", - data: [ - { - text: "text", - }, - { - text: "text", - }, - ], - }, - { - type: "facts", - data: [ - { - text: "text", - }, - { - text: "text", - }, - ], - }, - ], - templateKey: "templateKey", - outputLanguage: "outputLanguage", + body: { + context: [ + { + type: "facts", + data: [ + { + text: "text", + }, + { + text: "text", + }, + ], + }, + { + type: "facts", + data: [ + { + text: "text", + }, + { + text: "text", + }, + ], + }, + ], + templateKey: "templateKey", + outputLanguage: "outputLanguage", + }, }); }).rejects.toThrow(Corti.InternalServerError); }); @@ -490,32 +498,34 @@ describe("DocumentsClient", () => { await expect(async () => { return await client.documents.create("id", { - context: [ - { - type: "facts", - data: [ - { - text: "text", - }, - { - text: "text", - }, - ], - }, - { - type: "facts", - data: [ - { - text: "text", - }, - { - text: "text", - }, - ], - }, - ], - templateKey: "templateKey", - outputLanguage: "outputLanguage", + body: { + context: [ + { + type: "facts", + data: [ + { + text: "text", + }, + { + text: "text", + }, + ], + }, + { + type: "facts", + data: [ + { + text: "text", + }, + { + text: "text", + }, + ], + }, + ], + templateKey: "templateKey", + outputLanguage: "outputLanguage", + }, }); }).rejects.toThrow(Corti.GatewayTimeoutError); }); @@ -1049,9 +1059,11 @@ describe("DocumentsClient", () => { .build(); const response = await client.documents.generate({ - outputLanguage: "outputLanguage", - templateRef: { - templateId: "templateId", + body: { + outputLanguage: "outputLanguage", + templateRef: { + templateId: "templateId", + }, }, }); expect(response).toEqual({ @@ -1105,10 +1117,12 @@ describe("DocumentsClient", () => { await expect(async () => { return await client.documents.generate({ - templateRef: { - templateId: "templateId", + body: { + templateRef: { + templateId: "templateId", + }, + outputLanguage: "outputLanguage", }, - outputLanguage: "outputLanguage", }); }).rejects.toThrow(Corti.BadRequestError); }); @@ -1138,10 +1152,12 @@ describe("DocumentsClient", () => { await expect(async () => { return await client.documents.generate({ - templateRef: { - templateId: "templateId", + body: { + templateRef: { + templateId: "templateId", + }, + outputLanguage: "outputLanguage", }, - outputLanguage: "outputLanguage", }); }).rejects.toThrow(Corti.NotFoundError); }); @@ -1171,10 +1187,12 @@ describe("DocumentsClient", () => { await expect(async () => { return await client.documents.generate({ - templateRef: { - templateId: "templateId", + body: { + templateRef: { + templateId: "templateId", + }, + outputLanguage: "outputLanguage", }, - outputLanguage: "outputLanguage", }); }).rejects.toThrow(Corti.UnprocessableEntityError); }); @@ -1204,10 +1222,12 @@ describe("DocumentsClient", () => { await expect(async () => { return await client.documents.generate({ - templateRef: { - templateId: "templateId", + body: { + templateRef: { + templateId: "templateId", + }, + outputLanguage: "outputLanguage", }, - outputLanguage: "outputLanguage", }); }).rejects.toThrow(Corti.InternalServerError); }); diff --git a/tests/wire/documents/sections.test.ts b/tests/wire/documents/sections.test.ts index 687da8aa..fd570ae6 100644 --- a/tests/wire/documents/sections.test.ts +++ b/tests/wire/documents/sections.test.ts @@ -360,7 +360,7 @@ describe("SectionsClient", () => { environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, }); - const rawResponseBody = { requestid: "requestid", status: 1, type: "type", detail: "detail" }; + const rawResponseBody = { key: "value" }; server .mockEndpoint() diff --git a/tests/wire/documents/templates.test.ts b/tests/wire/documents/templates.test.ts index 80291580..499cb608 100644 --- a/tests/wire/documents/templates.test.ts +++ b/tests/wire/documents/templates.test.ts @@ -450,7 +450,7 @@ describe("TemplatesClient", () => { environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, }); - const rawResponseBody = { requestid: "requestid", status: 1, type: "type", detail: "detail" }; + const rawResponseBody = { key: "value" }; server .mockEndpoint()