@nouter/platform 0.2.0 → 0.4.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 +12 -0
- package/dist/evals.d.ts +16 -0
- package/dist/evals.js +36 -38
- package/dist/generated/openapi.d.ts +7838 -2407
- package/dist/index.d.ts +2 -1
- package/dist/index.js +41 -7
- package/dist/oma.d.ts +3 -0
- package/dist/oma.js +4 -0
- package/dist/platform/api-keys.js +5 -1
- package/dist/platform/http.d.ts +7 -1
- package/dist/platform/http.js +26 -5
- 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/platform/usage.d.ts +8 -0
- package/dist/platform/usage.js +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ 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 { SessionsResource, SessionOutputsResource, type PlatformSessionOutput, type PlatformSessionOutputsPage, } from "./platform/sessions.js";
|
|
13
14
|
import type { PlatformBeta } from "./agents.js";
|
|
14
15
|
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
16
|
export type { PlatformEnvironment, PlatformEnvironmentCreateParams, PlatformEnvironmentUpdateParams, PlatformEnvironments, PlatformNoneEnvironmentConfig, } from "./environments.js";
|
|
@@ -26,7 +27,7 @@ export interface NouterPlatformOptions extends AnthropicClientOptions {
|
|
|
26
27
|
bearer?: string;
|
|
27
28
|
/** Active Nouter platform workspace. Sent as `x-active-tenant`. */
|
|
28
29
|
activeTenantId?: string;
|
|
29
|
-
/**
|
|
30
|
+
/** The caller's own User-Agent; the SDK appends `nouter-platform-sdk/<version>` to it. */
|
|
30
31
|
userAgent?: string;
|
|
31
32
|
}
|
|
32
33
|
/** @deprecated Use `NouterPlatformOptions`. */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Anthropic, {} from "@anthropic-ai/sdk";
|
|
2
2
|
import { PlatformResources } from "./oma.js";
|
|
3
|
+
import { PLATFORM_SDK_VERSION } from "./version.js";
|
|
3
4
|
export { PlatformApiError } from "./platform/errors.js";
|
|
4
5
|
export { UserProfilesResource, USER_PROFILES_BETA, } from "./platform/user-profiles.js";
|
|
5
6
|
export { UsageResource, } from "./platform/usage.js";
|
|
@@ -10,6 +11,7 @@ export { PrivacyErasureResource, PRIVACY_ERASURE_BETA, } from "./platform/privac
|
|
|
10
11
|
export { ApiKeysResource, KEY_PRESETS, } from "./platform/api-keys.js";
|
|
11
12
|
export { AuditEventsResource, } from "./platform/audit-events.js";
|
|
12
13
|
export { MeResource } from "./platform/me.js";
|
|
14
|
+
export { SessionsResource, SessionOutputsResource, } from "./platform/sessions.js";
|
|
13
15
|
export { PlatformModelsResource, PlatformModelCardsResource, PlatformHarnessesResource, PlatformResources, } from "./oma.js";
|
|
14
16
|
export { EvalsResource, EvalBenchmarksResource, EvalCasesResource, EvalRunsResource, EVAL_RUN_TERMINAL_STATUSES, } from "./evals.js";
|
|
15
17
|
export { Anthropic };
|
|
@@ -45,6 +47,33 @@ function mergeDefaultHeaders(defaultHeaders, additions) {
|
|
|
45
47
|
}
|
|
46
48
|
return merged;
|
|
47
49
|
}
|
|
50
|
+
/** El User-Agent propio del SDK: viaja por default y se suma al del integrador. */
|
|
51
|
+
const SDK_USER_AGENT = `nouter-platform-sdk/${PLATFORM_SDK_VERSION}`;
|
|
52
|
+
function headerString(value) {
|
|
53
|
+
if (typeof value === "string") {
|
|
54
|
+
const trimmed = value.trim();
|
|
55
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
const joined = value.map(String).join(" ").trim();
|
|
59
|
+
return joined.length > 0 ? joined : undefined;
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Suma el User-Agent del SDK al del integrador en vez de reemplazarlo. El SDK oficial arma
|
|
65
|
+
* `User-Agent: Anthropic/JS <VERSION>` en `getUserAgent()` y después aplica `this._options.defaultHeaders` en
|
|
66
|
+
* `buildHeaders`, que gana en el merge
|
|
67
|
+
* (https://github.com/anthropics/anthropic-sdk-typescript/blob/main/src/client.ts): por eso nuestro header default
|
|
68
|
+
* reemplaza al `Anthropic/JS` y no se apila. Los `X-Stainless-*` de `getPlatformHeaders`
|
|
69
|
+
* (https://github.com/anthropics/anthropic-sdk-typescript/blob/main/src/internal/detect-platform.ts) siguen viajando
|
|
70
|
+
* aparte.
|
|
71
|
+
*/
|
|
72
|
+
function composeUserAgent(caller, ours) {
|
|
73
|
+
if (caller === undefined)
|
|
74
|
+
return ours;
|
|
75
|
+
return caller.split(/\s+/).includes(ours) ? caller : `${caller} ${ours}`;
|
|
76
|
+
}
|
|
48
77
|
/** NOUTER PATCH: el SDK no tiene host de API por defecto. Gana `baseURL` (o el
|
|
49
78
|
* `baseUrl` obsoleto), después la variable `NOUTER_PLATFORM_BASE_URL`; si no, falla con un error claro. */
|
|
50
79
|
function resolveBaseURL(explicit) {
|
|
@@ -68,6 +97,17 @@ export class NouterPlatform {
|
|
|
68
97
|
// emit Bearer under SDK 1.x, so only string keys are remapped to X-Api-Key.
|
|
69
98
|
const platformApiKey = typeof apiKey === "string" && apiKey.length > 0 ? apiKey : null;
|
|
70
99
|
const authToken = options.authToken ?? bearer ?? null;
|
|
100
|
+
const mergedDefaults = mergeDefaultHeaders(defaultHeaders, {
|
|
101
|
+
...(platformApiKey ? { "X-Api-Key": platformApiKey } : {}),
|
|
102
|
+
// Omit Authorization only when we are not using authToken Bearer auth.
|
|
103
|
+
...(platformApiKey && !authToken ? { Authorization: null } : {}),
|
|
104
|
+
...(activeTenantId ? { "x-active-tenant": activeTenantId } : {}),
|
|
105
|
+
});
|
|
106
|
+
// El integrador puede traer su User-Agent por la opción o por `defaultHeaders`; el del SDK se suma en los dos casos.
|
|
107
|
+
const callerAgent = typeof userAgent === "string" && userAgent.trim().length > 0
|
|
108
|
+
? userAgent.trim()
|
|
109
|
+
: headerString(mergedDefaults["user-agent"]);
|
|
110
|
+
mergedDefaults["user-agent"] = composeUserAgent(callerAgent, SDK_USER_AGENT);
|
|
71
111
|
this.anthropic = new Anthropic({
|
|
72
112
|
...anthropicOptions,
|
|
73
113
|
// Prevent SDK 1.x from emitting Authorization: Bearer for the Nouter platform key.
|
|
@@ -75,13 +115,7 @@ export class NouterPlatform {
|
|
|
75
115
|
// NOUTER PATCH: sin URL por defecto de upstream; sale de `baseURL` o de NOUTER_PLATFORM_BASE_URL.
|
|
76
116
|
baseURL: resolveBaseURL(options.baseURL ?? baseUrl),
|
|
77
117
|
authToken,
|
|
78
|
-
defaultHeaders:
|
|
79
|
-
...(platformApiKey ? { "X-Api-Key": platformApiKey } : {}),
|
|
80
|
-
// Omit Authorization only when we are not using authToken Bearer auth.
|
|
81
|
-
...(platformApiKey && !authToken ? { Authorization: null } : {}),
|
|
82
|
-
...(activeTenantId ? { "x-active-tenant": activeTenantId } : {}),
|
|
83
|
-
...(userAgent ? { "user-agent": userAgent } : {}),
|
|
84
|
-
}),
|
|
118
|
+
defaultHeaders: mergedDefaults,
|
|
85
119
|
});
|
|
86
120
|
// Keep the official resources and transport intact; do not normalize patches.
|
|
87
121
|
this.beta = this.anthropic.beta;
|
package/dist/oma.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ 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 { SessionsResource } from "./platform/sessions.js";
|
|
13
14
|
export { PlatformModelCardsResource };
|
|
14
15
|
export type { PlatformModelCard, PlatformModelCardCreateParams, PlatformModelCardCreateResponse, PlatformModelCardDeleted, PlatformModelCardListParams, PlatformModelCardListResponse, PlatformModelCardUpdateParams, } from "./platform/model-cards.js";
|
|
15
16
|
/** Pi provider id. Built-ins and user-defined ids share this open shape. */
|
|
@@ -121,6 +122,8 @@ export declare class PlatformResources {
|
|
|
121
122
|
readonly apiKeys: ApiKeysResource;
|
|
122
123
|
readonly auditEvents: AuditEventsResource;
|
|
123
124
|
readonly me: MeResource;
|
|
125
|
+
/** Los outputs de una sesión; la ruta es `/v1/sessions/*`, no `/v1/oma/*`. */
|
|
126
|
+
readonly sessions: SessionsResource;
|
|
124
127
|
constructor(client: Anthropic);
|
|
125
128
|
request<Response>(params: PlatformRequestParams): import("@anthropic-ai/sdk").APIPromise<Response>;
|
|
126
129
|
}
|
package/dist/oma.js
CHANGED
|
@@ -9,6 +9,7 @@ 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 { SessionsResource } from "./platform/sessions.js";
|
|
12
13
|
import { withRetryPolicy } from "./platform/http.js";
|
|
13
14
|
export { PlatformModelCardsResource };
|
|
14
15
|
export class PlatformHarnessesResource {
|
|
@@ -50,6 +51,8 @@ export class PlatformResources {
|
|
|
50
51
|
apiKeys;
|
|
51
52
|
auditEvents;
|
|
52
53
|
me;
|
|
54
|
+
/** Los outputs de una sesión; la ruta es `/v1/sessions/*`, no `/v1/oma/*`. */
|
|
55
|
+
sessions;
|
|
53
56
|
constructor(client) {
|
|
54
57
|
this.client = client;
|
|
55
58
|
this.models = new PlatformModelsResource(client);
|
|
@@ -65,6 +68,7 @@ export class PlatformResources {
|
|
|
65
68
|
this.apiKeys = new ApiKeysResource(client);
|
|
66
69
|
this.auditEvents = new AuditEventsResource(client);
|
|
67
70
|
this.me = new MeResource(client);
|
|
71
|
+
this.sessions = new SessionsResource(client);
|
|
68
72
|
}
|
|
69
73
|
request(params) {
|
|
70
74
|
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
|
}
|
package/dist/platform/http.d.ts
CHANGED
|
@@ -20,8 +20,14 @@ export declare function withRetryPolicy<T extends RequestOptions>(method: Platfo
|
|
|
20
20
|
* usan para que el error sea uno solo, lea el sobre que lea.
|
|
21
21
|
*/
|
|
22
22
|
export declare function platformRequest<Response>(client: Anthropic, method: PlatformMethod, path: string, options?: PlatformRequestOptions): Promise<Response>;
|
|
23
|
+
/** El beta de la familia Managed Agents; la ruta de outputs lo exige en cada llamada. */
|
|
24
|
+
export declare const MANAGED_AGENTS_BETA = "managed-agents-2026-04-01";
|
|
23
25
|
/** Suma headers a los que pase el llamador, sin perder el `Headers` ni las tuplas del cliente oficial. */
|
|
24
26
|
export declare function withHeaders(options: RequestOptions | undefined, additions: Record<string, string>): RequestOptions;
|
|
25
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Suma el `anthropic-beta` de la ruta a los headers que pase el llamador **concatenando**: si el llamador ya trae
|
|
29
|
+
* `anthropic-beta`, agrega `beta` a la lista separada por comas cuando falta; si no la trae, la pone sola. El servidor
|
|
30
|
+
* lee la cabecera como un conjunto, así un beta del llamador convive con el de la ruta.
|
|
31
|
+
*/
|
|
26
32
|
export declare function withBeta(beta: string, options?: RequestOptions): RequestOptions;
|
|
27
33
|
export {};
|
package/dist/platform/http.js
CHANGED
|
@@ -27,10 +27,11 @@ export async function platformRequest(client, method, path, options = {}) {
|
|
|
27
27
|
throw error;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
export
|
|
30
|
+
/** El beta de la familia Managed Agents; la ruta de outputs lo exige en cada llamada. */
|
|
31
|
+
export const MANAGED_AGENTS_BETA = "managed-agents-2026-04-01";
|
|
32
|
+
/** Los headers del llamador en un `Headers`, sin perder el `Headers`, las tuplas ni el objeto. */
|
|
33
|
+
function mergedHeaders(given) {
|
|
32
34
|
const headers = new Headers();
|
|
33
|
-
const given = options?.headers;
|
|
34
35
|
if (given instanceof Headers) {
|
|
35
36
|
given.forEach((value, name) => headers.set(name, value));
|
|
36
37
|
}
|
|
@@ -47,11 +48,31 @@ export function withHeaders(options, additions) {
|
|
|
47
48
|
headers.set(name, Array.isArray(value) ? value.join(",") : String(value));
|
|
48
49
|
}
|
|
49
50
|
}
|
|
51
|
+
return headers;
|
|
52
|
+
}
|
|
53
|
+
/** Suma headers a los que pase el llamador, sin perder el `Headers` ni las tuplas del cliente oficial. */
|
|
54
|
+
export function withHeaders(options, additions) {
|
|
55
|
+
const headers = mergedHeaders(options?.headers);
|
|
50
56
|
for (const [name, value] of Object.entries(additions))
|
|
51
57
|
headers.set(name, value);
|
|
52
58
|
return { ...options, headers };
|
|
53
59
|
}
|
|
54
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Suma el `anthropic-beta` de la ruta a los headers que pase el llamador **concatenando**: si el llamador ya trae
|
|
62
|
+
* `anthropic-beta`, agrega `beta` a la lista separada por comas cuando falta; si no la trae, la pone sola. El servidor
|
|
63
|
+
* lee la cabecera como un conjunto, así un beta del llamador convive con el de la ruta.
|
|
64
|
+
*/
|
|
55
65
|
export function withBeta(beta, options) {
|
|
56
|
-
|
|
66
|
+
const headers = mergedHeaders(options?.headers);
|
|
67
|
+
const given = headers.get("anthropic-beta");
|
|
68
|
+
const betas = given === null
|
|
69
|
+
? []
|
|
70
|
+
: given
|
|
71
|
+
.split(",")
|
|
72
|
+
.map((value) => value.trim())
|
|
73
|
+
.filter((value) => value.length > 0);
|
|
74
|
+
if (!betas.includes(beta))
|
|
75
|
+
betas.push(beta);
|
|
76
|
+
headers.set("anthropic-beta", betas.join(","));
|
|
77
|
+
return { ...options, headers };
|
|
57
78
|
}
|
|
@@ -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
|
+
}
|
|
@@ -3,11 +3,15 @@ type RequestOptions = Anthropic.RequestOptions;
|
|
|
3
3
|
import type { operations } from "../generated/openapi.js";
|
|
4
4
|
import type { JsonContent } from "./types.js";
|
|
5
5
|
type ConsumptionQuery = NonNullable<NonNullable<operations["getV1OmaUsageLimitsConsumption"]["parameters"]>["query"]>;
|
|
6
|
+
type NoticesQuery = NonNullable<NonNullable<operations["getV1OmaUsageLimitsNotices"]["parameters"]>["query"]>;
|
|
6
7
|
/** Un nivel de consumo; la ruta acepta más de uno, pero el transporte serializa los arrays con corchetes (`kind[]`). */
|
|
7
8
|
export type PlatformConsumptionKind = Exclude<NonNullable<ConsumptionQuery["kind"]>, readonly unknown[]>;
|
|
9
|
+
/** NOUTER PATCH (avisos de tope, tarea 5): un nivel de aviso; los ocho del contrato de `notices`. */
|
|
10
|
+
export type PlatformUsageNoticeKind = Exclude<NonNullable<NoticesQuery["kind"]>, readonly unknown[]>;
|
|
8
11
|
export type PlatformUsageLimits = JsonContent<operations["getV1OmaUsageLimits"]["responses"][200]>;
|
|
9
12
|
export type PlatformUsageLimitsUpdate = JsonContent<NonNullable<operations["postV1OmaUsageLimits"]["requestBody"]>>;
|
|
10
13
|
export type PlatformUsageConsumption = JsonContent<operations["getV1OmaUsageLimitsConsumption"]["responses"][200]>;
|
|
14
|
+
export type PlatformUsageNotices = JsonContent<operations["getV1OmaUsageLimitsNotices"]["responses"][200]>;
|
|
11
15
|
export interface PlatformUsageLimitsParams {
|
|
12
16
|
/** Sin `agent_id`, los topes de la organización. */
|
|
13
17
|
agent_id?: string;
|
|
@@ -20,6 +24,23 @@ export interface PlatformUsageConsumptionParams {
|
|
|
20
24
|
limit?: number;
|
|
21
25
|
page?: string;
|
|
22
26
|
}
|
|
27
|
+
/** NOUTER PATCH (avisos de tope, tarea 5): los filtros de `GET /v1/oma/usage_limits/notices`. */
|
|
28
|
+
export interface PlatformUsageNoticesParams {
|
|
29
|
+
kind?: PlatformUsageNoticeKind;
|
|
30
|
+
subject_id?: string;
|
|
31
|
+
threshold?: 80 | 100;
|
|
32
|
+
period?: string;
|
|
33
|
+
since?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Toda la organización: solo una cookie de owner o admin, o una clave de organización; no se combina con
|
|
36
|
+
* `workspace_id`.
|
|
37
|
+
*/
|
|
38
|
+
scope?: "organization";
|
|
39
|
+
/** Solo con una cookie de owner o admin: elige otro workspace; una clave no lo mueve. */
|
|
40
|
+
workspace_id?: string;
|
|
41
|
+
limit?: number;
|
|
42
|
+
page?: string;
|
|
43
|
+
}
|
|
23
44
|
/**
|
|
24
45
|
* `GET`/`POST /v1/oma/usage_limits` (los topes de la organización o de un agente) y la lectura del consumo con sus
|
|
25
46
|
* páginas. La familia de error es `v1`.
|
|
@@ -30,5 +51,7 @@ export declare class UsageLimitsResource {
|
|
|
30
51
|
get(params?: PlatformUsageLimitsParams, options?: RequestOptions): Promise<PlatformUsageLimits>;
|
|
31
52
|
set(params: PlatformUsageLimitsUpdate, options?: RequestOptions): Promise<PlatformUsageLimits>;
|
|
32
53
|
consumption(params?: PlatformUsageConsumptionParams, options?: RequestOptions): Promise<PlatformUsageConsumption>;
|
|
54
|
+
/** NOUTER PATCH (avisos de tope, tarea 5): los avisos 80/100 registrados, en `sent_at` descendente. */
|
|
55
|
+
notices(params?: PlatformUsageNoticesParams, options?: RequestOptions): Promise<PlatformUsageNotices>;
|
|
33
56
|
}
|
|
34
57
|
export {};
|
|
@@ -35,4 +35,23 @@ export class UsageLimitsResource {
|
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
+
/** NOUTER PATCH (avisos de tope, tarea 5): los avisos 80/100 registrados, en `sent_at` descendente. */
|
|
39
|
+
notices(params = {}, options) {
|
|
40
|
+
return platformRequest(this.client, "get", "/v1/oma/usage_limits/notices", {
|
|
41
|
+
...options,
|
|
42
|
+
query: {
|
|
43
|
+
...(params.kind !== undefined && { kind: params.kind }),
|
|
44
|
+
...(params.subject_id !== undefined && { subject_id: params.subject_id }),
|
|
45
|
+
...(params.threshold !== undefined && { threshold: params.threshold }),
|
|
46
|
+
...(params.period !== undefined && { period: params.period }),
|
|
47
|
+
...(params.since !== undefined && { since: params.since }),
|
|
48
|
+
...(params.scope !== undefined && { scope: params.scope }),
|
|
49
|
+
...(params.workspace_id !== undefined && {
|
|
50
|
+
workspace_id: params.workspace_id,
|
|
51
|
+
}),
|
|
52
|
+
...(params.limit !== undefined && { limit: params.limit }),
|
|
53
|
+
...(params.page !== undefined && { page: params.page }),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
38
57
|
}
|
package/dist/platform/usage.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type { operations } from "../generated/openapi.js";
|
|
|
4
4
|
import type { JsonContent } from "./types.js";
|
|
5
5
|
type UsageQuery = NonNullable<NonNullable<operations["getV1OmaUsage"]["parameters"]>["query"]>;
|
|
6
6
|
export type PlatformUsageGroupBy = NonNullable<UsageQuery["group_by"]>[number];
|
|
7
|
+
/** El enum de niveles del filtro, el del contrato (`USAGE_SERVICE_TIERS` en http-routes, vía el OpenAPI generado). */
|
|
8
|
+
export type PlatformUsageServiceTier = NonNullable<UsageQuery["service_tiers"]>[number];
|
|
7
9
|
export type PlatformUsage = JsonContent<operations["getV1OmaUsage"]["responses"][200]>;
|
|
8
10
|
export interface PlatformUsageParams {
|
|
9
11
|
days?: "7" | "30" | "90";
|
|
@@ -13,6 +15,12 @@ export interface PlatformUsageParams {
|
|
|
13
15
|
group_by?: PlatformUsageGroupBy[];
|
|
14
16
|
/** Se manda como `api_key_ids[]`, la forma que acepta la ruta; el transporte repite la clave por id. */
|
|
15
17
|
api_key_ids?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Se manda como `service_tiers` (el alias sin corchetes que también acepta la ruta); el transporte repite la clave
|
|
20
|
+
* por nivel. El ledger escribe `standard` (todo lo demás) y `batch` (la Batches API); los otros niveles del enum no
|
|
21
|
+
* dan filas. `models` y `sessions` no se filtran por nivel, y el cursor liga el filtro.
|
|
22
|
+
*/
|
|
23
|
+
service_tiers?: PlatformUsageServiceTier[];
|
|
16
24
|
user_profile_id?: string;
|
|
17
25
|
limit?: number;
|
|
18
26
|
page?: string;
|
package/dist/platform/usage.js
CHANGED
|
@@ -14,6 +14,7 @@ export class UsageResource {
|
|
|
14
14
|
...(params.ending_at !== undefined && { ending_at: params.ending_at }),
|
|
15
15
|
...(params.group_by !== undefined && { group_by: params.group_by }),
|
|
16
16
|
...(params.api_key_ids !== undefined && { api_key_ids: params.api_key_ids }),
|
|
17
|
+
...(params.service_tiers !== undefined && { service_tiers: params.service_tiers }),
|
|
17
18
|
...(params.user_profile_id !== undefined && { user_profile_id: params.user_profile_id }),
|
|
18
19
|
...(params.limit !== undefined && { limit: params.limit }),
|
|
19
20
|
...(params.page !== undefined && { page: params.page }),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLATFORM_SDK_VERSION = "0.4.0";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// La versión del paquete, como una constante que el release actualiza: es el mismo patrón del SDK oficial de Anthropic
|
|
2
|
+
// (https://github.com/anthropics/anthropic-sdk-typescript/blob/main/src/version.ts, `export const VERSION = '…'`). Se
|
|
3
|
+
// mantiene acá y no leyendo `package.json` para no meter `node:fs` en un paquete que hoy no depende de ningún builtin.
|
|
4
|
+
// `test/user-agent.test.ts` falla si esta constante se separa del manifiesto.
|
|
5
|
+
export const PLATFORM_SDK_VERSION = "0.4.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nouter/platform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Nouter platform SDK: the official Anthropic Managed Agents client plus typed Nouter platform extensions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"NOTICE"
|
|
19
19
|
],
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=20"
|
|
21
|
+
"node": ">=20.6"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"homepage": "https://github.com/Nouter-ai/platform",
|
|
50
50
|
"repository": {
|
|
51
51
|
"type": "git",
|
|
52
|
-
"url": "https://github.com/Nouter-ai/platform",
|
|
52
|
+
"url": "git+https://github.com/Nouter-ai/platform.git",
|
|
53
53
|
"directory": "packages/sdk"
|
|
54
54
|
},
|
|
55
55
|
"bugs": {
|