@nouter/platform 0.3.0 → 0.5.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/README.md +17 -0
- package/dist/agents.d.ts +19 -0
- package/dist/evals.d.ts +16 -0
- package/dist/evals.js +36 -38
- package/dist/generated/openapi.d.ts +6091 -2842
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/oma.d.ts +9 -0
- package/dist/oma.js +12 -0
- package/dist/platform/api-keys.js +5 -1
- package/dist/platform/federation.d.ts +120 -0
- package/dist/platform/federation.js +100 -0
- package/dist/platform/http.d.ts +21 -1
- package/dist/platform/http.js +43 -5
- package/dist/platform/service-accounts.d.ts +61 -0
- package/dist/platform/service-accounts.js +47 -0
- package/dist/platform/sessions.d.ts +33 -0
- package/dist/platform/sessions.js +59 -0
- package/dist/platform/usage-limits.d.ts +23 -0
- package/dist/platform/usage-limits.js +19 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export { PrivacyErasureResource, PRIVACY_ERASURE_BETA, type PlatformErasureReque
|
|
|
10
10
|
export { ApiKeysResource, KEY_PRESETS, type PlatformApiKey, type PlatformApiKeyCreateParams, type PlatformApiKeyCreateResponse, type PlatformApiKeyDeleted, type PlatformApiKeyRotateParams, type PlatformApiKeyRotateResponse, type PlatformApiKeyScope, type PlatformApiKeysPage, type PlatformApiKeyUpdateParams, type PlatformApiKeyUpdateResponse, } from "./platform/api-keys.js";
|
|
11
11
|
export { AuditEventsResource, type PlatformAuditEvent, type PlatformAuditEventsPage, type PlatformAuditEventsParams, } from "./platform/audit-events.js";
|
|
12
12
|
export { MeResource, type PlatformMe } from "./platform/me.js";
|
|
13
|
+
export { ServiceAccountsResource, type PlatformServiceAccount, type PlatformServiceAccountCreateParams, type PlatformServiceAccountCreateResponse, type PlatformServiceAccountResponse, type PlatformServiceAccountsListParams, type PlatformServiceAccountsPage, } from "./platform/service-accounts.js";
|
|
14
|
+
export { FederationResource, FederationIssuersResource, FederationRulesResource, type PlatformFederationIssuer, type PlatformFederationIssuerCreateParams, type PlatformFederationIssuerCreateResponse, type PlatformFederationIssuerResponse, type PlatformFederationIssuersListParams, type PlatformFederationIssuersPage, type PlatformFederationRule, type PlatformFederationRuleCreateParams, type PlatformFederationRuleCreateResponse, type PlatformFederationRuleResponse, type PlatformFederationRulesListParams, type PlatformFederationRulesPage, } from "./platform/federation.js";
|
|
15
|
+
export { SessionsResource, SessionOutputsResource, type PlatformSessionOutput, type PlatformSessionOutputsPage, } from "./platform/sessions.js";
|
|
13
16
|
import type { PlatformBeta } from "./agents.js";
|
|
14
17
|
export type { PlatformAgentAcp, PlatformAgentAcpParams, PlatformAgentExtension, PlatformAgentExtensionParams, PlatformAgentModelParams, PlatformAgent, PlatformAgentCreateParams, PlatformAgentUpdateParams, PlatformAgentMultiagentParams, PlatformAgentMultiagent, PlatformMultiagent, PlatformSessionThreadAgent, PlatformSessionAgent, PlatformSession, PlatformSessionCreateParams, PlatformAgents, PlatformSessions, PlatformBeta, PlatformAgentPolicy, PlatformAgentRetention, PlatformMcpToolClass, PlatformMcpToolClassEntry, PlatformMcpServer, PlatformMcpServerParams, PlatformStdioMcpServer, PlatformStdioMcpServerParams, PlatformAgentRuntimeBindingParams, PlatformJsonValue, PlatformProviderOptions, } from "./agents.js";
|
|
15
18
|
export type { PlatformEnvironment, PlatformEnvironmentCreateParams, PlatformEnvironmentUpdateParams, PlatformEnvironments, PlatformNoneEnvironmentConfig, } from "./environments.js";
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,9 @@ export { PrivacyErasureResource, PRIVACY_ERASURE_BETA, } from "./platform/privac
|
|
|
11
11
|
export { ApiKeysResource, KEY_PRESETS, } from "./platform/api-keys.js";
|
|
12
12
|
export { AuditEventsResource, } from "./platform/audit-events.js";
|
|
13
13
|
export { MeResource } from "./platform/me.js";
|
|
14
|
+
export { ServiceAccountsResource, } from "./platform/service-accounts.js";
|
|
15
|
+
export { FederationResource, FederationIssuersResource, FederationRulesResource, } from "./platform/federation.js";
|
|
16
|
+
export { SessionsResource, SessionOutputsResource, } from "./platform/sessions.js";
|
|
14
17
|
export { PlatformModelsResource, PlatformModelCardsResource, PlatformHarnessesResource, PlatformResources, } from "./oma.js";
|
|
15
18
|
export { EvalsResource, EvalBenchmarksResource, EvalCasesResource, EvalRunsResource, EVAL_RUN_TERMINAL_STATUSES, } from "./evals.js";
|
|
16
19
|
export { Anthropic };
|
package/dist/oma.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ import { PrivacyErasureResource } from "./platform/privacy-erasure.js";
|
|
|
10
10
|
import { ApiKeysResource } from "./platform/api-keys.js";
|
|
11
11
|
import { AuditEventsResource } from "./platform/audit-events.js";
|
|
12
12
|
import { MeResource } from "./platform/me.js";
|
|
13
|
+
import { ServiceAccountsResource } from "./platform/service-accounts.js";
|
|
14
|
+
import { FederationResource } from "./platform/federation.js";
|
|
15
|
+
import { SessionsResource } from "./platform/sessions.js";
|
|
13
16
|
export { PlatformModelCardsResource };
|
|
14
17
|
export type { PlatformModelCard, PlatformModelCardCreateParams, PlatformModelCardCreateResponse, PlatformModelCardDeleted, PlatformModelCardListParams, PlatformModelCardListResponse, PlatformModelCardUpdateParams, } from "./platform/model-cards.js";
|
|
15
18
|
/** Pi provider id. Built-ins and user-defined ids share this open shape. */
|
|
@@ -121,6 +124,12 @@ export declare class PlatformResources {
|
|
|
121
124
|
readonly apiKeys: ApiKeysResource;
|
|
122
125
|
readonly auditEvents: AuditEventsResource;
|
|
123
126
|
readonly me: MeResource;
|
|
127
|
+
/** Las cuentas de servicio de `/v1/oma/service_accounts`: listar, crear, leer y archivar. */
|
|
128
|
+
readonly serviceAccounts: ServiceAccountsResource;
|
|
129
|
+
/** La federación de `/v1/oma`: los emisores (`issuers`) y las reglas (`rules`), con las mismas cuatro operaciones. */
|
|
130
|
+
readonly federation: FederationResource;
|
|
131
|
+
/** Los outputs de una sesión; la ruta es `/v1/sessions/*`, no `/v1/oma/*`. */
|
|
132
|
+
readonly sessions: SessionsResource;
|
|
124
133
|
constructor(client: Anthropic);
|
|
125
134
|
request<Response>(params: PlatformRequestParams): import("@anthropic-ai/sdk").APIPromise<Response>;
|
|
126
135
|
}
|
package/dist/oma.js
CHANGED
|
@@ -9,6 +9,9 @@ import { PrivacyErasureResource } from "./platform/privacy-erasure.js";
|
|
|
9
9
|
import { ApiKeysResource } from "./platform/api-keys.js";
|
|
10
10
|
import { AuditEventsResource } from "./platform/audit-events.js";
|
|
11
11
|
import { MeResource } from "./platform/me.js";
|
|
12
|
+
import { ServiceAccountsResource } from "./platform/service-accounts.js";
|
|
13
|
+
import { FederationResource } from "./platform/federation.js";
|
|
14
|
+
import { SessionsResource } from "./platform/sessions.js";
|
|
12
15
|
import { withRetryPolicy } from "./platform/http.js";
|
|
13
16
|
export { PlatformModelCardsResource };
|
|
14
17
|
export class PlatformHarnessesResource {
|
|
@@ -50,6 +53,12 @@ export class PlatformResources {
|
|
|
50
53
|
apiKeys;
|
|
51
54
|
auditEvents;
|
|
52
55
|
me;
|
|
56
|
+
/** Las cuentas de servicio de `/v1/oma/service_accounts`: listar, crear, leer y archivar. */
|
|
57
|
+
serviceAccounts;
|
|
58
|
+
/** La federación de `/v1/oma`: los emisores (`issuers`) y las reglas (`rules`), con las mismas cuatro operaciones. */
|
|
59
|
+
federation;
|
|
60
|
+
/** Los outputs de una sesión; la ruta es `/v1/sessions/*`, no `/v1/oma/*`. */
|
|
61
|
+
sessions;
|
|
53
62
|
constructor(client) {
|
|
54
63
|
this.client = client;
|
|
55
64
|
this.models = new PlatformModelsResource(client);
|
|
@@ -65,6 +74,9 @@ export class PlatformResources {
|
|
|
65
74
|
this.apiKeys = new ApiKeysResource(client);
|
|
66
75
|
this.auditEvents = new AuditEventsResource(client);
|
|
67
76
|
this.me = new MeResource(client);
|
|
77
|
+
this.serviceAccounts = new ServiceAccountsResource(client);
|
|
78
|
+
this.federation = new FederationResource(client);
|
|
79
|
+
this.sessions = new SessionsResource(client);
|
|
68
80
|
}
|
|
69
81
|
request(params) {
|
|
70
82
|
const { method, path, ...options } = params;
|
|
@@ -56,7 +56,11 @@ export class ApiKeysResource {
|
|
|
56
56
|
rotate(id, params = {}, options) {
|
|
57
57
|
return platformRequest(this.client, "post", `/v1/oma/api_keys/${encodeURIComponent(id)}/rotate`, {
|
|
58
58
|
...options,
|
|
59
|
-
body: {
|
|
59
|
+
body: {
|
|
60
|
+
grace_period_seconds: params.grace_period_seconds ?? 0,
|
|
61
|
+
// NOUTER PATCH (T8): un vencimiento explícito para la sucesora; sin él, hereda el de la vieja.
|
|
62
|
+
...(params.expires_at === undefined ? {} : { expires_at: params.expires_at }),
|
|
63
|
+
},
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import { type PlatformRequestOptions } from "./http.js";
|
|
5
|
+
import type { JsonContent } from "./types.js";
|
|
6
|
+
type FederationIssuersResponse = JsonContent<operations["getV1OmaFederationIssuers"]["responses"][200]>;
|
|
7
|
+
/** Una página de emisores de federación (`GET /v1/oma/federation_issuers`), con `has_more` y `next_page`. */
|
|
8
|
+
export type PlatformFederationIssuersPage = FederationIssuersResponse;
|
|
9
|
+
/** Un emisor de federación tal como lo devuelve el contrato: su proveedor, su emisor y sus claves. */
|
|
10
|
+
export type PlatformFederationIssuer = FederationIssuersResponse["data"][number];
|
|
11
|
+
type FederationIssuerCreateBody = JsonContent<operations["postV1OmaFederationIssuers"]["requestBody"]>;
|
|
12
|
+
/** El cuerpo de crear un emisor: el nombre, el proveedor y la URL del emisor; `jwks` es opcional. */
|
|
13
|
+
export type PlatformFederationIssuerCreateParams = FederationIssuerCreateBody;
|
|
14
|
+
/**
|
|
15
|
+
* El emisor que devuelven el detalle, el archivo y el alta (`GET /v1/oma/federation_issuers/{id}`): el tipo neutral
|
|
16
|
+
* del recurso, no el del alta en particular.
|
|
17
|
+
*/
|
|
18
|
+
export type PlatformFederationIssuerResponse = JsonContent<operations["getV1OmaFederationIssuersId"]["responses"][200]>;
|
|
19
|
+
/** El alta devuelve la misma forma; el alias nombra la respuesta de `create`. */
|
|
20
|
+
export type PlatformFederationIssuerCreateResponse = PlatformFederationIssuerResponse;
|
|
21
|
+
/** La query de `list` de emisores tal como la declara el contrato (`limit`, `page`, `include_archived`). */
|
|
22
|
+
type FederationIssuersListQuery = NonNullable<operations["getV1OmaFederationIssuers"]["parameters"]["query"]>;
|
|
23
|
+
/**
|
|
24
|
+
* Las opciones de `list` de emisores: las del cliente oficial más la query del contrato, con `include_archived` como
|
|
25
|
+
* booleano (el SDK lo manda al wire como `"true"`/`"false"`).
|
|
26
|
+
*/
|
|
27
|
+
export type PlatformFederationIssuersListParams = Omit<PlatformRequestOptions, "body" | "query"> & {
|
|
28
|
+
query?: Omit<FederationIssuersListQuery, "include_archived"> & {
|
|
29
|
+
include_archived?: boolean;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
type FederationRulesResponse = JsonContent<operations["getV1OmaFederationRules"]["responses"][200]>;
|
|
33
|
+
/** Una página de reglas de federación (`GET /v1/oma/federation_rules`), con `has_more` y `next_page`. */
|
|
34
|
+
export type PlatformFederationRulesPage = FederationRulesResponse;
|
|
35
|
+
/** Una regla de federación tal como la devuelve el contrato: su emisor, el match, el destino y sus alcances. */
|
|
36
|
+
export type PlatformFederationRule = FederationRulesResponse["data"][number];
|
|
37
|
+
type FederationRuleCreateBody = JsonContent<operations["postV1OmaFederationRules"]["requestBody"]>;
|
|
38
|
+
/** El cuerpo de crear una regla: el emisor, el match, el destino y los alcances que se emiten. */
|
|
39
|
+
export type PlatformFederationRuleCreateParams = FederationRuleCreateBody;
|
|
40
|
+
/**
|
|
41
|
+
* La regla que devuelven el detalle, el archivo y el alta (`GET /v1/oma/federation_rules/{id}`): el tipo neutral del
|
|
42
|
+
* recurso, no el del alta en particular.
|
|
43
|
+
*/
|
|
44
|
+
export type PlatformFederationRuleResponse = JsonContent<operations["getV1OmaFederationRulesId"]["responses"][200]>;
|
|
45
|
+
/** El alta devuelve la misma forma; el alias nombra la respuesta de `create`. */
|
|
46
|
+
export type PlatformFederationRuleCreateResponse = PlatformFederationRuleResponse;
|
|
47
|
+
/** La query de `list` de reglas tal como la declara el contrato: la página más `issuer_id`. */
|
|
48
|
+
type FederationRulesListQuery = NonNullable<operations["getV1OmaFederationRules"]["parameters"]["query"]>;
|
|
49
|
+
/**
|
|
50
|
+
* Las opciones de `list` de reglas: las del cliente oficial más la query del contrato (`issuer_id` y la página), con
|
|
51
|
+
* `include_archived` como booleano (el SDK lo manda al wire como `"true"`/`"false"`).
|
|
52
|
+
*/
|
|
53
|
+
export type PlatformFederationRulesListParams = Omit<PlatformRequestOptions, "body" | "query"> & {
|
|
54
|
+
query?: Omit<FederationRulesListQuery, "include_archived"> & {
|
|
55
|
+
include_archived?: boolean;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* `/v1/oma/federation_issuers`: las cuatro operaciones que la guía enseña — `list`, `create`, `retrieve` y `archive`.
|
|
60
|
+
* Los `POST` no se reintentan (`withRetryPolicy`) y los errores salen como `PlatformApiError`.
|
|
61
|
+
*/
|
|
62
|
+
export declare class FederationIssuersResource {
|
|
63
|
+
private readonly client;
|
|
64
|
+
constructor(client: Anthropic);
|
|
65
|
+
/**
|
|
66
|
+
* Lista los emisores (`GET /v1/oma/federation_issuers`). La query es la del contrato: `limit` (de 1 a 100), `page`
|
|
67
|
+
* (el `next_page` de la página anterior) e `include_archived` (booleano; al wire va como `"true"`/`"false"`).
|
|
68
|
+
*/
|
|
69
|
+
list(params?: PlatformFederationIssuersListParams): Promise<PlatformFederationIssuersPage>;
|
|
70
|
+
/**
|
|
71
|
+
* Crea un emisor (`POST /v1/oma/federation_issuers`). Pide la credencial de una persona: una clave de service
|
|
72
|
+
* account o un token federado reciben `403` con `errorCode: "admin_required"`. Los `400` traen el código en
|
|
73
|
+
* `errorCode`: `invalid_name`, `invalid_issuer_url`, `invalid_jwks`, `invalid_token_lifetime` y
|
|
74
|
+
* `federation_issuer_limit_reached`.
|
|
75
|
+
*/
|
|
76
|
+
create(params: PlatformFederationIssuerCreateParams, options?: RequestOptions): Promise<PlatformFederationIssuerCreateResponse>;
|
|
77
|
+
retrieve(id: string, options?: RequestOptions): Promise<PlatformFederationIssuerResponse>;
|
|
78
|
+
/**
|
|
79
|
+
* Archiva el emisor (`POST /v1/oma/federation_issuers/:id/archive`); la ruta no es un `DELETE`. Es idempotente. Un
|
|
80
|
+
* `400` con `errorCode: "resource_in_use"` avisa que hay reglas de federación que lo usan: hay que archivarlas
|
|
81
|
+
* primero. Un id inexistente o de otra organización es el `404` `federation_issuer_not_found`.
|
|
82
|
+
*/
|
|
83
|
+
archive(id: string, options?: RequestOptions): Promise<PlatformFederationIssuerResponse>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `/v1/oma/federation_rules`: las cuatro operaciones que la guía enseña — `list`, `create`, `retrieve` y `archive`.
|
|
87
|
+
* Los `POST` no se reintentan (`withRetryPolicy`) y los errores salen como `PlatformApiError`.
|
|
88
|
+
*/
|
|
89
|
+
export declare class FederationRulesResource {
|
|
90
|
+
private readonly client;
|
|
91
|
+
constructor(client: Anthropic);
|
|
92
|
+
/**
|
|
93
|
+
* Lista las reglas (`GET /v1/oma/federation_rules`). La query es la del contrato: `limit` (de 1 a 100), `page` (el
|
|
94
|
+
* `next_page` de la página anterior), `include_archived` (booleano; al wire va como `"true"`/`"false"`) e
|
|
95
|
+
* `issuer_id` para quedarse con las reglas de un emisor.
|
|
96
|
+
*/
|
|
97
|
+
list(params?: PlatformFederationRulesListParams): Promise<PlatformFederationRulesPage>;
|
|
98
|
+
/**
|
|
99
|
+
* Crea una regla (`POST /v1/oma/federation_rules`). Pide la credencial de una persona: una clave de service
|
|
100
|
+
* account o un token federado reciben `403` con `errorCode: "admin_required"`. Los `400` traen el código en
|
|
101
|
+
* `errorCode`: `invalid_name`, `invalid_match`, `invalid_scope`, `invalid_token_lifetime`,
|
|
102
|
+
* `federation_rule_limit_reached`, `federation_issuer_archived` y `service_account_archived`; un emisor, un
|
|
103
|
+
* workspace o una cuenta de destino que no son de la organización son `404` con su código.
|
|
104
|
+
*/
|
|
105
|
+
create(params: PlatformFederationRuleCreateParams, options?: RequestOptions): Promise<PlatformFederationRuleCreateResponse>;
|
|
106
|
+
retrieve(id: string, options?: RequestOptions): Promise<PlatformFederationRuleResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* Archiva la regla (`POST /v1/oma/federation_rules/:id/archive`); la ruta no es un `DELETE`. Es idempotente y
|
|
109
|
+
* libera el `resource_in_use` de su cuenta y de su emisor. Un id inexistente o de otra organización es el `404`
|
|
110
|
+
* `federation_rule_not_found`.
|
|
111
|
+
*/
|
|
112
|
+
archive(id: string, options?: RequestOptions): Promise<PlatformFederationRuleResponse>;
|
|
113
|
+
}
|
|
114
|
+
/** El namespace `federation` de `client.platform`: los emisores y las reglas. */
|
|
115
|
+
export declare class FederationResource {
|
|
116
|
+
readonly issuers: FederationIssuersResource;
|
|
117
|
+
readonly rules: FederationRulesResource;
|
|
118
|
+
constructor(client: Anthropic);
|
|
119
|
+
}
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { platformRequest, serializeListQuery } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* `/v1/oma/federation_issuers`: las cuatro operaciones que la guía enseña — `list`, `create`, `retrieve` y `archive`.
|
|
4
|
+
* Los `POST` no se reintentan (`withRetryPolicy`) y los errores salen como `PlatformApiError`.
|
|
5
|
+
*/
|
|
6
|
+
export class FederationIssuersResource {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Lista los emisores (`GET /v1/oma/federation_issuers`). La query es la del contrato: `limit` (de 1 a 100), `page`
|
|
13
|
+
* (el `next_page` de la página anterior) e `include_archived` (booleano; al wire va como `"true"`/`"false"`).
|
|
14
|
+
*/
|
|
15
|
+
list(params = {}) {
|
|
16
|
+
const { query, ...options } = params;
|
|
17
|
+
return platformRequest(this.client, "get", "/v1/oma/federation_issuers", {
|
|
18
|
+
...options,
|
|
19
|
+
query: serializeListQuery(query),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Crea un emisor (`POST /v1/oma/federation_issuers`). Pide la credencial de una persona: una clave de service
|
|
24
|
+
* account o un token federado reciben `403` con `errorCode: "admin_required"`. Los `400` traen el código en
|
|
25
|
+
* `errorCode`: `invalid_name`, `invalid_issuer_url`, `invalid_jwks`, `invalid_token_lifetime` y
|
|
26
|
+
* `federation_issuer_limit_reached`.
|
|
27
|
+
*/
|
|
28
|
+
create(params, options) {
|
|
29
|
+
return platformRequest(this.client, "post", "/v1/oma/federation_issuers", {
|
|
30
|
+
...options,
|
|
31
|
+
body: params,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
retrieve(id, options) {
|
|
35
|
+
return platformRequest(this.client, "get", `/v1/oma/federation_issuers/${encodeURIComponent(id)}`, options);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Archiva el emisor (`POST /v1/oma/federation_issuers/:id/archive`); la ruta no es un `DELETE`. Es idempotente. Un
|
|
39
|
+
* `400` con `errorCode: "resource_in_use"` avisa que hay reglas de federación que lo usan: hay que archivarlas
|
|
40
|
+
* primero. Un id inexistente o de otra organización es el `404` `federation_issuer_not_found`.
|
|
41
|
+
*/
|
|
42
|
+
archive(id, options) {
|
|
43
|
+
return platformRequest(this.client, "post", `/v1/oma/federation_issuers/${encodeURIComponent(id)}/archive`, options);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* `/v1/oma/federation_rules`: las cuatro operaciones que la guía enseña — `list`, `create`, `retrieve` y `archive`.
|
|
48
|
+
* Los `POST` no se reintentan (`withRetryPolicy`) y los errores salen como `PlatformApiError`.
|
|
49
|
+
*/
|
|
50
|
+
export class FederationRulesResource {
|
|
51
|
+
client;
|
|
52
|
+
constructor(client) {
|
|
53
|
+
this.client = client;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Lista las reglas (`GET /v1/oma/federation_rules`). La query es la del contrato: `limit` (de 1 a 100), `page` (el
|
|
57
|
+
* `next_page` de la página anterior), `include_archived` (booleano; al wire va como `"true"`/`"false"`) e
|
|
58
|
+
* `issuer_id` para quedarse con las reglas de un emisor.
|
|
59
|
+
*/
|
|
60
|
+
list(params = {}) {
|
|
61
|
+
const { query, ...options } = params;
|
|
62
|
+
return platformRequest(this.client, "get", "/v1/oma/federation_rules", {
|
|
63
|
+
...options,
|
|
64
|
+
query: serializeListQuery(query),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Crea una regla (`POST /v1/oma/federation_rules`). Pide la credencial de una persona: una clave de service
|
|
69
|
+
* account o un token federado reciben `403` con `errorCode: "admin_required"`. Los `400` traen el código en
|
|
70
|
+
* `errorCode`: `invalid_name`, `invalid_match`, `invalid_scope`, `invalid_token_lifetime`,
|
|
71
|
+
* `federation_rule_limit_reached`, `federation_issuer_archived` y `service_account_archived`; un emisor, un
|
|
72
|
+
* workspace o una cuenta de destino que no son de la organización son `404` con su código.
|
|
73
|
+
*/
|
|
74
|
+
create(params, options) {
|
|
75
|
+
return platformRequest(this.client, "post", "/v1/oma/federation_rules", {
|
|
76
|
+
...options,
|
|
77
|
+
body: params,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
retrieve(id, options) {
|
|
81
|
+
return platformRequest(this.client, "get", `/v1/oma/federation_rules/${encodeURIComponent(id)}`, options);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Archiva la regla (`POST /v1/oma/federation_rules/:id/archive`); la ruta no es un `DELETE`. Es idempotente y
|
|
85
|
+
* libera el `resource_in_use` de su cuenta y de su emisor. Un id inexistente o de otra organización es el `404`
|
|
86
|
+
* `federation_rule_not_found`.
|
|
87
|
+
*/
|
|
88
|
+
archive(id, options) {
|
|
89
|
+
return platformRequest(this.client, "post", `/v1/oma/federation_rules/${encodeURIComponent(id)}/archive`, options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** El namespace `federation` de `client.platform`: los emisores y las reglas. */
|
|
93
|
+
export class FederationResource {
|
|
94
|
+
issuers;
|
|
95
|
+
rules;
|
|
96
|
+
constructor(client) {
|
|
97
|
+
this.issuers = new FederationIssuersResource(client);
|
|
98
|
+
this.rules = new FederationRulesResource(client);
|
|
99
|
+
}
|
|
100
|
+
}
|
package/dist/platform/http.d.ts
CHANGED
|
@@ -6,6 +6,16 @@ export interface PlatformRequestOptions extends Omit<RequestOptions, "body" | "q
|
|
|
6
6
|
body?: unknown;
|
|
7
7
|
query?: object | null;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* La query de un `list` de platform tal como va al wire: el contrato declara `include_archived` como `"true"` |
|
|
11
|
+
* `"false"`, pero la superficie del SDK lo acepta booleano, así que acá se serializa. El resto de la query pasa tal
|
|
12
|
+
* cual; sin query, `undefined`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function serializeListQuery<Query extends {
|
|
15
|
+
include_archived?: boolean;
|
|
16
|
+
}>(query: Query | undefined): (Omit<Query, "include_archived"> & {
|
|
17
|
+
include_archived?: "true" | "false";
|
|
18
|
+
}) | undefined;
|
|
9
19
|
/**
|
|
10
20
|
* La política de reintentos de las rutas de platform: un `POST` no se reintenta salvo que el llamador pida
|
|
11
21
|
* `maxRetries`. Las rutas de `client.platform` y las extensiones de `/v1/oma` (evals, modelos, `platform.request`) no
|
|
@@ -20,8 +30,18 @@ export declare function withRetryPolicy<T extends RequestOptions>(method: Platfo
|
|
|
20
30
|
* usan para que el error sea uno solo, lea el sobre que lea.
|
|
21
31
|
*/
|
|
22
32
|
export declare function platformRequest<Response>(client: Anthropic, method: PlatformMethod, path: string, options?: PlatformRequestOptions): Promise<Response>;
|
|
33
|
+
/** El beta de la familia Managed Agents; la ruta de outputs lo exige en cada llamada. */
|
|
34
|
+
export declare const MANAGED_AGENTS_BETA = "managed-agents-2026-04-01";
|
|
23
35
|
/** Suma headers a los que pase el llamador, sin perder el `Headers` ni las tuplas del cliente oficial. */
|
|
24
36
|
export declare function withHeaders(options: RequestOptions | undefined, additions: Record<string, string>): RequestOptions;
|
|
25
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Suma el `anthropic-beta` de la ruta a los headers que pase el llamador **concatenando**: si el llamador ya trae
|
|
39
|
+
* `anthropic-beta`, agrega `beta` a la lista separada por comas cuando falta; si no la trae, la pone sola. El servidor
|
|
40
|
+
* lee la cabecera como un conjunto, así un beta del llamador convive con el de la ruta.
|
|
41
|
+
*
|
|
42
|
+
* **El límite del SDK base:** la concatenación solo cubre el `anthropic-beta` que venga en `options.headers`. Uno que
|
|
43
|
+
* venga en `defaultHeaders` del cliente lo pisa el de la petición, porque el cliente arma la cabecera con los headers
|
|
44
|
+
* de la llamada; para sumar un beta del cliente hay que pasarlo en `options.headers`.
|
|
45
|
+
*/
|
|
26
46
|
export declare function withBeta(beta: string, options?: RequestOptions): RequestOptions;
|
|
27
47
|
export {};
|
package/dist/platform/http.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { APIError } from "@anthropic-ai/sdk";
|
|
2
2
|
import { PlatformApiError } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* La query de un `list` de platform tal como va al wire: el contrato declara `include_archived` como `"true"` |
|
|
5
|
+
* `"false"`, pero la superficie del SDK lo acepta booleano, así que acá se serializa. El resto de la query pasa tal
|
|
6
|
+
* cual; sin query, `undefined`.
|
|
7
|
+
*/
|
|
8
|
+
export function serializeListQuery(query) {
|
|
9
|
+
if (query === undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
const { include_archived, ...rest } = query;
|
|
12
|
+
if (include_archived === undefined)
|
|
13
|
+
return rest;
|
|
14
|
+
return { ...rest, include_archived: include_archived ? "true" : "false" };
|
|
15
|
+
}
|
|
3
16
|
/**
|
|
4
17
|
* La política de reintentos de las rutas de platform: un `POST` no se reintenta salvo que el llamador pida
|
|
5
18
|
* `maxRetries`. Las rutas de `client.platform` y las extensiones de `/v1/oma` (evals, modelos, `platform.request`) no
|
|
@@ -27,10 +40,11 @@ export async function platformRequest(client, method, path, options = {}) {
|
|
|
27
40
|
throw error;
|
|
28
41
|
}
|
|
29
42
|
}
|
|
30
|
-
/**
|
|
31
|
-
export
|
|
43
|
+
/** El beta de la familia Managed Agents; la ruta de outputs lo exige en cada llamada. */
|
|
44
|
+
export const MANAGED_AGENTS_BETA = "managed-agents-2026-04-01";
|
|
45
|
+
/** Los headers del llamador en un `Headers`, sin perder el `Headers`, las tuplas ni el objeto. */
|
|
46
|
+
function mergedHeaders(given) {
|
|
32
47
|
const headers = new Headers();
|
|
33
|
-
const given = options?.headers;
|
|
34
48
|
if (given instanceof Headers) {
|
|
35
49
|
given.forEach((value, name) => headers.set(name, value));
|
|
36
50
|
}
|
|
@@ -47,11 +61,35 @@ export function withHeaders(options, additions) {
|
|
|
47
61
|
headers.set(name, Array.isArray(value) ? value.join(",") : String(value));
|
|
48
62
|
}
|
|
49
63
|
}
|
|
64
|
+
return headers;
|
|
65
|
+
}
|
|
66
|
+
/** Suma headers a los que pase el llamador, sin perder el `Headers` ni las tuplas del cliente oficial. */
|
|
67
|
+
export function withHeaders(options, additions) {
|
|
68
|
+
const headers = mergedHeaders(options?.headers);
|
|
50
69
|
for (const [name, value] of Object.entries(additions))
|
|
51
70
|
headers.set(name, value);
|
|
52
71
|
return { ...options, headers };
|
|
53
72
|
}
|
|
54
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Suma el `anthropic-beta` de la ruta a los headers que pase el llamador **concatenando**: si el llamador ya trae
|
|
75
|
+
* `anthropic-beta`, agrega `beta` a la lista separada por comas cuando falta; si no la trae, la pone sola. El servidor
|
|
76
|
+
* lee la cabecera como un conjunto, así un beta del llamador convive con el de la ruta.
|
|
77
|
+
*
|
|
78
|
+
* **El límite del SDK base:** la concatenación solo cubre el `anthropic-beta` que venga en `options.headers`. Uno que
|
|
79
|
+
* venga en `defaultHeaders` del cliente lo pisa el de la petición, porque el cliente arma la cabecera con los headers
|
|
80
|
+
* de la llamada; para sumar un beta del cliente hay que pasarlo en `options.headers`.
|
|
81
|
+
*/
|
|
55
82
|
export function withBeta(beta, options) {
|
|
56
|
-
|
|
83
|
+
const headers = mergedHeaders(options?.headers);
|
|
84
|
+
const given = headers.get("anthropic-beta");
|
|
85
|
+
const betas = given === null
|
|
86
|
+
? []
|
|
87
|
+
: given
|
|
88
|
+
.split(",")
|
|
89
|
+
.map((value) => value.trim())
|
|
90
|
+
.filter((value) => value.length > 0);
|
|
91
|
+
if (!betas.includes(beta))
|
|
92
|
+
betas.push(beta);
|
|
93
|
+
headers.set("anthropic-beta", betas.join(","));
|
|
94
|
+
return { ...options, headers };
|
|
57
95
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
type RequestOptions = Anthropic.RequestOptions;
|
|
3
|
+
import type { operations } from "../generated/openapi.js";
|
|
4
|
+
import { type PlatformRequestOptions } from "./http.js";
|
|
5
|
+
import type { JsonContent } from "./types.js";
|
|
6
|
+
type ServiceAccountsResponse = JsonContent<operations["getV1OmaServiceAccounts"]["responses"][200]>;
|
|
7
|
+
/** Una página de cuentas de servicio (`GET /v1/oma/service_accounts`), con `has_more` y `next_page`. */
|
|
8
|
+
export type PlatformServiceAccountsPage = ServiceAccountsResponse;
|
|
9
|
+
/** Una cuenta de servicio tal como la devuelve el contrato: su rol de organización y su archivo opcional. */
|
|
10
|
+
export type PlatformServiceAccount = ServiceAccountsResponse["data"][number];
|
|
11
|
+
type ServiceAccountCreateBody = JsonContent<operations["postV1OmaServiceAccounts"]["requestBody"]>;
|
|
12
|
+
/** El cuerpo de crear una cuenta de servicio: el nombre y `developer` o `admin`. */
|
|
13
|
+
export type PlatformServiceAccountCreateParams = ServiceAccountCreateBody;
|
|
14
|
+
/**
|
|
15
|
+
* La cuenta de servicio que devuelven el detalle, el archivo y el alta (`GET /v1/oma/service_accounts/{id}`): el tipo
|
|
16
|
+
* neutral del recurso, no el del alta en particular.
|
|
17
|
+
*/
|
|
18
|
+
export type PlatformServiceAccountResponse = JsonContent<operations["getV1OmaServiceAccountsId"]["responses"][200]>;
|
|
19
|
+
/** El alta devuelve la misma forma; el alias nombra la respuesta de `create`. */
|
|
20
|
+
export type PlatformServiceAccountCreateResponse = PlatformServiceAccountResponse;
|
|
21
|
+
/** La query de `list` tal como la declara el contrato (`limit`, `page`, `include_archived`). */
|
|
22
|
+
type ServiceAccountsListQuery = NonNullable<operations["getV1OmaServiceAccounts"]["parameters"]["query"]>;
|
|
23
|
+
/**
|
|
24
|
+
* Las opciones de `list`: las del cliente oficial más la query del contrato, con `include_archived` como booleano (el
|
|
25
|
+
* SDK lo manda al wire como `"true"`/`"false"`).
|
|
26
|
+
*/
|
|
27
|
+
export type PlatformServiceAccountsListParams = Omit<PlatformRequestOptions, "body" | "query"> & {
|
|
28
|
+
query?: Omit<ServiceAccountsListQuery, "include_archived"> & {
|
|
29
|
+
include_archived?: boolean;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* `/v1/oma/service_accounts`: las cuatro operaciones que la guía enseña — `list`, `create`, `retrieve` y `archive`.
|
|
34
|
+
* Los `POST` no se reintentan (`withRetryPolicy`) y los errores salen como `PlatformApiError`.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ServiceAccountsResource {
|
|
37
|
+
private readonly client;
|
|
38
|
+
constructor(client: Anthropic);
|
|
39
|
+
/**
|
|
40
|
+
* Lista las cuentas (`GET /v1/oma/service_accounts`). La query es la del contrato: `limit` (de 1 a 100), `page` (el
|
|
41
|
+
* `next_page` de la página anterior) e `include_archived` (booleano; al wire va como `"true"`/`"false"`).
|
|
42
|
+
*/
|
|
43
|
+
list(params?: PlatformServiceAccountsListParams): Promise<PlatformServiceAccountsPage>;
|
|
44
|
+
/**
|
|
45
|
+
* Crea una cuenta de servicio (`POST /v1/oma/service_accounts`). Es una escritura de gestión: pide la credencial de
|
|
46
|
+
* una persona, así que una clave de service account, una clave sin principal o un token federado reciben `403` con
|
|
47
|
+
* `errorCode: "admin_required"` aunque tengan el alcance (una identidad no humana no fabrica otras). Los `400` del
|
|
48
|
+
* contrato también traen el código en `errorCode`: `invalid_name` (nombre inválido o repetido) y
|
|
49
|
+
* `service_account_limit_reached` (la organización llegó a su tope).
|
|
50
|
+
*/
|
|
51
|
+
create(params: PlatformServiceAccountCreateParams, options?: RequestOptions): Promise<PlatformServiceAccountCreateResponse>;
|
|
52
|
+
retrieve(id: string, options?: RequestOptions): Promise<PlatformServiceAccountResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Archiva la cuenta (`POST /v1/oma/service_accounts/:id/archive`); la ruta no es un `DELETE`. Es idempotente:
|
|
55
|
+
* archivar una cuenta ya archivada devuelve la misma cuenta. Un `400` con `errorCode: "resource_in_use"` avisa que
|
|
56
|
+
* hay reglas de federación que la usan como destino: hay que archivarlas primero. Un id inexistente o de otra
|
|
57
|
+
* organización es el `404` `service_account_not_found` (también si no tiene la forma `svac_<uuid>`).
|
|
58
|
+
*/
|
|
59
|
+
archive(id: string, options?: RequestOptions): Promise<PlatformServiceAccountResponse>;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { platformRequest, serializeListQuery } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* `/v1/oma/service_accounts`: las cuatro operaciones que la guía enseña — `list`, `create`, `retrieve` y `archive`.
|
|
4
|
+
* Los `POST` no se reintentan (`withRetryPolicy`) y los errores salen como `PlatformApiError`.
|
|
5
|
+
*/
|
|
6
|
+
export class ServiceAccountsResource {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Lista las cuentas (`GET /v1/oma/service_accounts`). La query es la del contrato: `limit` (de 1 a 100), `page` (el
|
|
13
|
+
* `next_page` de la página anterior) e `include_archived` (booleano; al wire va como `"true"`/`"false"`).
|
|
14
|
+
*/
|
|
15
|
+
list(params = {}) {
|
|
16
|
+
const { query, ...options } = params;
|
|
17
|
+
return platformRequest(this.client, "get", "/v1/oma/service_accounts", {
|
|
18
|
+
...options,
|
|
19
|
+
query: serializeListQuery(query),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Crea una cuenta de servicio (`POST /v1/oma/service_accounts`). Es una escritura de gestión: pide la credencial de
|
|
24
|
+
* una persona, así que una clave de service account, una clave sin principal o un token federado reciben `403` con
|
|
25
|
+
* `errorCode: "admin_required"` aunque tengan el alcance (una identidad no humana no fabrica otras). Los `400` del
|
|
26
|
+
* contrato también traen el código en `errorCode`: `invalid_name` (nombre inválido o repetido) y
|
|
27
|
+
* `service_account_limit_reached` (la organización llegó a su tope).
|
|
28
|
+
*/
|
|
29
|
+
create(params, options) {
|
|
30
|
+
return platformRequest(this.client, "post", "/v1/oma/service_accounts", {
|
|
31
|
+
...options,
|
|
32
|
+
body: params,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
retrieve(id, options) {
|
|
36
|
+
return platformRequest(this.client, "get", `/v1/oma/service_accounts/${encodeURIComponent(id)}`, options);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Archiva la cuenta (`POST /v1/oma/service_accounts/:id/archive`); la ruta no es un `DELETE`. Es idempotente:
|
|
40
|
+
* archivar una cuenta ya archivada devuelve la misma cuenta. Un `400` con `errorCode: "resource_in_use"` avisa que
|
|
41
|
+
* hay reglas de federación que la usan como destino: hay que archivarlas primero. Un id inexistente o de otra
|
|
42
|
+
* organización es el `404` `service_account_not_found` (también si no tiene la forma `svac_<uuid>`).
|
|
43
|
+
*/
|
|
44
|
+
archive(id, options) {
|
|
45
|
+
return platformRequest(this.client, "post", `/v1/oma/service_accounts/${encodeURIComponent(id)}/archive`, options);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 OutputListResponse = JsonContent<operations["getV1SessionsSessionIdOutputs"]["responses"][200]>;
|
|
6
|
+
export type PlatformSessionOutputsPage = OutputListResponse;
|
|
7
|
+
/** Un output de la sesión: el nombre, el tamaño, cuándo se subió y su tipo. */
|
|
8
|
+
export type PlatformSessionOutput = OutputListResponse["data"][number];
|
|
9
|
+
/**
|
|
10
|
+
* Los outputs de una Managed Session: `GET /v1/sessions/:sessionId/outputs` y `.../outputs/:filename`. La ruta no es
|
|
11
|
+
* `/v1/oma/*`, así que el recurso arma la ruta completa. Las dos operaciones mandan
|
|
12
|
+
* `anthropic-beta: managed-agents-2026-04-01`, que `buildManagedSessionOutputRoutes` exige.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SessionOutputsResource {
|
|
15
|
+
private readonly client;
|
|
16
|
+
constructor(client: Anthropic);
|
|
17
|
+
/** La lista no pagina: la ruta contesta `{ data, has_more: false }` y no acepta cursor. */
|
|
18
|
+
list(sessionId: string, options?: RequestOptions): Promise<PlatformSessionOutputsPage>;
|
|
19
|
+
/**
|
|
20
|
+
* Baja un output como el `Response` crudo del `fetch`, no como texto: los bytes no UTF-8 no se corrompen.
|
|
21
|
+
*
|
|
22
|
+
* **Leé o cancelá `body`**: `await response.arrayBuffer()`, `await response.text()` o
|
|
23
|
+
* `await response.body?.cancel()`; si no, la conexión queda tomada. Un no-`2xx` rechaza con `PlatformApiError`, igual
|
|
24
|
+
* que el resto de `platform`.
|
|
25
|
+
*/
|
|
26
|
+
content(sessionId: string, filename: string, options?: RequestOptions): Promise<Response>;
|
|
27
|
+
}
|
|
28
|
+
/** El namespace `sessions` de `client.platform`; hoy expone los outputs. */
|
|
29
|
+
export declare class SessionsResource {
|
|
30
|
+
readonly outputs: SessionOutputsResource;
|
|
31
|
+
constructor(client: Anthropic);
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { APIError } from "@anthropic-ai/sdk";
|
|
2
|
+
import { PlatformApiError } from "./errors.js";
|
|
3
|
+
import { MANAGED_AGENTS_BETA, platformRequest, withBeta } from "./http.js";
|
|
4
|
+
/**
|
|
5
|
+
* Codifica el nombre de un output como un solo segmento (`%20`, `%2F`). Los nombres vacíos, `.` y `..` no se escapan
|
|
6
|
+
* con `encodeURIComponent` y se rechazan antes de llamar, con un `TypeError`.
|
|
7
|
+
*/
|
|
8
|
+
function outputFilenameSegment(filename) {
|
|
9
|
+
if (typeof filename !== "string" || filename.length === 0 || filename === "." || filename === "..") {
|
|
10
|
+
throw new TypeError("filename must be a non-empty name other than '.' or '..'");
|
|
11
|
+
}
|
|
12
|
+
return encodeURIComponent(filename);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Los outputs de una Managed Session: `GET /v1/sessions/:sessionId/outputs` y `.../outputs/:filename`. La ruta no es
|
|
16
|
+
* `/v1/oma/*`, así que el recurso arma la ruta completa. Las dos operaciones mandan
|
|
17
|
+
* `anthropic-beta: managed-agents-2026-04-01`, que `buildManagedSessionOutputRoutes` exige.
|
|
18
|
+
*/
|
|
19
|
+
export class SessionOutputsResource {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/** La lista no pagina: la ruta contesta `{ data, has_more: false }` y no acepta cursor. */
|
|
25
|
+
list(sessionId, options) {
|
|
26
|
+
return platformRequest(this.client, "get", `/v1/sessions/${encodeURIComponent(sessionId)}/outputs`, withBeta(MANAGED_AGENTS_BETA, options));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Baja un output como el `Response` crudo del `fetch`, no como texto: los bytes no UTF-8 no se corrompen.
|
|
30
|
+
*
|
|
31
|
+
* **Leé o cancelá `body`**: `await response.arrayBuffer()`, `await response.text()` o
|
|
32
|
+
* `await response.body?.cancel()`; si no, la conexión queda tomada. Un no-`2xx` rechaza con `PlatformApiError`, igual
|
|
33
|
+
* que el resto de `platform`.
|
|
34
|
+
*/
|
|
35
|
+
async content(sessionId, filename, options) {
|
|
36
|
+
const segment = outputFilenameSegment(filename);
|
|
37
|
+
try {
|
|
38
|
+
return await this.client
|
|
39
|
+
.request({
|
|
40
|
+
...withBeta(MANAGED_AGENTS_BETA, options),
|
|
41
|
+
method: "get",
|
|
42
|
+
path: `/v1/sessions/${encodeURIComponent(sessionId)}/outputs/${segment}`,
|
|
43
|
+
})
|
|
44
|
+
.asResponse();
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error instanceof APIError)
|
|
48
|
+
throw PlatformApiError.fromAPIError(error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** El namespace `sessions` de `client.platform`; hoy expone los outputs. */
|
|
54
|
+
export class SessionsResource {
|
|
55
|
+
outputs;
|
|
56
|
+
constructor(client) {
|
|
57
|
+
this.outputs = new SessionOutputsResource(client);
|
|
58
|
+
}
|
|
59
|
+
}
|