@pouchy_ai/admin-sdk 0.4.3 → 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 +15 -0
- package/README.md +5 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +24 -9
- package/package.json +24 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
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
|
+
|
|
5
20
|
## 0.4.3 — 2026-07-17
|
|
6
21
|
|
|
7
22
|
- Packaging only: added the `default` export condition beside `import` in 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
|
|
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';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const ADMIN_SDK_VERSION = "0.4.
|
|
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.
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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.
|
|
4
|
-
"description": "Typed TypeScript client for the Pouchy Admin API
|
|
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,7 +10,9 @@
|
|
|
10
10
|
"url": "https://github.com/oviswang/Pouchy.git",
|
|
11
11
|
"directory": "packages/admin-sdk"
|
|
12
12
|
},
|
|
13
|
-
"bugs": {
|
|
13
|
+
"bugs": {
|
|
14
|
+
"email": "support@pouchy.ai"
|
|
15
|
+
},
|
|
14
16
|
"exports": {
|
|
15
17
|
".": {
|
|
16
18
|
"types": "./dist/index.d.ts",
|
|
@@ -20,13 +22,28 @@
|
|
|
20
22
|
},
|
|
21
23
|
"main": "./dist/index.js",
|
|
22
24
|
"types": "./dist/index.d.ts",
|
|
23
|
-
"files": [
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"CHANGELOG.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
24
31
|
"sideEffects": false,
|
|
25
32
|
"scripts": {
|
|
26
33
|
"build": "tsc -p tsconfig.json",
|
|
27
34
|
"prepublishOnly": "npm run build"
|
|
28
35
|
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
|
|
31
|
-
|
|
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
|
+
}
|
|
32
49
|
}
|