@pouchy_ai/admin-sdk 0.4.2 → 0.4.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to `@pouchy_ai/admin-sdk` are documented here.
4
4
 
5
+ ## 0.4.4 — 2026-07-17
6
+
7
+ Transport-error parity with the JS/python/unity siblings (they got this in
8
+ their last release; admin-sdk was only touched for packaging).
9
+
10
+ - **Every failure now throws `AdminApiError`.** A network/DNS failure
11
+ previously escaped as a raw `TypeError: fetch failed`, contradicting the
12
+ documented "failures throw AdminApiError" contract. Transport errors are
13
+ wrapped as `AdminApiError(status: 0)`.
14
+ - **Per-request timeout** (`timeoutMs`, default 30s): a hung upstream now
15
+ rejects with `AdminApiError('request timed out after …', 0)` instead of
16
+ hanging forever. Uses `AbortSignal.timeout`.
17
+ - **`ADMIN_SDK_VERSION` corrected to match `package.json`** (it had drifted to
18
+ `0.4.2`, the second time this constant fell behind — now pinned by a test).
19
+
20
+ ## 0.4.3 — 2026-07-17
21
+
22
+ - Packaging only: added the `default` export condition beside `import` in the
23
+ `exports` map — bundlers resolving with non-import condition sets no longer
24
+ fail on the bare `"."` entry. No runtime changes.
25
+
5
26
  ## 0.4.2 — 2026-07-16
6
27
 
7
28
  The rest of the 0.4.1 drift class — four more response/input shapes that lied
@@ -27,6 +48,9 @@ about the live routes, caught by comparing every method against its
27
48
  the closed object literal blocked fields the server accepts, so test-env /
28
49
  secret-bearing connectors were unreachable through the typed method.
29
50
  - **`getBilling().billing.periodEnd`** is `string | null` (always present).
51
+ - **`listVoices`** input gains `age?` and `CatalogVoice` carries `age` — the
52
+ server's `/v1/admin/voice-catalog` already filters and returns it (this bullet
53
+ was omitted from the original 0.4.2 notes; the types shipped correctly).
30
54
 
31
55
  Also in this release: `GET /v1/admin/openapi` (the machine-readable spec this
32
56
  SDK mirrors) was rewritten against the live routes — it still described the
package/README.md CHANGED
@@ -61,13 +61,16 @@ console.log(`armed — ${armed.reprovisioned} running instance(s) updated`);
61
61
  createAdminClient({
62
62
  adminKey: 'pchy_admin_…', // required
63
63
  baseUrl: 'https://pouchy.ai/v1/admin', // optional (self-host / staging)
64
- fetch: myFetch // optional (Node <18, or tests)
64
+ fetch: myFetch, // optional (Node <18, or tests)
65
+ timeoutMs: 30_000 // optional per-request timeout (default 30s)
65
66
  });
66
67
  ```
67
68
 
68
69
  ## Errors
69
70
 
70
- Every method throws `AdminApiError` on a non-2xx response:
71
+ Every method throws `AdminApiError` on failure — a non-2xx response, a network
72
+ error, or a timeout. Transport failures (network/DNS/timeout) carry
73
+ `status: 0`; HTTP errors carry the real status and the server's `error` string:
71
74
 
72
75
  ```ts
73
76
  import { AdminApiError } from '@pouchy_ai/admin-sdk';
