@nouter/platform 0.4.0 → 0.6.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.
@@ -0,0 +1,76 @@
1
+ import { APIError, toFile } from "@anthropic-ai/sdk";
2
+ import { PlatformApiError } from "./errors.js";
3
+ import { withBeta, withRetryPolicy } from "./http.js";
4
+ /** El beta que exige toda la familia `/v1/skills` (`requireBeta(SKILLS_API_BETA)` en el servidor). */
5
+ export const SKILLS_BETA = "skills-2025-10-02";
6
+ /**
7
+ * Traduce el `APIError` del SDK oficial al error de `platform`. El recurso oficial de skills no pasa por
8
+ * `platformRequest`, así que cada método envuelve su promesa con esto.
9
+ */
10
+ async function translated(call) {
11
+ try {
12
+ return await call;
13
+ }
14
+ catch (error) {
15
+ if (error instanceof APIError)
16
+ throw PlatformApiError.fromAPIError(error);
17
+ throw error;
18
+ }
19
+ }
20
+ /** Cada archivo como `File` con su ruta relativa como nombre: es lo que el multipart manda en `filename`. */
21
+ function uploadables(files) {
22
+ return Promise.all(files.map((file) => toFile(file.content, file.path)));
23
+ }
24
+ /**
25
+ * Las versiones de una skill: `POST /v1/skills/{skillId}/versions` y la descarga del contenido.
26
+ *
27
+ * El SDK oficial 1.13.0 no tiene `content` en `client.skills.versions`; el binario solo existe como
28
+ * `client.beta.skills.versions.download`, que devuelve el `Response` crudo. El método público sigue siendo `content`.
29
+ */
30
+ export class SkillVersionsResource {
31
+ client;
32
+ constructor(client) {
33
+ this.client = client;
34
+ }
35
+ async create(skillId, params, options) {
36
+ const files = await uploadables(params.files);
37
+ const created = await translated(this.client.skills.versions.create(skillId, { files }, withRetryPolicy("post", withBeta(SKILLS_BETA, options))));
38
+ // El servidor contesta la forma del contrato; el tipo del SDK oficial no es la fuente.
39
+ return created;
40
+ }
41
+ /**
42
+ * Baja el contenido de una versión como el `Response` crudo del `fetch`, no como texto.
43
+ *
44
+ * **Leé o cancelá `body`**: `await response.arrayBuffer()`, `await response.text()` o
45
+ * `await response.body?.cancel()`; si no, la conexión queda tomada. Un no-`2xx` rechaza con `PlatformApiError`.
46
+ */
47
+ content(skillId, version, options) {
48
+ return translated(this.client.beta.skills.versions
49
+ .download(version, { skill_id: skillId }, withBeta(SKILLS_BETA, options))
50
+ .asResponse());
51
+ }
52
+ }
53
+ /**
54
+ * `client.platform.skills`: la lista, el alta y las versiones de `/v1/skills`, delegando en `client.skills.*` del
55
+ * SDK oficial. Todas las llamadas mandan `anthropic-beta: skills-2025-10-02` y los `POST` van sin reintentos.
56
+ */
57
+ export class SkillsResource {
58
+ client;
59
+ versions;
60
+ constructor(client) {
61
+ this.client = client;
62
+ this.versions = new SkillVersionsResource(client);
63
+ }
64
+ async list(params = {}, options) {
65
+ const page = await translated(this.client.skills.list(params, withBeta(SKILLS_BETA, options)));
66
+ // El SDK oficial devuelve un `PageCursor` con `options`, `response` y `body` propios; la superficie de la
67
+ // plataforma expone la página plana del contrato, `{ data, next_page }`. El cast de `data` es por el índice
68
+ // abierto de `source` en el tipo del contrato, que el `Skill` oficial no declara.
69
+ return { data: page.data, next_page: page.next_page };
70
+ }
71
+ async create(params, options) {
72
+ const files = await uploadables(params.files);
73
+ const created = await translated(this.client.skills.create({ files }, withRetryPolicy("post", withBeta(SKILLS_BETA, options))));
74
+ return created;
75
+ }
76
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const PLATFORM_SDK_VERSION = "0.4.0";
1
+ export declare const PLATFORM_SDK_VERSION = "0.6.0";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  // (https://github.com/anthropics/anthropic-sdk-typescript/blob/main/src/version.ts, `export const VERSION = '…'`). Se
3
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
4
  // `test/user-agent.test.ts` falla si esta constante se separa del manifiesto.
5
- export const PLATFORM_SDK_VERSION = "0.4.0";
5
+ export const PLATFORM_SDK_VERSION = "0.6.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nouter/platform",
3
- "version": "0.4.0",
3
+ "version": "0.6.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",
@@ -14,6 +14,7 @@
14
14
  "files": [
15
15
  "dist",
16
16
  "README.md",
17
+ "CHANGELOG.md",
17
18
  "LICENSE",
18
19
  "NOTICE"
19
20
  ],