@pouchy_ai/admin-sdk 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/CHANGELOG.md +40 -0
- package/README.md +19 -5
- package/dist/index.d.ts +137 -1
- package/dist/index.js +17 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@pouchy_ai/admin-sdk` are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.3.0 — 2026-07-13
|
|
6
|
+
|
|
7
|
+
Skill-config parity — a docs-only skill (no `tools:` block) can now be
|
|
8
|
+
installed AND armed entirely via the API, no dashboard step:
|
|
9
|
+
|
|
10
|
+
- **`grantSkill(slug, { freeHttp, grantedDomains? })`** — the free-HTTP grant
|
|
11
|
+
(`PATCH /v1/admin/skills/{slug}`): let the agent drive a skill's API from its
|
|
12
|
+
prose body via `http_request`, bounded to the manifest's `allowed_domains` ∪
|
|
13
|
+
`grantedDomains`. The new def is re-pushed to running instances; the result's
|
|
14
|
+
`reprovisioned` reports how many picked it up. Full flow: `installSkill` →
|
|
15
|
+
`updateAgent(id, { skills: [...] })` → `grantSkill`.
|
|
16
|
+
- **`setSkillRate(slug, ratePerMin)`** — typed convenience over `updateSkill`
|
|
17
|
+
for the per-minute call budget (1..120, or null to restore the default).
|
|
18
|
+
|
|
19
|
+
## 0.2.0 — 2026-07-11
|
|
20
|
+
|
|
21
|
+
Provisioning-parity release (driven by integrator feedback — programmatic
|
|
22
|
+
per-member agent provisioning with no human in the loop):
|
|
23
|
+
|
|
24
|
+
- **`listVoices({ gender?, locale? })`** — the platform voice catalog on the
|
|
25
|
+
admin key (`GET /v1/admin/voice-catalog`). Rows carry `provider` (which agent
|
|
26
|
+
`voices` slot the `providerVoiceId` goes in), plus `gender` / `locales` tags
|
|
27
|
+
for auto-selection. Gender filter matches explicitly tagged rows; locale
|
|
28
|
+
filter matches rows listing it (no locale list = unrestricted).
|
|
29
|
+
- **`rotateKey(keyId, { graceHours? })`** — secret-key rotation with a grace
|
|
30
|
+
window (default 24 h; the old key keeps verifying while you swap envs).
|
|
31
|
+
- **`testWebhook(webhookId)`** / **`redeliverWebhook(deliveryId)`** — send a
|
|
32
|
+
test event; manually re-send a recorded delivery's original body.
|
|
33
|
+
- **`updateWebhook(webhookId, { url?, events? })`** — edit an endpoint in
|
|
34
|
+
place (keeps the signing secret + delivery history) — and
|
|
35
|
+
**`rotateWebhookSecret(webhookId)`** — roll the signing secret (shown once).
|
|
36
|
+
- **`getRecentTraces({ agentId?, sinceHours?, errorsOnly?, limit? })`** — the
|
|
37
|
+
project-wide failed-run browser.
|
|
38
|
+
- **`importUsers({ externalUserIds, agentId?, env? })`** — batch instance
|
|
39
|
+
import (idempotent per external id; never meters MAU).
|
|
40
|
+
- **`exportUser(instanceId)`** — GDPR data-portability export.
|
|
41
|
+
- **`getUserSessions(instanceId)`** / **`getUserTurns(instanceId, sessionId)`**
|
|
42
|
+
— session list + turn-log transcripts.
|
|
43
|
+
- `AuditRow.actor` — audit-log rows now attribute WHO acted.
|
|
44
|
+
|
|
5
45
|
## 0.1.0
|
|
6
46
|
|
|
7
47
|
Initial release. Typed, zero-dependency client for the Pouchy Admin API
|
package/README.md
CHANGED
|
@@ -40,6 +40,19 @@ console.log(key.token); // shown ONCE
|
|
|
40
40
|
// Read this month's usage
|
|
41
41
|
const usage = await admin.getUsage();
|
|
42
42
|
console.log(usage.mau, '/', usage.mauLimit, 'MAU');
|
|
43
|
+
|
|
44
|
+
// Equip an agent with ANY skill — including a docs-only skill.md that has no
|
|
45
|
+
// `tools:` block — entirely via the API:
|
|
46
|
+
const { skill } = await admin.installSkill({
|
|
47
|
+
md: '---\nname: echo-probe\nallowed_domains:\n - postman-echo.com\n---\nGET https://postman-echo.com/get echoes the request.'
|
|
48
|
+
});
|
|
49
|
+
await admin.updateAgent(agent.agentId, { skills: [skill.slug] }); // attach to the agent
|
|
50
|
+
const armed = await admin.grantSkill(skill.slug, {
|
|
51
|
+
freeHttp: true,
|
|
52
|
+
grantedDomains: ['postman-echo.com'] // unioned with the manifest's allowed_domains
|
|
53
|
+
});
|
|
54
|
+
console.log(`armed — ${armed.reprovisioned} running instance(s) updated`);
|
|
55
|
+
// The agent can now drive the API from the skill's prose via http_request.
|
|
43
56
|
```
|
|
44
57
|
|
|
45
58
|
## Options
|
|
@@ -70,15 +83,16 @@ try {
|
|
|
70
83
|
| Area | Methods |
|
|
71
84
|
| --- | --- |
|
|
72
85
|
| Agents | `listAgents` · `createAgent` · `getAgent` · `updateAgent` · `deleteAgent` |
|
|
73
|
-
|
|
|
74
|
-
|
|
|
86
|
+
| Voices | `listVoices({ gender?, locale? })` — catalog for programmatic voice selection |
|
|
87
|
+
| Secret keys | `listKeys` · `createKey` · `revokeKey` · `rotateKey` (24 h grace) |
|
|
88
|
+
| End users | `listUsers` · `setUserSuspended` · `deleteUser` · `getUserWallet` · `getUserTraces` · `importUsers` · `exportUser` · `getUserSessions` · `getUserTurns` |
|
|
75
89
|
| Knowledge | `listKnowledge` · `ingestKnowledge` · `deleteKnowledge` |
|
|
76
|
-
| Skills | `listSkills` · `installSkill` · `updateSkill` · `uninstallSkill` |
|
|
90
|
+
| Skills | `listSkills` · `installSkill` · `updateSkill` · `setSkillRate` · `grantSkill` (free-HTTP) · `uninstallSkill` |
|
|
77
91
|
| Credentials | `listCredentials` · `putCredentials` · `deleteCredentials` |
|
|
78
92
|
| Channels | `listChannels` · `createChannel` · `getChannel` · `updateChannel` · `deleteChannel` |
|
|
79
93
|
| Schedules | `listSchedules` · `createSchedule` · `getSchedule` · `updateSchedule` · `deleteSchedule` |
|
|
80
|
-
| Webhooks | `listWebhooks` · `createWebhook` · `deleteWebhook` |
|
|
81
|
-
| Reporting | `getUsage` · `getBilling` · `getTracesSummary` · `getLogs` · `getProject` · `updateProject` |
|
|
94
|
+
| Webhooks | `listWebhooks` · `createWebhook` · `updateWebhook` · `rotateWebhookSecret` · `deleteWebhook` · `testWebhook` · `redeliverWebhook` |
|
|
95
|
+
| Reporting | `getUsage` · `getBilling` · `getTracesSummary` · `getRecentTraces` · `getLogs` · `getProject` · `updateProject` |
|
|
82
96
|
| Escape hatch | `request(method, path, body?)` — any endpoint not yet typed |
|
|
83
97
|
|
|
84
98
|
## OpenAPI
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const ADMIN_SDK_VERSION = "0.
|
|
1
|
+
export declare const ADMIN_SDK_VERSION = "0.2.0";
|
|
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. */
|
|
@@ -58,6 +58,49 @@ export interface AuditRow {
|
|
|
58
58
|
at: string;
|
|
59
59
|
type: string;
|
|
60
60
|
detail: Record<string, unknown>;
|
|
61
|
+
/** Who performed the action (member email/uid or `admin_key:{keyId}`);
|
|
62
|
+
* absent on system-originated entries. */
|
|
63
|
+
actor?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface CatalogVoice {
|
|
66
|
+
/** Catalog id (std_… / hd_…) — display/reference only. */
|
|
67
|
+
id: string;
|
|
68
|
+
name: string;
|
|
69
|
+
desc: string;
|
|
70
|
+
tier: 'standard' | 'premium';
|
|
71
|
+
/** Which agent `voices` slot the providerVoiceId goes in. */
|
|
72
|
+
provider: 'openAI' | 'elevenLabs';
|
|
73
|
+
/** The value to write into that slot. */
|
|
74
|
+
providerVoiceId: string;
|
|
75
|
+
previewUrl?: string;
|
|
76
|
+
/** Present on tagged rows; filter with listVoices({ gender }). */
|
|
77
|
+
gender?: 'female' | 'male' | 'neutral';
|
|
78
|
+
/** Locales this voice suits; ABSENT = unrestricted. */
|
|
79
|
+
locales?: string[];
|
|
80
|
+
}
|
|
81
|
+
export interface RecentTrace {
|
|
82
|
+
traceId: string;
|
|
83
|
+
sessionId: string;
|
|
84
|
+
agentId?: string;
|
|
85
|
+
instanceId?: string;
|
|
86
|
+
trigger: string;
|
|
87
|
+
startedAt: number;
|
|
88
|
+
durationMs: number;
|
|
89
|
+
tokensIn: number;
|
|
90
|
+
tokensOut: number;
|
|
91
|
+
tokensCached: number;
|
|
92
|
+
toolCount: number;
|
|
93
|
+
ok: boolean;
|
|
94
|
+
spans: {
|
|
95
|
+
name: string;
|
|
96
|
+
kind: string;
|
|
97
|
+
ms: number;
|
|
98
|
+
}[];
|
|
99
|
+
}
|
|
100
|
+
export interface DeliveryOutcome {
|
|
101
|
+
ok: boolean;
|
|
102
|
+
status?: number;
|
|
103
|
+
error?: string;
|
|
61
104
|
}
|
|
62
105
|
/** The Admin API client. Every method returns the parsed JSON body; failures
|
|
63
106
|
* throw AdminApiError. */
|
|
@@ -97,6 +140,18 @@ export interface AdminClient {
|
|
|
97
140
|
revokeKey(keyId: string): Promise<{
|
|
98
141
|
revoked: boolean;
|
|
99
142
|
}>;
|
|
143
|
+
/** Rotate a secret key: mints the replacement (plaintext returned ONCE);
|
|
144
|
+
* the old key keeps verifying for the grace window (default 24 h). */
|
|
145
|
+
rotateKey(keyId: string, opts?: {
|
|
146
|
+
graceHours?: number;
|
|
147
|
+
}): Promise<{
|
|
148
|
+
key: string;
|
|
149
|
+
record: SecretKey;
|
|
150
|
+
old: {
|
|
151
|
+
keyId: string;
|
|
152
|
+
graceUntil: string | null;
|
|
153
|
+
};
|
|
154
|
+
}>;
|
|
100
155
|
listUsers(params?: {
|
|
101
156
|
q?: string;
|
|
102
157
|
limit?: number;
|
|
@@ -116,6 +171,31 @@ export interface AdminClient {
|
|
|
116
171
|
getUserTraces(instanceId: string): Promise<{
|
|
117
172
|
traces: unknown[];
|
|
118
173
|
}>;
|
|
174
|
+
/** Batch-import end users from your own id list (idempotent per external id;
|
|
175
|
+
* never meters MAU — imported users bill only when they actually mint). */
|
|
176
|
+
importUsers(input: {
|
|
177
|
+
externalUserIds: string[] | string;
|
|
178
|
+
agentId?: string;
|
|
179
|
+
env?: Env;
|
|
180
|
+
}): Promise<{
|
|
181
|
+
created: number;
|
|
182
|
+
skipped: number;
|
|
183
|
+
invalid: string[];
|
|
184
|
+
}>;
|
|
185
|
+
/** GDPR data-portability export: registry, character state, memories, contacts. */
|
|
186
|
+
exportUser(instanceId: string): Promise<Record<string, unknown>>;
|
|
187
|
+
/** The instance's companion sessions, most recently active first. */
|
|
188
|
+
getUserSessions(instanceId: string, params?: {
|
|
189
|
+
limit?: number;
|
|
190
|
+
}): Promise<{
|
|
191
|
+
sessions: unknown[];
|
|
192
|
+
}>;
|
|
193
|
+
/** A session's turn log (oldest first, with per-turn trace meta). */
|
|
194
|
+
getUserTurns(instanceId: string, sessionId: string, params?: {
|
|
195
|
+
limit?: number;
|
|
196
|
+
}): Promise<{
|
|
197
|
+
turns: unknown[];
|
|
198
|
+
}>;
|
|
119
199
|
listKnowledge(): Promise<{
|
|
120
200
|
docs: unknown[];
|
|
121
201
|
}>;
|
|
@@ -153,6 +233,24 @@ export interface AdminClient {
|
|
|
153
233
|
slug: string;
|
|
154
234
|
};
|
|
155
235
|
}>;
|
|
236
|
+
/** Set a skill's per-minute call budget (1..120; null restores the default). */
|
|
237
|
+
setSkillRate(slug: string, ratePerMin: number | null): Promise<{
|
|
238
|
+
ratePerMin: number | null;
|
|
239
|
+
}>;
|
|
240
|
+
/** Free-HTTP grant (universal import): let the agent drive this skill's API
|
|
241
|
+
* from its prose body via `http_request`, bounded to the manifest's
|
|
242
|
+
* `allowed_domains` ∪ `grantedDomains`. This is how a docs-only skill
|
|
243
|
+
* (no `tools:` block) becomes runnable — install it, attach it to an agent
|
|
244
|
+
* (`updateAgent(id, { skills: [...] })`), then grant it here. The new def is
|
|
245
|
+
* re-pushed to running instances; `reprovisioned` is how many were updated. */
|
|
246
|
+
grantSkill(slug: string, grant: {
|
|
247
|
+
freeHttp: boolean;
|
|
248
|
+
grantedDomains?: string[];
|
|
249
|
+
}): Promise<{
|
|
250
|
+
freeHttp: boolean;
|
|
251
|
+
grantedDomains: string[];
|
|
252
|
+
reprovisioned: number;
|
|
253
|
+
}>;
|
|
156
254
|
uninstallSkill(slug: string): Promise<{
|
|
157
255
|
deleted: boolean;
|
|
158
256
|
}>;
|
|
@@ -226,6 +324,26 @@ export interface AdminClient {
|
|
|
226
324
|
deleteWebhook(webhookId: string): Promise<{
|
|
227
325
|
deleted: boolean;
|
|
228
326
|
}>;
|
|
327
|
+
/** Edit url/events in place (keeps the signing secret + delivery history). */
|
|
328
|
+
updateWebhook(webhookId: string, patch: {
|
|
329
|
+
url?: string;
|
|
330
|
+
events?: string[];
|
|
331
|
+
}): Promise<{
|
|
332
|
+
webhook: {
|
|
333
|
+
webhookId: string;
|
|
334
|
+
};
|
|
335
|
+
}>;
|
|
336
|
+
/** Roll the signing secret (returned ONCE; no dual-secret grace). */
|
|
337
|
+
rotateWebhookSecret(webhookId: string): Promise<{
|
|
338
|
+
webhook: {
|
|
339
|
+
webhookId: string;
|
|
340
|
+
secret: string;
|
|
341
|
+
};
|
|
342
|
+
}>;
|
|
343
|
+
/** Send a clearly-marked test event to this endpoint (ignores subscriptions). */
|
|
344
|
+
testWebhook(webhookId: string): Promise<DeliveryOutcome>;
|
|
345
|
+
/** Manually re-send a recorded delivery's original body, re-signed. */
|
|
346
|
+
redeliverWebhook(deliveryId: string): Promise<DeliveryOutcome>;
|
|
229
347
|
getUsage(): Promise<MonthUsage>;
|
|
230
348
|
getBilling(): Promise<{
|
|
231
349
|
plan: string;
|
|
@@ -236,6 +354,24 @@ export interface AdminClient {
|
|
|
236
354
|
agentId?: string;
|
|
237
355
|
sinceHours?: number;
|
|
238
356
|
}): Promise<Record<string, unknown>>;
|
|
357
|
+
/** Recent run rows project-wide (the failed-run browser). */
|
|
358
|
+
getRecentTraces(params?: {
|
|
359
|
+
agentId?: string;
|
|
360
|
+
sinceHours?: number;
|
|
361
|
+
errorsOnly?: boolean;
|
|
362
|
+
limit?: number;
|
|
363
|
+
}): Promise<{
|
|
364
|
+
traces: RecentTrace[];
|
|
365
|
+
}>;
|
|
366
|
+
/** Enabled platform voices for programmatic provisioning. Filter by gender
|
|
367
|
+
* (explicitly tagged rows only) and/or locale (rows listing it, or with no
|
|
368
|
+
* locale list = unrestricted). */
|
|
369
|
+
listVoices(params?: {
|
|
370
|
+
gender?: 'female' | 'male' | 'neutral';
|
|
371
|
+
locale?: string;
|
|
372
|
+
}): Promise<{
|
|
373
|
+
voices: CatalogVoice[];
|
|
374
|
+
}>;
|
|
239
375
|
getLogs(params?: {
|
|
240
376
|
limit?: number;
|
|
241
377
|
}): Promise<{
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
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.
|
|
11
|
+
export const ADMIN_SDK_VERSION = '0.2.0';
|
|
12
12
|
export const DEFAULT_BASE_URL = 'https://pouchy.ai/v1/admin';
|
|
13
13
|
/** Thrown on any non-2xx response. `status` is the HTTP status; `message` is the
|
|
14
14
|
* server's `error` string when present. */
|
|
@@ -58,17 +58,27 @@ export function createAdminClient(opts) {
|
|
|
58
58
|
listKeys: () => request('GET', '/keys'),
|
|
59
59
|
createKey: (input) => request('POST', '/keys', input),
|
|
60
60
|
revokeKey: (id) => request('DELETE', `/keys/${encodeURIComponent(id)}`),
|
|
61
|
+
rotateKey: (id, opts = {}) => request('POST', `/keys/${encodeURIComponent(id)}/rotate`, opts),
|
|
61
62
|
listUsers: (params = {}) => request('GET', `/users${qs(params)}`),
|
|
62
63
|
setUserSuspended: (id, suspended) => request('PATCH', `/users/${encodeURIComponent(id)}`, { suspended }),
|
|
63
64
|
deleteUser: (id) => request('DELETE', `/users/${encodeURIComponent(id)}`),
|
|
64
65
|
getUserWallet: (id) => request('GET', `/users/${encodeURIComponent(id)}/wallet`),
|
|
65
66
|
getUserTraces: (id) => request('GET', `/users/${encodeURIComponent(id)}/traces`),
|
|
67
|
+
importUsers: (input) => request('POST', '/users/import', input),
|
|
68
|
+
exportUser: (id) => request('GET', `/users/${encodeURIComponent(id)}/export`),
|
|
69
|
+
getUserSessions: (id, params = {}) => request('GET', `/users/${encodeURIComponent(id)}/sessions${qs(params)}`),
|
|
70
|
+
getUserTurns: (id, sessionId, params = {}) => request('GET', `/users/${encodeURIComponent(id)}/sessions/${encodeURIComponent(sessionId)}/turns${qs(params)}`),
|
|
66
71
|
listKnowledge: () => request('GET', '/knowledge'),
|
|
67
72
|
ingestKnowledge: (input) => request('POST', '/knowledge', input),
|
|
68
73
|
deleteKnowledge: (id) => request('DELETE', `/knowledge/${encodeURIComponent(id)}`),
|
|
69
74
|
listSkills: () => request('GET', '/skills'),
|
|
70
75
|
installSkill: (input) => request('POST', '/skills', input),
|
|
71
76
|
updateSkill: (slug, patch) => request('PATCH', `/skills/${encodeURIComponent(slug)}`, patch),
|
|
77
|
+
setSkillRate: (slug, ratePerMin) => request('PATCH', `/skills/${encodeURIComponent(slug)}`, { ratePerMin }),
|
|
78
|
+
grantSkill: (slug, grant) => request('PATCH', `/skills/${encodeURIComponent(slug)}`, {
|
|
79
|
+
freeHttp: grant.freeHttp,
|
|
80
|
+
grantedDomains: grant.grantedDomains ?? []
|
|
81
|
+
}),
|
|
72
82
|
uninstallSkill: (slug) => request('DELETE', `/skills/${encodeURIComponent(slug)}`),
|
|
73
83
|
listCredentials: () => request('GET', '/credentials'),
|
|
74
84
|
putCredentials: (input) => request('POST', '/credentials', input),
|
|
@@ -86,9 +96,15 @@ export function createAdminClient(opts) {
|
|
|
86
96
|
listWebhooks: () => request('GET', '/webhooks'),
|
|
87
97
|
createWebhook: (input) => request('POST', '/webhooks', input),
|
|
88
98
|
deleteWebhook: (id) => request('DELETE', `/webhooks/${encodeURIComponent(id)}`),
|
|
99
|
+
updateWebhook: (id, patch) => request('PATCH', `/webhooks/${encodeURIComponent(id)}`, patch),
|
|
100
|
+
rotateWebhookSecret: (id) => request('POST', `/webhooks/${encodeURIComponent(id)}/rotate-secret`),
|
|
101
|
+
testWebhook: (id) => request('POST', `/webhooks/${encodeURIComponent(id)}/test`),
|
|
102
|
+
redeliverWebhook: (id) => request('POST', `/webhooks/deliveries/${encodeURIComponent(id)}/redeliver`),
|
|
89
103
|
getUsage: () => request('GET', '/usage'),
|
|
90
104
|
getBilling: () => request('GET', '/billing'),
|
|
91
105
|
getTracesSummary: (params = {}) => request('GET', `/traces/summary${qs(params)}`),
|
|
106
|
+
getRecentTraces: (params = {}) => request('GET', `/traces/recent${qs({ ...params, errorsOnly: params.errorsOnly ? '1' : undefined })}`),
|
|
107
|
+
listVoices: (params = {}) => request('GET', `/voice-catalog${qs(params)}`),
|
|
92
108
|
getLogs: (params = {}) => request('GET', `/logs${qs(params)}`),
|
|
93
109
|
getProject: () => request('GET', '/project'),
|
|
94
110
|
updateProject: (patch) => request('PATCH', '/project', patch),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pouchy_ai/admin-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
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.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|