@@ -83,7 +86,7 @@ try {
83
86
  | Area | Methods |
84
87
  | --- | --- |
85
88
  | Agents | `listAgents` · `createAgent` · `getAgent` · `updateAgent` · `deleteAgent` |
86
- | Voices | `listVoices({ gender?, locale? })` — catalog for programmatic voice selection |
89
+ | Voices | `listVoices({ gender?, age?, locale? })` — catalog for programmatic voice selection (each `CatalogVoice` carries `age`) |
87
90
  | Secret keys | `listKeys` · `createKey` · `revokeKey` · `rotateKey` (24 h grace) |
88
91
  | End users | `listUsers` · `setUserSuspended` · `deleteUser` · `getUserWallet` · `getUserTraces` · `importUsers` · `exportUser` · `getUserSessions` · `getUserTurns` |
89
92
  | Knowledge | `listKnowledge` · `ingestKnowledge` · `deleteKnowledge` |
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const ADMIN_SDK_VERSION = "0.4.2";
1
+ export declare const ADMIN_SDK_VERSION = "0.4.4";
2
2
  export declare const DEFAULT_BASE_URL = "https://pouchy.ai/v1/admin";
3
3
  export interface AdminClientOptions {
4
4
  /** A project Admin key (`pchy_admin_…`) from the dashboard Admin Keys page. */
@@ -7,6 +7,9 @@ export interface AdminClientOptions {
7
7
  baseUrl?: string;
8
8
  /** Inject a fetch impl (Node <18, or for tests). Default global fetch. */
9
9
  fetch?: typeof fetch;
10
+ /** Per-request timeout in ms (default 30s). A request that outlives it
11
+ * rejects with an AdminApiError(status 0). */
12
+ timeoutMs?: number;
10
13
  }
11
14
  /** Thrown on any non-2xx response. `status` is the HTTP status; `message` is the
12
15
  * server's `error` string when present. */
package/dist/index.js CHANGED
@@ -8,8 +8,10 @@
8
8
  // import { createAdminClient } from '@pouchy_ai/admin-sdk';
9
9
  // const admin = createAdminClient({ adminKey: process.env.POUCHY_ADMIN_KEY! });
10
10
  // const { agents } = await admin.listAgents();
11
- export const ADMIN_SDK_VERSION = '0.4.2';
11
+ export const ADMIN_SDK_VERSION = '0.4.4';
12
12
  export const DEFAULT_BASE_URL = 'https://pouchy.ai/v1/admin';
13
+ /** Default per-request timeout (ms). A hung upstream otherwise never rejects. */
14
+ const DEFAULT_TIMEOUT_MS = 30_000;
13
15
  /** Thrown on any non-2xx response. `status` is the HTTP status; `message` is the
14
16
  * server's `error` string when present. */
15
17
  export class AdminApiError extends Error {
@@ -35,15 +37,28 @@ export function createAdminClient(opts) {
35
37
  const f = opts.fetch ?? globalThis.fetch;
36
38
  if (!f)
37
39
  throw new AdminApiError('no fetch available — pass opts.fetch on Node <18', 0);
40
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
38
41
  async function request(method, path, body) {
39
- const res = await f(base + path, {
40
- method,
41
- headers: {
42
- authorization: `Bearer ${opts.adminKey}`,
43
- ...(body !== undefined ? { 'content-type': 'application/json' } : {})
44
- },
45
- body: body !== undefined ? JSON.stringify(body) : undefined
46
- });
42
+ // Every failure surfaces as an AdminApiError (the doc contract): a
43
+ // network/DNS error or a timeout would otherwise escape as a raw
44
+ // `TypeError: fetch failed` / AbortError. Status 0 = never reached the
45
+ // server (parity with the JS/python SDKs' transport-error wrapping).
46
+ let res;
47
+ try {
48
+ res = await f(base + path, {
49
+ method,
50
+ headers: {
51
+ authorization: `Bearer ${opts.adminKey}`,
52
+ ...(body !== undefined ? { 'content-type': 'application/json' } : {})
53
+ },
54
+ body: body !== undefined ? JSON.stringify(body) : undefined,
55
+ signal: AbortSignal.timeout(timeoutMs)
56
+ });
57
+ }
58
+ catch (e) {
59
+ const isTimeout = e instanceof Error && (e.name === 'TimeoutError' || e.name === 'AbortError');
60
+ throw new AdminApiError(isTimeout ? `request timed out after ${timeoutMs}ms` : `network error: ${e instanceof Error ? e.message : String(e)}`, 0);
61
+ }
47
62
  const data = (await res.json().catch(() => ({})));
48
63
  if (!res.ok)
49
64
  throw new AdminApiError(data?.error ?? `HTTP ${res.status}`, res.status);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pouchy_ai/admin-sdk",
3
- "version": "0.4.2",
4
- "description": "Typed TypeScript client for the Pouchy Admin API manage agents, keys, end users, knowledge, skills, channels, schedules, webhooks and credentials headlessly, with a project Admin key.",
3
+ "version": "0.4.4",
4
+ "description": "Typed TypeScript client for the Pouchy Admin API \u2014 manage agents, keys, end users, knowledge, skills, channels, schedules, webhooks and credentials headlessly, with a project Admin key.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "homepage": "https://pouchy.ai/sdk",
@@ -10,22 +10,40 @@
10
10
  "url": "https://github.com/oviswang/Pouchy.git",
11
11
  "directory": "packages/admin-sdk"
12
12
  },
13
- "bugs": { "email": "support@pouchy.ai" },
13
+ "bugs": {
14
+ "email": "support@pouchy.ai"
15
+ },
14
16
  "exports": {
15
17
  ".": {
16
18
  "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.js"
18
21
  }
19
22
  },
20
23
  "main": "./dist/index.js",
21
24
  "types": "./dist/index.d.ts",
22
- "files": ["dist", "README.md", "CHANGELOG.md", "LICENSE"],
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "CHANGELOG.md",
29
+ "LICENSE"
30
+ ],
23
31
  "sideEffects": false,
24
32
  "scripts": {
25
33
  "build": "tsc -p tsconfig.json",
26
34
  "prepublishOnly": "npm run build"
27
35
  },
28
- "devDependencies": { "typescript": "^5.5.0" },
29
- "keywords": ["pouchy", "admin", "api", "sdk", "agent-platform"],
30
- "publishConfig": { "access": "public" }
36
+ "devDependencies": {
37
+ "typescript": "^5.5.0"
38
+ },
39
+ "keywords": [
40
+ "pouchy",
41
+ "admin",
42
+ "api",
43
+ "sdk",
44
+ "agent-platform"
45
+ ],
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
31
49
  }