@nouter/platform 0.1.0 → 0.3.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/dist/generated/openapi.d.ts +5896 -2449
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -7
- 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
|
@@ -26,7 +26,7 @@ export interface NouterPlatformOptions extends AnthropicClientOptions {
|
|
|
26
26
|
bearer?: string;
|
|
27
27
|
/** Active Nouter platform workspace. Sent as `x-active-tenant`. */
|
|
28
28
|
activeTenantId?: string;
|
|
29
|
-
/**
|
|
29
|
+
/** The caller's own User-Agent; the SDK appends `nouter-platform-sdk/<version>` to it. */
|
|
30
30
|
userAgent?: string;
|
|
31
31
|
}
|
|
32
32
|
/** @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";
|
|
@@ -45,6 +46,33 @@ function mergeDefaultHeaders(defaultHeaders, additions) {
|
|
|
45
46
|
}
|
|
46
47
|
return merged;
|
|
47
48
|
}
|
|
49
|
+
/** El User-Agent propio del SDK: viaja por default y se suma al del integrador. */
|
|
50
|
+
const SDK_USER_AGENT = `nouter-platform-sdk/${PLATFORM_SDK_VERSION}`;
|
|
51
|
+
function headerString(value) {
|
|
52
|
+
if (typeof value === "string") {
|
|
53
|
+
const trimmed = value.trim();
|
|
54
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(value)) {
|
|
57
|
+
const joined = value.map(String).join(" ").trim();
|
|
58
|
+
return joined.length > 0 ? joined : undefined;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Suma el User-Agent del SDK al del integrador en vez de reemplazarlo. El SDK oficial arma
|
|
64
|
+
* `User-Agent: Anthropic/JS <VERSION>` en `getUserAgent()` y después aplica `this._options.defaultHeaders` en
|
|
65
|
+
* `buildHeaders`, que gana en el merge
|
|
66
|
+
* (https://github.com/anthropics/anthropic-sdk-typescript/blob/main/src/client.ts): por eso nuestro header default
|
|
67
|
+
* reemplaza al `Anthropic/JS` y no se apila. Los `X-Stainless-*` de `getPlatformHeaders`
|
|
68
|
+
* (https://github.com/anthropics/anthropic-sdk-typescript/blob/main/src/internal/detect-platform.ts) siguen viajando
|
|
69
|
+
* aparte.
|
|
70
|
+
*/
|
|
71
|
+
function composeUserAgent(caller, ours) {
|
|
72
|
+
if (caller === undefined)
|
|
73
|
+
return ours;
|
|
74
|
+
return caller.split(/\s+/).includes(ours) ? caller : `${caller} ${ours}`;
|
|
75
|
+
}
|
|
48
76
|
/** NOUTER PATCH: el SDK no tiene host de API por defecto. Gana `baseURL` (o el
|
|
49
77
|
* `baseUrl` obsoleto), después la variable `NOUTER_PLATFORM_BASE_URL`; si no, falla con un error claro. */
|
|
50
78
|
function resolveBaseURL(explicit) {
|
|
@@ -68,6 +96,17 @@ export class NouterPlatform {
|
|
|
68
96
|
// emit Bearer under SDK 1.x, so only string keys are remapped to X-Api-Key.
|
|
69
97
|
const platformApiKey = typeof apiKey === "string" && apiKey.length > 0 ? apiKey : null;
|
|
70
98
|
const authToken = options.authToken ?? bearer ?? null;
|
|
99
|
+
const mergedDefaults = mergeDefaultHeaders(defaultHeaders, {
|
|
100
|
+
...(platformApiKey ? { "X-Api-Key": platformApiKey } : {}),
|
|
101
|
+
// Omit Authorization only when we are not using authToken Bearer auth.
|
|
102
|
+
...(platformApiKey && !authToken ? { Authorization: null } : {}),
|
|
103
|
+
...(activeTenantId ? { "x-active-tenant": activeTenantId } : {}),
|
|
104
|
+
});
|
|
105
|
+
// El integrador puede traer su User-Agent por la opción o por `defaultHeaders`; el del SDK se suma en los dos casos.
|
|
106
|
+
const callerAgent = typeof userAgent === "string" && userAgent.trim().length > 0
|
|
107
|
+
? userAgent.trim()
|
|
108
|
+
: headerString(mergedDefaults["user-agent"]);
|
|
109
|
+
mergedDefaults["user-agent"] = composeUserAgent(callerAgent, SDK_USER_AGENT);
|
|
71
110
|
this.anthropic = new Anthropic({
|
|
72
111
|
...anthropicOptions,
|
|
73
112
|
// Prevent SDK 1.x from emitting Authorization: Bearer for the Nouter platform key.
|
|
@@ -75,13 +114,7 @@ export class NouterPlatform {
|
|
|
75
114
|
// NOUTER PATCH: sin URL por defecto de upstream; sale de `baseURL` o de NOUTER_PLATFORM_BASE_URL.
|
|
76
115
|
baseURL: resolveBaseURL(options.baseURL ?? baseUrl),
|
|
77
116
|
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
|
-
}),
|
|
117
|
+
defaultHeaders: mergedDefaults,
|
|
85
118
|
});
|
|
86
119
|
// Keep the official resources and transport intact; do not normalize patches.
|
|
87
120
|
this.beta = this.anthropic.beta;
|
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.3.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.3.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nouter/platform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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": {
|