Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cliVersion": "4.86.1",
"cliVersion": "5.35.2",
"generatorName": "fernapi/fern-typescript-node-sdk",
"generatorVersion": "3.54.0",
"generatorConfig": {
Expand All @@ -15,7 +15,9 @@
},
"packageJson": {
"scripts": {
"test:integration": "vitest --config vitest.integration.config.mts"
"test:integration": "pnpm test:integration:main && pnpm test:integration:empty-state",
"test:integration:main": "vitest run --config vitest.integration.config.mts --project integration",
"test:integration:empty-state": "vitest run --config vitest.integration.config.mts --project integration-empty-state"
},
"exports": {
"./utils": {
Expand All @@ -32,6 +34,6 @@
}
}
},
"originGitCommit": "23bce53307f0836f2dcd50e82ef0aba136e7ec2f",
"originGitCommit": "e2c066722308d4c0d7bbf864b8961eef50548709",
"sdkVersion": "0.0.0-dev"
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CodesClient } from "./api/resources/codes/client/Client.js";
import { DocumentsClient } from "./api/resources/documents/client/Client.js";
import { FactsClient } from "./api/resources/facts/client/Client.js";
import { InteractionsClient } from "./api/resources/interactions/client/Client.js";
import { LanguagesClient } from "./api/resources/languages/client/Client.js";
import { RecordingsClient } from "./api/resources/recordings/client/Client.js";
import { StreamClient } from "./api/resources/stream/client/Client.js";
import { TemplatesClient } from "./api/resources/templates/client/Client.js";
Expand All @@ -30,6 +31,7 @@ export class CortiClient {
protected _documents: DocumentsClient | undefined;
protected _templates: TemplatesClient | undefined;
protected _codes: CodesClient | undefined;
protected _languages: LanguagesClient | undefined;
protected _agents: AgentsClient | undefined;
protected _stream: StreamClient | undefined;
protected _transcribe: TranscribeClient | undefined;
Expand Down Expand Up @@ -70,6 +72,10 @@ export class CortiClient {
return (this._codes ??= new CodesClient(this._options));
}

public get languages(): LanguagesClient {
return (this._languages ??= new LanguagesClient(this._options));
}

public get agents(): AgentsClient {
return (this._agents ??= new AgentsClient(this._options));
}
Expand Down
22 changes: 22 additions & 0 deletions src/api/errors/ConflictError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file was auto-generated by Fern from our API Definition.

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) {
super({
message: "ConflictError",
statusCode: 409,
body: body,
rawResponse: rawResponse,
});
Object.setPrototypeOf(this, new.target.prototype);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}

this.name = this.constructor.name;
}
}
3 changes: 1 addition & 2 deletions src/api/errors/UnprocessableEntityError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 UnprocessableEntityError extends errors.CortiError {
constructor(body: Corti.AgentsValidationErrorResponse, rawResponse?: core.RawResponse) {
constructor(body?: unknown, rawResponse?: core.RawResponse) {
super({
message: "UnprocessableEntityError",
statusCode: 422,
Expand Down
1 change: 1 addition & 0 deletions src/api/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./BadGatewayError.js";
export * from "./BadRequestError.js";
export * from "./ConflictError.js";
export * from "./ForbiddenError.js";
export * from "./GatewayTimeoutError.js";
export * from "./InternalServerError.js";
Expand Down
122 changes: 82 additions & 40 deletions src/api/resources/agents/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,7 @@ export class AgentsClient {
case 401:
throw new Corti.UnauthorizedError(_response.error.body, _response.rawResponse);
case 422:
throw new Corti.UnprocessableEntityError(
serializers.AgentsValidationErrorResponse.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
}),
_response.rawResponse,
);
throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse);
default:
throw new errors.CortiError({
statusCode: _response.error.statusCode,
Expand Down Expand Up @@ -429,16 +420,7 @@ export class AgentsClient {
case 404:
throw new Corti.NotFoundError(_response.error.body, _response.rawResponse);
case 422:
throw new Corti.UnprocessableEntityError(
serializers.AgentsValidationErrorResponse.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
}),
_response.rawResponse,
);
throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse);
default:
throw new errors.CortiError({
statusCode: _response.error.statusCode,
Expand Down Expand Up @@ -621,16 +603,7 @@ export class AgentsClient {
case 404:
throw new Corti.NotFoundError(_response.error.body, _response.rawResponse);
case 422:
throw new Corti.UnprocessableEntityError(
serializers.AgentsValidationErrorResponse.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
}),
_response.rawResponse,
);
throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse);
default:
throw new errors.CortiError({
statusCode: _response.error.statusCode,
Expand Down Expand Up @@ -835,6 +808,84 @@ export class AgentsClient {
);
}

/**
* 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.
* @param {string} contextId - The identifier of the context (thread) to delete.
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Corti.BadRequestError}
* @throws {@link Corti.UnauthorizedError}
* @throws {@link Corti.NotFoundError}
*
* @example
* await client.agents.deleteContext("12345678-90ab-cdef-gh12-34567890abc", "contextId")
*/
public deleteContext(
id: string,
contextId: string,
requestOptions?: AgentsClient.RequestOptions,
): core.HttpResponsePromise<void> {
return core.HttpResponsePromise.fromPromise(this.__deleteContext(id, contextId, requestOptions));
}

private async __deleteContext(
id: string,
contextId: string,
requestOptions?: AgentsClient.RequestOptions,
): Promise<core.WithRawResponse<void>> {
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 }),
requestOptions?.headers,
);
const _response = await core.fetcher({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)).agents,
`agents/${core.url.encodePathParam(id)}/v1/contexts/${core.url.encodePathParam(contextId)}`,
),
method: "DELETE",
headers: _headers,
queryParameters: requestOptions?.queryParams,
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetchFn: this._options?.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return { data: undefined, rawResponse: _response.rawResponse };
}

if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Corti.BadRequestError(_response.error.body, _response.rawResponse);
case 401:
throw new Corti.UnauthorizedError(_response.error.body, _response.rawResponse);
case 404:
throw new Corti.NotFoundError(_response.error.body, _response.rawResponse);
default:
throw new errors.CortiError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
}

return handleNonStatusCodeError(
_response.error,
_response.rawResponse,
"DELETE",
"/agents/{id}/v1/contexts/{contextId}",
);
}

/**
* This endpoint retrieves the experts registry, which contains information about all available experts that can be referenced when creating agents through the AgentsCreateExpertReference schema.
*
Expand Down Expand Up @@ -909,16 +960,7 @@ export class AgentsClient {
case 401:
throw new Corti.UnauthorizedError(_response.error.body, _response.rawResponse);
case 422:
throw new Corti.UnprocessableEntityError(
serializers.AgentsValidationErrorResponse.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
}),
_response.rawResponse,
);
throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse);
default:
throw new errors.CortiError({
statusCode: _response.error.statusCode,
Expand Down
Loading
Loading