@nouter/platform 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +23 -0
- package/README.md +183 -2
- package/dist/agents.d.ts +331 -0
- package/dist/agents.js +1 -0
- package/dist/deployments.d.ts +35 -0
- package/dist/deployments.js +1 -0
- package/dist/environments.d.ts +30 -0
- package/dist/environments.js +1 -0
- package/dist/evals.d.ts +419 -0
- package/dist/evals.js +186 -0
- package/dist/generated/openapi.d.ts +33673 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +90 -0
- package/dist/oma.d.ts +126 -0
- package/dist/oma.js +80 -0
- package/dist/platform/api-keys.d.ts +54 -0
- package/dist/platform/api-keys.js +62 -0
- package/dist/platform/audit-events.d.ts +22 -0
- package/dist/platform/audit-events.js +29 -0
- package/dist/platform/errors.d.ts +30 -0
- package/dist/platform/errors.js +66 -0
- package/dist/platform/http.d.ts +27 -0
- package/dist/platform/http.js +57 -0
- package/dist/platform/me.d.ts +15 -0
- package/dist/platform/me.js +10 -0
- package/dist/platform/model-cards.d.ts +34 -0
- package/dist/platform/model-cards.js +40 -0
- package/dist/platform/privacy-erasure.d.ts +37 -0
- package/dist/platform/privacy-erasure.js +40 -0
- package/dist/platform/rate-limits.d.ts +16 -0
- package/dist/platform/rate-limits.js +14 -0
- package/dist/platform/settings.d.ts +17 -0
- package/dist/platform/settings.js +17 -0
- package/dist/platform/types.d.ts +6 -0
- package/dist/platform/types.js +1 -0
- package/dist/platform/usage-limits.d.ts +34 -0
- package/dist/platform/usage-limits.js +38 -0
- package/dist/platform/usage.d.ts +30 -0
- package/dist/platform/usage.js +34 -0
- package/dist/platform/user-profiles.d.ts +35 -0
- package/dist/platform/user-profiles.js +46 -0
- package/dist/trigger-events.d.ts +36 -0
- package/dist/trigger-events.js +1 -0
- package/package.json +63 -4
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { APIError } from "@anthropic-ai/sdk";
|
|
2
|
+
import { PlatformApiError } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* La política de reintentos de las rutas de platform: un `POST` no se reintenta salvo que el llamador pida
|
|
5
|
+
* `maxRetries`. Las rutas de `client.platform` y las extensiones de `/v1/oma` (evals, modelos, `platform.request`) no
|
|
6
|
+
* montan el middleware de `Idempotency-Key`: el servidor solo lo honra en `POST /v1/sessions`, en el `run` de
|
|
7
|
+
* deployments y en el append de eventos (`POST /v1/sessions/{id}/events`, que lo hace la aplicación, atado a la sesión
|
|
8
|
+
* y sin vencimiento), que van por `client.beta` y conservan los reintentos oficiales del cliente. Un POST de platform
|
|
9
|
+
* reintentado tras un 5xx o un corte puede crear dos claves, rotar dos veces o duplicar un pedido de borrado.
|
|
10
|
+
*/
|
|
11
|
+
export function withRetryPolicy(method, options) {
|
|
12
|
+
if (method !== "post" || options.maxRetries != null)
|
|
13
|
+
return options;
|
|
14
|
+
return { ...options, maxRetries: 0 };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Una llamada por el transporte oficial que traduce un `APIError` a `PlatformApiError`. Los recursos de platform la
|
|
18
|
+
* usan para que el error sea uno solo, lea el sobre que lea.
|
|
19
|
+
*/
|
|
20
|
+
export async function platformRequest(client, method, path, options = {}) {
|
|
21
|
+
try {
|
|
22
|
+
return await client.request({ ...withRetryPolicy(method, options), method, path });
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error instanceof APIError)
|
|
26
|
+
throw PlatformApiError.fromAPIError(error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Suma headers a los que pase el llamador, sin perder el `Headers` ni las tuplas del cliente oficial. */
|
|
31
|
+
export function withHeaders(options, additions) {
|
|
32
|
+
const headers = new Headers();
|
|
33
|
+
const given = options?.headers;
|
|
34
|
+
if (given instanceof Headers) {
|
|
35
|
+
given.forEach((value, name) => headers.set(name, value));
|
|
36
|
+
}
|
|
37
|
+
else if (Array.isArray(given)) {
|
|
38
|
+
for (const [name, value] of given) {
|
|
39
|
+
if (value !== null && value !== undefined)
|
|
40
|
+
headers.set(String(name), String(value));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (given !== undefined && given !== null) {
|
|
44
|
+
for (const [name, value] of Object.entries(given)) {
|
|
45
|
+
if (value === null || value === undefined)
|
|
46
|
+
continue;
|
|
47
|
+
headers.set(name, Array.isArray(value) ? value.join(",") : String(value));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const [name, value] of Object.entries(additions))
|
|
51
|
+
headers.set(name, value);
|
|
52
|
+
return { ...options, headers };
|
|
53
|
+
}
|
|
54
|
+
/** Suma el `anthropic-beta` de la ruta a los headers que pase el llamador. */
|
|
55
|
+
export function withBeta(beta, options) {
|
|
56
|
+
return withHeaders(options, { "anthropic-beta": beta });
|
|
57
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import type { JsonContent } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* `GET /v1/oma/me` con D-5: el rol en la organización del pedido y los alcances efectivos, expandidos. La familia de
|
|
7
|
+
* error es `text` (`{ error, error_code?, request_id }`).
|
|
8
|
+
*/
|
|
9
|
+
export type PlatformMe = JsonContent<operations["getV1OmaMe"]["responses"][200]>;
|
|
10
|
+
export declare class MeResource {
|
|
11
|
+
private readonly client;
|
|
12
|
+
constructor(client: Anthropic);
|
|
13
|
+
get(options?: RequestOptions): Promise<PlatformMe>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import type { JsonContent } from "./types.js";
|
|
5
|
+
export type PlatformModelCardListResponse = JsonContent<operations["getV1OmaModelCards"]["responses"][200]>;
|
|
6
|
+
export type PlatformModelCard = PlatformModelCardListResponse["data"][number];
|
|
7
|
+
/** El alta devuelve la card y, además, el resultado de la sonda (`probe`). */
|
|
8
|
+
export type PlatformModelCardCreateResponse = JsonContent<operations["postV1OmaModelCards"]["responses"][201]>;
|
|
9
|
+
export type PlatformModelCardCreateParams = JsonContent<NonNullable<operations["postV1OmaModelCards"]["requestBody"]>>;
|
|
10
|
+
export type PlatformModelCardUpdateParams = JsonContent<NonNullable<operations["postV1OmaModelCardsId"]["requestBody"]>>;
|
|
11
|
+
export type PlatformModelCardDeleted = JsonContent<operations["deleteV1OmaModelCardsId"]["responses"][200]>;
|
|
12
|
+
export interface PlatformModelCardListParams {
|
|
13
|
+
limit?: number;
|
|
14
|
+
cursor?: string;
|
|
15
|
+
page?: string;
|
|
16
|
+
q?: string;
|
|
17
|
+
provider?: string;
|
|
18
|
+
created_after?: string;
|
|
19
|
+
created_before?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `/v1/oma/model_cards`: el enrutamiento por proveedor, la credencial cifrada y los metadatos Pi. La familia de error
|
|
23
|
+
* es `text` (el sobre `{ error, request_id }`).
|
|
24
|
+
*/
|
|
25
|
+
export declare class PlatformModelCardsResource {
|
|
26
|
+
private readonly client;
|
|
27
|
+
constructor(client: Anthropic);
|
|
28
|
+
create(params: PlatformModelCardCreateParams, options?: RequestOptions): Promise<PlatformModelCardCreateResponse>;
|
|
29
|
+
list(params?: PlatformModelCardListParams, options?: RequestOptions): Promise<PlatformModelCardListResponse>;
|
|
30
|
+
retrieve(id: string, options?: RequestOptions): Promise<PlatformModelCard>;
|
|
31
|
+
update(id: string, params: PlatformModelCardUpdateParams, options?: RequestOptions): Promise<PlatformModelCard>;
|
|
32
|
+
delete(id: string, options?: RequestOptions): Promise<PlatformModelCardDeleted>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { platformRequest } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* `/v1/oma/model_cards`: el enrutamiento por proveedor, la credencial cifrada y los metadatos Pi. La familia de error
|
|
4
|
+
* es `text` (el sobre `{ error, request_id }`).
|
|
5
|
+
*/
|
|
6
|
+
export class PlatformModelCardsResource {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
create(params, options) {
|
|
12
|
+
return platformRequest(this.client, "post", "/v1/oma/model_cards", {
|
|
13
|
+
...options,
|
|
14
|
+
body: params,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
list(params = {}, options) {
|
|
18
|
+
return platformRequest(this.client, "get", "/v1/oma/model_cards", {
|
|
19
|
+
...options,
|
|
20
|
+
query: {
|
|
21
|
+
...(params.limit !== undefined && { limit: params.limit }),
|
|
22
|
+
...(params.cursor !== undefined && { cursor: params.cursor }),
|
|
23
|
+
...(params.page !== undefined && { page: params.page }),
|
|
24
|
+
...(params.q !== undefined && { q: params.q }),
|
|
25
|
+
...(params.provider !== undefined && { provider: params.provider }),
|
|
26
|
+
...(params.created_after !== undefined && { created_after: params.created_after }),
|
|
27
|
+
...(params.created_before !== undefined && { created_before: params.created_before }),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
retrieve(id, options) {
|
|
32
|
+
return platformRequest(this.client, "get", `/v1/oma/model_cards/${encodeURIComponent(id)}`, options);
|
|
33
|
+
}
|
|
34
|
+
update(id, params, options) {
|
|
35
|
+
return platformRequest(this.client, "post", `/v1/oma/model_cards/${encodeURIComponent(id)}`, { ...options, body: params });
|
|
36
|
+
}
|
|
37
|
+
delete(id, options) {
|
|
38
|
+
return platformRequest(this.client, "delete", `/v1/oma/model_cards/${encodeURIComponent(id)}`, options);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import type { JsonContent } from "./types.js";
|
|
5
|
+
/** La beta que exige `/v1/privacy/erasure_requests` (`PRIVACY_ERASURE_BETA` en `managed-agents-api/src/beta.ts`). */
|
|
6
|
+
export declare const PRIVACY_ERASURE_BETA = "privacy-erasure-2026-11-19";
|
|
7
|
+
export type PlatformErasureRequestCreateParams = JsonContent<NonNullable<operations["postV1PrivacyErasureRequests"]["requestBody"]>>;
|
|
8
|
+
export type PlatformErasureRequest = JsonContent<operations["postV1PrivacyErasureRequests"]["responses"][202]>;
|
|
9
|
+
type ErasureListResponse = JsonContent<operations["getV1PrivacyErasureRequests"]["responses"][200]>;
|
|
10
|
+
/** Sin `request_id`, la ruta devuelve la página. */
|
|
11
|
+
export type PlatformErasureRequestPage = Extract<ErasureListResponse, {
|
|
12
|
+
data: PlatformErasureRequest[];
|
|
13
|
+
}>;
|
|
14
|
+
/** Con `?request_id=`, devuelve un objeto suelto (el `oneOf` del OpenAPI). */
|
|
15
|
+
export type PlatformErasureRequestSingle = Exclude<ErasureListResponse, {
|
|
16
|
+
data: PlatformErasureRequest[];
|
|
17
|
+
}>;
|
|
18
|
+
export interface PlatformErasureRequestListParams {
|
|
19
|
+
limit?: number;
|
|
20
|
+
page?: string;
|
|
21
|
+
order?: "asc" | "desc";
|
|
22
|
+
status?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `/v1/privacy/erasure_requests`: el pedido de borrado por persona y sus lecturas. Todas piden
|
|
26
|
+
* `anthropic-beta: privacy-erasure-2026-11-19` y usan el sobre de `ApiError`.
|
|
27
|
+
*/
|
|
28
|
+
export declare class PrivacyErasureResource {
|
|
29
|
+
private readonly client;
|
|
30
|
+
constructor(client: Anthropic);
|
|
31
|
+
create(params: PlatformErasureRequestCreateParams, options?: RequestOptions): Promise<PlatformErasureRequest>;
|
|
32
|
+
list(params?: PlatformErasureRequestListParams, options?: RequestOptions): Promise<PlatformErasureRequestPage>;
|
|
33
|
+
/** La consulta por la clave del pedido (`?request_id=`): devuelve el pedido, no la página. */
|
|
34
|
+
retrieveByRequestId(requestId: string, options?: RequestOptions): Promise<PlatformErasureRequestSingle>;
|
|
35
|
+
retrieve(erasureRequestId: string, options?: RequestOptions): Promise<PlatformErasureRequest>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { platformRequest, withBeta } from "./http.js";
|
|
2
|
+
/** La beta que exige `/v1/privacy/erasure_requests` (`PRIVACY_ERASURE_BETA` en `managed-agents-api/src/beta.ts`). */
|
|
3
|
+
export const PRIVACY_ERASURE_BETA = "privacy-erasure-2026-11-19";
|
|
4
|
+
/**
|
|
5
|
+
* `/v1/privacy/erasure_requests`: el pedido de borrado por persona y sus lecturas. Todas piden
|
|
6
|
+
* `anthropic-beta: privacy-erasure-2026-11-19` y usan el sobre de `ApiError`.
|
|
7
|
+
*/
|
|
8
|
+
export class PrivacyErasureResource {
|
|
9
|
+
client;
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
create(params, options) {
|
|
14
|
+
return platformRequest(this.client, "post", "/v1/privacy/erasure_requests", {
|
|
15
|
+
...withBeta(PRIVACY_ERASURE_BETA, options),
|
|
16
|
+
body: params,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
list(params = {}, options) {
|
|
20
|
+
return platformRequest(this.client, "get", "/v1/privacy/erasure_requests", {
|
|
21
|
+
...withBeta(PRIVACY_ERASURE_BETA, options),
|
|
22
|
+
query: {
|
|
23
|
+
...(params.limit !== undefined && { limit: params.limit }),
|
|
24
|
+
...(params.page !== undefined && { page: params.page }),
|
|
25
|
+
...(params.order !== undefined && { order: params.order }),
|
|
26
|
+
...(params.status !== undefined && { status: params.status }),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** La consulta por la clave del pedido (`?request_id=`): devuelve el pedido, no la página. */
|
|
31
|
+
retrieveByRequestId(requestId, options) {
|
|
32
|
+
return platformRequest(this.client, "get", "/v1/privacy/erasure_requests", {
|
|
33
|
+
...withBeta(PRIVACY_ERASURE_BETA, options),
|
|
34
|
+
query: { request_id: requestId },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
retrieve(erasureRequestId, options) {
|
|
38
|
+
return platformRequest(this.client, "get", `/v1/privacy/erasure_requests/${encodeURIComponent(erasureRequestId)}`, withBeta(PRIVACY_ERASURE_BETA, options));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import type { JsonContent } from "./types.js";
|
|
5
|
+
export type PlatformRateLimits = JsonContent<operations["getV1OmaRateLimits"]["responses"][200]>;
|
|
6
|
+
export type PlatformRateLimitEntry = PlatformRateLimits["data"][number];
|
|
7
|
+
/**
|
|
8
|
+
* `GET /v1/oma/rate_limits`: las aperturas por minuto y por día del despliegue y, en solo lectura, una entrada por
|
|
9
|
+
* clave activa. La familia de error es `v1`.
|
|
10
|
+
*/
|
|
11
|
+
export declare class RateLimitsResource {
|
|
12
|
+
private readonly client;
|
|
13
|
+
constructor(client: Anthropic);
|
|
14
|
+
list(options?: RequestOptions): Promise<PlatformRateLimits>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { platformRequest } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* `GET /v1/oma/rate_limits`: las aperturas por minuto y por día del despliegue y, en solo lectura, una entrada por
|
|
4
|
+
* clave activa. La familia de error es `v1`.
|
|
5
|
+
*/
|
|
6
|
+
export class RateLimitsResource {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
list(options) {
|
|
12
|
+
return platformRequest(this.client, "get", "/v1/oma/rate_limits", options);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import type { JsonContent } from "./types.js";
|
|
5
|
+
export type PlatformSettings = JsonContent<operations["getV1OmaSettings"]["responses"][200]>;
|
|
6
|
+
export type PlatformSettingsUpdate = JsonContent<NonNullable<operations["postV1OmaSettings"]["requestBody"]>>;
|
|
7
|
+
/**
|
|
8
|
+
* `GET`/`POST /v1/oma/settings`: los topes y la `policy` de la organización. El `GET` da `ETag` y el `POST` acepta
|
|
9
|
+
* `If-Match` (se pasa en `options.headers`). La familia de error es `v1`.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SettingsResource {
|
|
12
|
+
private readonly client;
|
|
13
|
+
constructor(client: Anthropic);
|
|
14
|
+
get(options?: RequestOptions): Promise<PlatformSettings>;
|
|
15
|
+
set(params: PlatformSettingsUpdate, options?: RequestOptions): Promise<PlatformSettings>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { platformRequest } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* `GET`/`POST /v1/oma/settings`: los topes y la `policy` de la organización. El `GET` da `ETag` y el `POST` acepta
|
|
4
|
+
* `If-Match` (se pasa en `options.headers`). La familia de error es `v1`.
|
|
5
|
+
*/
|
|
6
|
+
export class SettingsResource {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
get(options) {
|
|
12
|
+
return platformRequest(this.client, "get", "/v1/oma/settings", options);
|
|
13
|
+
}
|
|
14
|
+
set(params, options) {
|
|
15
|
+
return platformRequest(this.client, "post", "/v1/oma/settings", { ...options, body: params });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import type { JsonContent } from "./types.js";
|
|
5
|
+
type ConsumptionQuery = NonNullable<NonNullable<operations["getV1OmaUsageLimitsConsumption"]["parameters"]>["query"]>;
|
|
6
|
+
/** Un nivel de consumo; la ruta acepta más de uno, pero el transporte serializa los arrays con corchetes (`kind[]`). */
|
|
7
|
+
export type PlatformConsumptionKind = Exclude<NonNullable<ConsumptionQuery["kind"]>, readonly unknown[]>;
|
|
8
|
+
export type PlatformUsageLimits = JsonContent<operations["getV1OmaUsageLimits"]["responses"][200]>;
|
|
9
|
+
export type PlatformUsageLimitsUpdate = JsonContent<NonNullable<operations["postV1OmaUsageLimits"]["requestBody"]>>;
|
|
10
|
+
export type PlatformUsageConsumption = JsonContent<operations["getV1OmaUsageLimitsConsumption"]["responses"][200]>;
|
|
11
|
+
export interface PlatformUsageLimitsParams {
|
|
12
|
+
/** Sin `agent_id`, los topes de la organización. */
|
|
13
|
+
agent_id?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PlatformUsageConsumptionParams {
|
|
16
|
+
day?: string;
|
|
17
|
+
kind?: PlatformConsumptionKind;
|
|
18
|
+
agent_id?: string;
|
|
19
|
+
user_profile_id?: string;
|
|
20
|
+
limit?: number;
|
|
21
|
+
page?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `GET`/`POST /v1/oma/usage_limits` (los topes de la organización o de un agente) y la lectura del consumo con sus
|
|
25
|
+
* páginas. La familia de error es `v1`.
|
|
26
|
+
*/
|
|
27
|
+
export declare class UsageLimitsResource {
|
|
28
|
+
private readonly client;
|
|
29
|
+
constructor(client: Anthropic);
|
|
30
|
+
get(params?: PlatformUsageLimitsParams, options?: RequestOptions): Promise<PlatformUsageLimits>;
|
|
31
|
+
set(params: PlatformUsageLimitsUpdate, options?: RequestOptions): Promise<PlatformUsageLimits>;
|
|
32
|
+
consumption(params?: PlatformUsageConsumptionParams, options?: RequestOptions): Promise<PlatformUsageConsumption>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { platformRequest } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* `GET`/`POST /v1/oma/usage_limits` (los topes de la organización o de un agente) y la lectura del consumo con sus
|
|
4
|
+
* páginas. La familia de error es `v1`.
|
|
5
|
+
*/
|
|
6
|
+
export class UsageLimitsResource {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
get(params = {}, options) {
|
|
12
|
+
return platformRequest(this.client, "get", "/v1/oma/usage_limits", {
|
|
13
|
+
...options,
|
|
14
|
+
query: { ...(params.agent_id !== undefined && { agent_id: params.agent_id }) },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
set(params, options) {
|
|
18
|
+
return platformRequest(this.client, "post", "/v1/oma/usage_limits", {
|
|
19
|
+
...options,
|
|
20
|
+
body: params,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
consumption(params = {}, options) {
|
|
24
|
+
return platformRequest(this.client, "get", "/v1/oma/usage_limits/consumption", {
|
|
25
|
+
...options,
|
|
26
|
+
query: {
|
|
27
|
+
...(params.day !== undefined && { day: params.day }),
|
|
28
|
+
...(params.kind !== undefined && { kind: params.kind }),
|
|
29
|
+
...(params.agent_id !== undefined && { agent_id: params.agent_id }),
|
|
30
|
+
...(params.user_profile_id !== undefined && {
|
|
31
|
+
user_profile_id: params.user_profile_id,
|
|
32
|
+
}),
|
|
33
|
+
...(params.limit !== undefined && { limit: params.limit }),
|
|
34
|
+
...(params.page !== undefined && { page: params.page }),
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import type { JsonContent } from "./types.js";
|
|
5
|
+
type UsageQuery = NonNullable<NonNullable<operations["getV1OmaUsage"]["parameters"]>["query"]>;
|
|
6
|
+
export type PlatformUsageGroupBy = NonNullable<UsageQuery["group_by"]>[number];
|
|
7
|
+
export type PlatformUsage = JsonContent<operations["getV1OmaUsage"]["responses"][200]>;
|
|
8
|
+
export interface PlatformUsageParams {
|
|
9
|
+
days?: "7" | "30" | "90";
|
|
10
|
+
starting_at?: string;
|
|
11
|
+
ending_at?: string;
|
|
12
|
+
/** Se manda como `group_by[]`, la forma que acepta la ruta. */
|
|
13
|
+
group_by?: PlatformUsageGroupBy[];
|
|
14
|
+
/** Se manda como `api_key_ids[]`, la forma que acepta la ruta; el transporte repite la clave por id. */
|
|
15
|
+
api_key_ids?: string[];
|
|
16
|
+
user_profile_id?: string;
|
|
17
|
+
limit?: number;
|
|
18
|
+
page?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* `GET /v1/oma/usage` y su exportación CSV. La familia de error es `v1` (el sobre de `ApiError`).
|
|
22
|
+
*/
|
|
23
|
+
export declare class UsageResource {
|
|
24
|
+
private readonly client;
|
|
25
|
+
constructor(client: Anthropic);
|
|
26
|
+
private query;
|
|
27
|
+
list(params?: PlatformUsageParams, options?: RequestOptions): Promise<PlatformUsage>;
|
|
28
|
+
export(params?: PlatformUsageParams, options?: RequestOptions): Promise<string>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { platformRequest, withHeaders } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* `GET /v1/oma/usage` y su exportación CSV. La familia de error es `v1` (el sobre de `ApiError`).
|
|
4
|
+
*/
|
|
5
|
+
export class UsageResource {
|
|
6
|
+
client;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
query(params) {
|
|
11
|
+
return {
|
|
12
|
+
...(params.days !== undefined && { days: params.days }),
|
|
13
|
+
...(params.starting_at !== undefined && { starting_at: params.starting_at }),
|
|
14
|
+
...(params.ending_at !== undefined && { ending_at: params.ending_at }),
|
|
15
|
+
...(params.group_by !== undefined && { group_by: params.group_by }),
|
|
16
|
+
...(params.api_key_ids !== undefined && { api_key_ids: params.api_key_ids }),
|
|
17
|
+
...(params.user_profile_id !== undefined && { user_profile_id: params.user_profile_id }),
|
|
18
|
+
...(params.limit !== undefined && { limit: params.limit }),
|
|
19
|
+
...(params.page !== undefined && { page: params.page }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
list(params = {}, options) {
|
|
23
|
+
return platformRequest(this.client, "get", "/v1/oma/usage", {
|
|
24
|
+
...options,
|
|
25
|
+
query: this.query(params),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export(params = {}, options) {
|
|
29
|
+
return platformRequest(this.client, "get", "/v1/oma/usage/export", {
|
|
30
|
+
...withHeaders(options, { accept: "text/csv" }),
|
|
31
|
+
query: { ...this.query(params), format: "csv" },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import type { PlatformErasureRequest } from "./privacy-erasure.js";
|
|
5
|
+
import type { JsonContent } from "./types.js";
|
|
6
|
+
/** La beta que exige `/v1/user_profiles` (`USER_PROFILES_BETA` en `managed-agents-api/src/beta.ts`). */
|
|
7
|
+
export declare const USER_PROFILES_BETA = "user-profiles-2026-08-18";
|
|
8
|
+
export type PlatformUserProfileRequest = JsonContent<NonNullable<operations["postV1UserProfiles"]["requestBody"]>>;
|
|
9
|
+
export type PlatformUserProfileUpdateRequest = JsonContent<NonNullable<operations["postV1UserProfilesUserProfileId"]["requestBody"]>>;
|
|
10
|
+
export type PlatformUserProfile = JsonContent<operations["postV1UserProfiles"]["responses"][200]>;
|
|
11
|
+
export type PlatformUserProfilePage = JsonContent<operations["getV1UserProfiles"]["responses"][200]>;
|
|
12
|
+
export interface PlatformUserProfileListParams {
|
|
13
|
+
limit?: number;
|
|
14
|
+
page?: string;
|
|
15
|
+
order?: "asc" | "desc";
|
|
16
|
+
external_id?: string;
|
|
17
|
+
/** La lista excluye los archivados por defecto; `true` los incluye. */
|
|
18
|
+
include_archived?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* `/v1/user_profiles`: el upsert por `external_id`, la lista, el detalle, la actualización, el archivo y el borrado por
|
|
22
|
+
* persona de 2b. Todas las rutas piden `anthropic-beta: user-profiles-2026-08-18`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class UserProfilesResource {
|
|
25
|
+
private readonly client;
|
|
26
|
+
constructor(client: Anthropic);
|
|
27
|
+
upsert(params: PlatformUserProfileRequest, options?: RequestOptions): Promise<PlatformUserProfile>;
|
|
28
|
+
list(params?: PlatformUserProfileListParams, options?: RequestOptions): Promise<PlatformUserProfilePage>;
|
|
29
|
+
retrieve(userProfileId: string, options?: RequestOptions): Promise<PlatformUserProfile>;
|
|
30
|
+
update(userProfileId: string, params: PlatformUserProfileUpdateRequest, options?: RequestOptions): Promise<PlatformUserProfile>;
|
|
31
|
+
archive(userProfileId: string, options?: RequestOptions): Promise<PlatformUserProfile>;
|
|
32
|
+
/** El borrado por persona de 2b: encola la erasure y responde 202 con el pedido. */
|
|
33
|
+
delete(userProfileId: string, options?: RequestOptions): Promise<PlatformErasureRequest>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { platformRequest, withBeta } from "./http.js";
|
|
2
|
+
/** La beta que exige `/v1/user_profiles` (`USER_PROFILES_BETA` en `managed-agents-api/src/beta.ts`). */
|
|
3
|
+
export const USER_PROFILES_BETA = "user-profiles-2026-08-18";
|
|
4
|
+
/**
|
|
5
|
+
* `/v1/user_profiles`: el upsert por `external_id`, la lista, el detalle, la actualización, el archivo y el borrado por
|
|
6
|
+
* persona de 2b. Todas las rutas piden `anthropic-beta: user-profiles-2026-08-18`.
|
|
7
|
+
*/
|
|
8
|
+
export class UserProfilesResource {
|
|
9
|
+
client;
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
upsert(params, options) {
|
|
14
|
+
return platformRequest(this.client, "post", "/v1/user_profiles", {
|
|
15
|
+
...withBeta(USER_PROFILES_BETA, options),
|
|
16
|
+
body: params,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
list(params = {}, options) {
|
|
20
|
+
return platformRequest(this.client, "get", "/v1/user_profiles", {
|
|
21
|
+
...withBeta(USER_PROFILES_BETA, options),
|
|
22
|
+
query: {
|
|
23
|
+
...(params.limit !== undefined && { limit: params.limit }),
|
|
24
|
+
...(params.page !== undefined && { page: params.page }),
|
|
25
|
+
...(params.order !== undefined && { order: params.order }),
|
|
26
|
+
...(params.external_id !== undefined && { external_id: params.external_id }),
|
|
27
|
+
...(params.include_archived !== undefined && {
|
|
28
|
+
include_archived: params.include_archived ? "true" : "false",
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
retrieve(userProfileId, options) {
|
|
34
|
+
return platformRequest(this.client, "get", `/v1/user_profiles/${encodeURIComponent(userProfileId)}`, withBeta(USER_PROFILES_BETA, options));
|
|
35
|
+
}
|
|
36
|
+
update(userProfileId, params, options) {
|
|
37
|
+
return platformRequest(this.client, "post", `/v1/user_profiles/${encodeURIComponent(userProfileId)}`, { ...withBeta(USER_PROFILES_BETA, options), body: params });
|
|
38
|
+
}
|
|
39
|
+
archive(userProfileId, options) {
|
|
40
|
+
return platformRequest(this.client, "post", `/v1/user_profiles/${encodeURIComponent(userProfileId)}/archive`, withBeta(USER_PROFILES_BETA, options));
|
|
41
|
+
}
|
|
42
|
+
/** El borrado por persona de 2b: encola la erasure y responde 202 con el pedido. */
|
|
43
|
+
delete(userProfileId, options) {
|
|
44
|
+
return platformRequest(this.client, "delete", `/v1/user_profiles/${encodeURIComponent(userProfileId)}`, withBeta(USER_PROFILES_BETA, options));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PlatformDeploymentRunInitialEventParams } from "./deployments.js";
|
|
2
|
+
export type PlatformTriggerEventStatus = "pending" | "dispatching" | "dispatched" | "failed";
|
|
3
|
+
/**
|
|
4
|
+
* El cuerpo de `POST /v1/trigger_events`. `idempotency_key` va en el cuerpo (1 a 255 ASCII visibles); `source` es
|
|
5
|
+
* texto libre de hasta 64 caracteres que platform solo guarda. `user_profile_id` exige `sessions:write` además de
|
|
6
|
+
* `triggers:write`. `session_id`, si viene, tiene que ser del mismo deployment.
|
|
7
|
+
*/
|
|
8
|
+
export interface PlatformTriggerEventCreateParams {
|
|
9
|
+
deployment_id: string;
|
|
10
|
+
idempotency_key: string;
|
|
11
|
+
source: string;
|
|
12
|
+
initial_events?: Array<PlatformDeploymentRunInitialEventParams>;
|
|
13
|
+
metadata?: Record<string, string>;
|
|
14
|
+
user_profile_id?: string;
|
|
15
|
+
session_id?: string;
|
|
16
|
+
}
|
|
17
|
+
/** El error del drenaje: `type` es el código estable, `message` el texto para humanos. */
|
|
18
|
+
export interface PlatformTriggerEventError {
|
|
19
|
+
type: string;
|
|
20
|
+
message: string;
|
|
21
|
+
}
|
|
22
|
+
/** Lo que devuelve el `GET /v1/trigger_events/:id`: el estado, los intentos y el resultado del drenaje. */
|
|
23
|
+
export interface PlatformTriggerEvent {
|
|
24
|
+
type: "trigger_event";
|
|
25
|
+
id: string;
|
|
26
|
+
status: PlatformTriggerEventStatus;
|
|
27
|
+
deployment_id: string;
|
|
28
|
+
created_at: string;
|
|
29
|
+
updated_at: string;
|
|
30
|
+
attempts: number;
|
|
31
|
+
deployment_run_id: string | null;
|
|
32
|
+
session_id: string | null;
|
|
33
|
+
error: PlatformTriggerEventError | null;
|
|
34
|
+
}
|
|
35
|
+
/** La respuesta del alta: 202 con uno nuevo o 200 con el existente (su `status` puede ser otro). */
|
|
36
|
+
export type PlatformTriggerEventCreateResponse = Pick<PlatformTriggerEvent, "type" | "id" | "status" | "deployment_id" | "created_at">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|