@pouchy_ai/admin-sdk 0.1.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 ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@pouchy_ai/admin-sdk` are documented here.
4
+
5
+ ## 0.1.0
6
+
7
+ Initial release. Typed, zero-dependency client for the Pouchy Admin API
8
+ (`https://pouchy.ai/v1/admin`):
9
+
10
+ - `createAdminClient({ adminKey, baseUrl?, fetch? })` → typed methods for agents,
11
+ secret keys, end users, knowledge, skills, credentials, channels, schedules,
12
+ webhooks, plus usage / billing / traces / audit-log / project reporting.
13
+ - `AdminApiError` (with `status`) on any non-2xx response.
14
+ - `request(method, path, body?)` escape hatch for endpoints not yet typed.
15
+ - Pairs with the machine-readable spec at `GET /v1/admin/openapi` (OpenAPI 3.1).
package/LICENSE ADDED
@@ -0,0 +1,41 @@
1
+ Pouchy Companion SDK License
2
+ Copyright (c) 2026 Pouchy.ai. All Rights Reserved.
3
+
4
+ This license governs use of the "@pouchy_ai/companion-sdk" software package (the
5
+ "SDK") as published to the npm registry. The SDK is proprietary software owned
6
+ by Pouchy.ai. By installing, copying, or using the SDK you agree to these terms.
7
+
8
+ 1. GRANT. Subject to these terms, Pouchy.ai grants you a worldwide,
9
+ non-exclusive, non-transferable, royalty-free, revocable license to install
10
+ and use the SDK, as distributed, solely to build and operate applications
11
+ that integrate with Pouchy.ai's official services and APIs.
12
+
13
+ 2. RESTRICTIONS. Except to the extent a restriction below is prohibited by
14
+ applicable law, you may not:
15
+ (a) modify, adapt, or create derivative works of the SDK's source for
16
+ redistribution;
17
+ (b) redistribute, sublicense, sell, rent, or lease the SDK as a standalone
18
+ product, or republish it under a different name;
19
+ (c) reverse engineer, decompile, or disassemble the SDK except to the extent
20
+ necessary for interoperability and expressly permitted by law;
21
+ (d) use the SDK to build or operate a service that competes with Pouchy.ai's
22
+ services, or to access Pouchy.ai's services in violation of their terms;
23
+ (e) remove or alter any copyright, trademark, or other proprietary notices.
24
+
25
+ 3. RESERVATION OF RIGHTS. All rights not expressly granted are reserved by
26
+ Pouchy.ai. No rights are granted in Pouchy.ai's source repositories,
27
+ trademarks, or services beyond what is needed to use the SDK as described.
28
+
29
+ 4. TERMINATION. This license terminates automatically if you breach it. On
30
+ termination you must stop using and delete all copies of the SDK.
31
+
32
+ 5. NO WARRANTY. THE SDK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
35
+
36
+ 6. LIMITATION OF LIABILITY. IN NO EVENT SHALL POUCHY.AI BE LIABLE FOR ANY CLAIM,
37
+ DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR
38
+ OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SDK OR THE USE OR
39
+ OTHER DEALINGS IN THE SDK.
40
+
41
+ For any other use, or for written permission, contact legal@pouchy.ai.
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # @pouchy_ai/admin-sdk
2
+
3
+ Typed TypeScript client for the **Pouchy Admin API** — everything the dashboard
4
+ does, headless. Manage agents, secret keys, end users, knowledge, skills,
5
+ channels, schedules, webhooks and credentials; read usage, billing, traces and
6
+ audit logs. Zero runtime dependencies (uses the global `fetch`).
7
+
8
+ The Admin API is authenticated with a **project-scoped Admin key**
9
+ (`pchy_admin_…`, from the dashboard **Admin Keys** page). The project is implied
10
+ by the key — you never pass a project id.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm i @pouchy_ai/admin-sdk
16
+ ```
17
+
18
+ ## Quickstart
19
+
20
+ ```ts
21
+ import { createAdminClient } from '@pouchy_ai/admin-sdk';
22
+
23
+ const admin = createAdminClient({ adminKey: process.env.POUCHY_ADMIN_KEY! });
24
+
25
+ // List agents
26
+ const { agents } = await admin.listAgents();
27
+
28
+ // Create + publish an agent
29
+ const { agent } = await admin.createAgent({
30
+ name: 'Support Bot',
31
+ archetype: 'support',
32
+ systemPrompt: 'You are a concise, friendly support agent.'
33
+ });
34
+ await admin.updateAgent(agent.agentId, { status: 'published' });
35
+
36
+ // Mint a secret key for your backend to open end-user sessions with
37
+ const { key } = await admin.createKey({ label: 'prod-backend', env: 'live' });
38
+ console.log(key.token); // shown ONCE
39
+
40
+ // Read this month's usage
41
+ const usage = await admin.getUsage();
42
+ console.log(usage.mau, '/', usage.mauLimit, 'MAU');
43
+ ```
44
+
45
+ ## Options
46
+
47
+ ```ts
48
+ createAdminClient({
49
+ adminKey: 'pchy_admin_…', // required
50
+ baseUrl: 'https://pouchy.ai/v1/admin', // optional (self-host / staging)
51
+ fetch: myFetch // optional (Node <18, or tests)
52
+ });
53
+ ```
54
+
55
+ ## Errors
56
+
57
+ Every method throws `AdminApiError` on a non-2xx response:
58
+
59
+ ```ts
60
+ import { AdminApiError } from '@pouchy_ai/admin-sdk';
61
+ try {
62
+ await admin.getAgent('nope');
63
+ } catch (e) {
64
+ if (e instanceof AdminApiError) console.error(e.status, e.message); // 404 "unknown agent"
65
+ }
66
+ ```
67
+
68
+ ## Surface
69
+
70
+ | Area | Methods |
71
+ | --- | --- |
72
+ | Agents | `listAgents` · `createAgent` · `getAgent` · `updateAgent` · `deleteAgent` |
73
+ | Secret keys | `listKeys` · `createKey` · `revokeKey` |
74
+ | End users | `listUsers` · `setUserSuspended` · `deleteUser` · `getUserWallet` · `getUserTraces` |
75
+ | Knowledge | `listKnowledge` · `ingestKnowledge` · `deleteKnowledge` |
76
+ | Skills | `listSkills` · `installSkill` · `updateSkill` · `uninstallSkill` |
77
+ | Credentials | `listCredentials` · `putCredentials` · `deleteCredentials` |
78
+ | Channels | `listChannels` · `createChannel` · `getChannel` · `updateChannel` · `deleteChannel` |
79
+ | Schedules | `listSchedules` · `createSchedule` · `getSchedule` · `updateSchedule` · `deleteSchedule` |
80
+ | Webhooks | `listWebhooks` · `createWebhook` · `deleteWebhook` |
81
+ | Reporting | `getUsage` · `getBilling` · `getTracesSummary` · `getLogs` · `getProject` · `updateProject` |
82
+ | Escape hatch | `request(method, path, body?)` — any endpoint not yet typed |
83
+
84
+ ## OpenAPI
85
+
86
+ The machine-readable contract is served at **`GET https://pouchy.ai/v1/admin/openapi`**
87
+ (OpenAPI 3.1, public). Import it into Postman / Swagger UI, or generate a client
88
+ in any other language with `openapi-generator`.
89
+
90
+ ## License
91
+
92
+ SEE LICENSE IN LICENSE.
@@ -0,0 +1,262 @@
1
+ export declare const ADMIN_SDK_VERSION = "0.1.0";
2
+ export declare const DEFAULT_BASE_URL = "https://pouchy.ai/v1/admin";
3
+ export interface AdminClientOptions {
4
+ /** A project Admin key (`pchy_admin_…`) from the dashboard Admin Keys page. */
5
+ adminKey: string;
6
+ /** Override the API base (self-host / staging). Default production. */
7
+ baseUrl?: string;
8
+ /** Inject a fetch impl (Node <18, or for tests). Default global fetch. */
9
+ fetch?: typeof fetch;
10
+ }
11
+ /** Thrown on any non-2xx response. `status` is the HTTP status; `message` is the
12
+ * server's `error` string when present. */
13
+ export declare class AdminApiError extends Error {
14
+ status: number;
15
+ constructor(message: string, status: number);
16
+ }
17
+ export type Env = 'live' | 'test';
18
+ export type AgentStatus = 'draft' | 'published';
19
+ export type ModelTier = 'standard' | 'pro';
20
+ export interface Agent {
21
+ agentId: string;
22
+ name: string;
23
+ archetype: string;
24
+ systemPrompt: string;
25
+ status?: AgentStatus;
26
+ modelTier?: ModelTier;
27
+ templateRev: number;
28
+ createdAt: string;
29
+ [k: string]: unknown;
30
+ }
31
+ export interface SecretKey {
32
+ keyId: string;
33
+ label: string;
34
+ env: Env;
35
+ prefix: string;
36
+ createdAt: string;
37
+ lastUsedAt: string | null;
38
+ revokedAt: string | null;
39
+ }
40
+ export interface Instance {
41
+ instanceId: string;
42
+ externalUserId: string;
43
+ agentId: string;
44
+ createdAt: string;
45
+ lastActiveAt: string;
46
+ suspended?: boolean;
47
+ }
48
+ export interface MonthUsage {
49
+ month: string;
50
+ mau: number;
51
+ mauLimit: number;
52
+ sessions: number;
53
+ tokensIn: number;
54
+ tokensOut: number;
55
+ [k: string]: unknown;
56
+ }
57
+ export interface AuditRow {
58
+ at: string;
59
+ type: string;
60
+ detail: Record<string, unknown>;
61
+ }
62
+ /** The Admin API client. Every method returns the parsed JSON body; failures
63
+ * throw AdminApiError. */
64
+ export interface AdminClient {
65
+ listAgents(): Promise<{
66
+ agents: Agent[];
67
+ }>;
68
+ createAgent(input: {
69
+ name: string;
70
+ archetype: string;
71
+ systemPrompt?: string;
72
+ } & Record<string, unknown>): Promise<{
73
+ agent: Agent;
74
+ }>;
75
+ getAgent(agentId: string): Promise<{
76
+ agent: Agent;
77
+ }>;
78
+ updateAgent(agentId: string, patch: Partial<Agent> & Record<string, unknown>): Promise<{
79
+ agent: Agent;
80
+ }>;
81
+ deleteAgent(agentId: string): Promise<{
82
+ deleted: boolean;
83
+ }>;
84
+ listKeys(): Promise<{
85
+ keys: SecretKey[];
86
+ }>;
87
+ createKey(input: {
88
+ label?: string;
89
+ env?: Env;
90
+ }): Promise<{
91
+ key: {
92
+ keyId: string;
93
+ token: string;
94
+ env: Env;
95
+ };
96
+ }>;
97
+ revokeKey(keyId: string): Promise<{
98
+ revoked: boolean;
99
+ }>;
100
+ listUsers(params?: {
101
+ q?: string;
102
+ limit?: number;
103
+ }): Promise<{
104
+ users: Instance[];
105
+ }>;
106
+ setUserSuspended(instanceId: string, suspended: boolean): Promise<{
107
+ suspended: boolean;
108
+ }>;
109
+ deleteUser(instanceId: string): Promise<{
110
+ deleted: boolean;
111
+ }>;
112
+ getUserWallet(instanceId: string): Promise<{
113
+ balance: number;
114
+ address: string;
115
+ }>;
116
+ getUserTraces(instanceId: string): Promise<{
117
+ traces: unknown[];
118
+ }>;
119
+ listKnowledge(): Promise<{
120
+ docs: unknown[];
121
+ }>;
122
+ ingestKnowledge(input: {
123
+ title?: string;
124
+ text?: string;
125
+ url?: string;
126
+ }): Promise<{
127
+ doc: {
128
+ docId: string;
129
+ chunks: number;
130
+ };
131
+ }>;
132
+ deleteKnowledge(docId: string): Promise<{
133
+ deleted: boolean;
134
+ }>;
135
+ listSkills(): Promise<{
136
+ skills: unknown[];
137
+ }>;
138
+ installSkill(input: {
139
+ md?: string;
140
+ url?: string;
141
+ mcpUrl?: string;
142
+ openapi?: string;
143
+ openapiUrl?: string;
144
+ slug?: string;
145
+ }): Promise<{
146
+ skill: {
147
+ slug: string;
148
+ version: number;
149
+ };
150
+ }>;
151
+ updateSkill(slug: string, patch: Record<string, unknown>): Promise<{
152
+ skill: {
153
+ slug: string;
154
+ };
155
+ }>;
156
+ uninstallSkill(slug: string): Promise<{
157
+ deleted: boolean;
158
+ }>;
159
+ listCredentials(): Promise<{
160
+ credentials: unknown[];
161
+ }>;
162
+ putCredentials(input: {
163
+ skill: string;
164
+ credentials: Record<string, unknown>;
165
+ }): Promise<{
166
+ ok: boolean;
167
+ }>;
168
+ deleteCredentials(skill: string): Promise<{
169
+ deleted: boolean;
170
+ }>;
171
+ listChannels(): Promise<{
172
+ channels: unknown[];
173
+ }>;
174
+ createChannel(input: {
175
+ type: string;
176
+ agentId: string;
177
+ config?: Record<string, unknown>;
178
+ }): Promise<{
179
+ channel: {
180
+ id: string;
181
+ };
182
+ inboundUrl: string;
183
+ }>;
184
+ getChannel(channelId: string): Promise<{
185
+ channel: unknown;
186
+ }>;
187
+ updateChannel(channelId: string, patch: Record<string, unknown>): Promise<{
188
+ channel: unknown;
189
+ }>;
190
+ deleteChannel(channelId: string): Promise<{
191
+ deleted: boolean;
192
+ }>;
193
+ listSchedules(): Promise<{
194
+ schedules: unknown[];
195
+ }>;
196
+ createSchedule(input: {
197
+ agentId: string;
198
+ cron: string;
199
+ prompt?: string;
200
+ }): Promise<{
201
+ schedule: {
202
+ scheduleId: string;
203
+ };
204
+ }>;
205
+ getSchedule(scheduleId: string): Promise<{
206
+ schedule: unknown;
207
+ }>;
208
+ updateSchedule(scheduleId: string, patch: Record<string, unknown>): Promise<{
209
+ schedule: unknown;
210
+ }>;
211
+ deleteSchedule(scheduleId: string): Promise<{
212
+ deleted: boolean;
213
+ }>;
214
+ listWebhooks(): Promise<{
215
+ webhooks: unknown[];
216
+ }>;
217
+ createWebhook(input: {
218
+ url: string;
219
+ events?: string[];
220
+ }): Promise<{
221
+ webhook: {
222
+ webhookId: string;
223
+ secret: string;
224
+ };
225
+ }>;
226
+ deleteWebhook(webhookId: string): Promise<{
227
+ deleted: boolean;
228
+ }>;
229
+ getUsage(): Promise<MonthUsage>;
230
+ getBilling(): Promise<{
231
+ plan: string;
232
+ mauLimit: number;
233
+ periodEnd?: string;
234
+ }>;
235
+ getTracesSummary(params?: {
236
+ agentId?: string;
237
+ sinceHours?: number;
238
+ }): Promise<Record<string, unknown>>;
239
+ getLogs(params?: {
240
+ limit?: number;
241
+ }): Promise<{
242
+ logs: AuditRow[];
243
+ }>;
244
+ getProject(): Promise<{
245
+ project: {
246
+ projectId: string;
247
+ name: string;
248
+ archived?: boolean;
249
+ };
250
+ }>;
251
+ updateProject(patch: {
252
+ name?: string;
253
+ archived?: boolean;
254
+ }): Promise<{
255
+ project: {
256
+ projectId: string;
257
+ };
258
+ }>;
259
+ /** Escape hatch: call any endpoint the typed methods don't cover yet. */
260
+ request<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
261
+ }
262
+ export declare function createAdminClient(opts: AdminClientOptions): AdminClient;
package/dist/index.js ADDED
@@ -0,0 +1,97 @@
1
+ // @pouchy_ai/admin-sdk — a tiny, zero-dependency TypeScript client for the
2
+ // Pouchy Admin API (https://pouchy.ai/v1/admin). Everything the dashboard does,
3
+ // headless: manage agents, keys, end users, knowledge, skills, channels,
4
+ // schedules, webhooks, credentials — plus read usage, billing, traces and audit
5
+ // logs. Authenticate with a project-scoped Admin key (the project is implied by
6
+ // the key). The machine-readable contract is at GET /v1/admin/openapi.
7
+ //
8
+ // import { createAdminClient } from '@pouchy_ai/admin-sdk';
9
+ // const admin = createAdminClient({ adminKey: process.env.POUCHY_ADMIN_KEY! });
10
+ // const { agents } = await admin.listAgents();
11
+ export const ADMIN_SDK_VERSION = '0.1.0';
12
+ export const DEFAULT_BASE_URL = 'https://pouchy.ai/v1/admin';
13
+ /** Thrown on any non-2xx response. `status` is the HTTP status; `message` is the
14
+ * server's `error` string when present. */
15
+ export class AdminApiError extends Error {
16
+ status;
17
+ constructor(message, status) {
18
+ super(message);
19
+ this.name = 'AdminApiError';
20
+ this.status = status;
21
+ }
22
+ }
23
+ function qs(params) {
24
+ const u = new URLSearchParams();
25
+ for (const [k, v] of Object.entries(params))
26
+ if (v != null)
27
+ u.set(k, String(v));
28
+ const s = u.toString();
29
+ return s ? `?${s}` : '';
30
+ }
31
+ export function createAdminClient(opts) {
32
+ if (!opts.adminKey)
33
+ throw new AdminApiError('adminKey is required', 0);
34
+ const base = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
35
+ const f = opts.fetch ?? globalThis.fetch;
36
+ if (!f)
37
+ throw new AdminApiError('no fetch available — pass opts.fetch on Node <18', 0);
38
+ 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
+ });
47
+ const data = (await res.json().catch(() => ({})));
48
+ if (!res.ok)
49
+ throw new AdminApiError(data?.error ?? `HTTP ${res.status}`, res.status);
50
+ return data;
51
+ }
52
+ return {
53
+ listAgents: () => request('GET', '/agents'),
54
+ createAgent: (input) => request('POST', '/agents', input),
55
+ getAgent: (id) => request('GET', `/agents/${encodeURIComponent(id)}`),
56
+ updateAgent: (id, patch) => request('PATCH', `/agents/${encodeURIComponent(id)}`, patch),
57
+ deleteAgent: (id) => request('DELETE', `/agents/${encodeURIComponent(id)}`),
58
+ listKeys: () => request('GET', '/keys'),
59
+ createKey: (input) => request('POST', '/keys', input),
60
+ revokeKey: (id) => request('DELETE', `/keys/${encodeURIComponent(id)}`),
61
+ listUsers: (params = {}) => request('GET', `/users${qs(params)}`),
62
+ setUserSuspended: (id, suspended) => request('PATCH', `/users/${encodeURIComponent(id)}`, { suspended }),
63
+ deleteUser: (id) => request('DELETE', `/users/${encodeURIComponent(id)}`),
64
+ getUserWallet: (id) => request('GET', `/users/${encodeURIComponent(id)}/wallet`),
65
+ getUserTraces: (id) => request('GET', `/users/${encodeURIComponent(id)}/traces`),
66
+ listKnowledge: () => request('GET', '/knowledge'),
67
+ ingestKnowledge: (input) => request('POST', '/knowledge', input),
68
+ deleteKnowledge: (id) => request('DELETE', `/knowledge/${encodeURIComponent(id)}`),
69
+ listSkills: () => request('GET', '/skills'),
70
+ installSkill: (input) => request('POST', '/skills', input),
71
+ updateSkill: (slug, patch) => request('PATCH', `/skills/${encodeURIComponent(slug)}`, patch),
72
+ uninstallSkill: (slug) => request('DELETE', `/skills/${encodeURIComponent(slug)}`),
73
+ listCredentials: () => request('GET', '/credentials'),
74
+ putCredentials: (input) => request('POST', '/credentials', input),
75
+ deleteCredentials: (skill) => request('DELETE', `/credentials/${encodeURIComponent(skill)}`),
76
+ listChannels: () => request('GET', '/channels'),
77
+ createChannel: (input) => request('POST', '/channels', input),
78
+ getChannel: (id) => request('GET', `/channels/${encodeURIComponent(id)}`),
79
+ updateChannel: (id, patch) => request('PATCH', `/channels/${encodeURIComponent(id)}`, patch),
80
+ deleteChannel: (id) => request('DELETE', `/channels/${encodeURIComponent(id)}`),
81
+ listSchedules: () => request('GET', '/schedules'),
82
+ createSchedule: (input) => request('POST', '/schedules', input),
83
+ getSchedule: (id) => request('GET', `/schedules/${encodeURIComponent(id)}`),
84
+ updateSchedule: (id, patch) => request('PATCH', `/schedules/${encodeURIComponent(id)}`, patch),
85
+ deleteSchedule: (id) => request('DELETE', `/schedules/${encodeURIComponent(id)}`),
86
+ listWebhooks: () => request('GET', '/webhooks'),
87
+ createWebhook: (input) => request('POST', '/webhooks', input),
88
+ deleteWebhook: (id) => request('DELETE', `/webhooks/${encodeURIComponent(id)}`),
89
+ getUsage: () => request('GET', '/usage'),
90
+ getBilling: () => request('GET', '/billing'),
91
+ getTracesSummary: (params = {}) => request('GET', `/traces/summary${qs(params)}`),
92
+ getLogs: (params = {}) => request('GET', `/logs${qs(params)}`),
93
+ getProject: () => request('GET', '/project'),
94
+ updateProject: (patch) => request('PATCH', '/project', patch),
95
+ request
96
+ };
97
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@pouchy_ai/admin-sdk",
3
+ "version": "0.1.0",
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
+ "type": "module",
6
+ "license": "SEE LICENSE IN LICENSE",
7
+ "homepage": "https://pouchy.ai/sdk",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/oviswang/Pouchy.git",
11
+ "directory": "packages/admin-sdk"
12
+ },
13
+ "bugs": { "email": "support@pouchy.ai" },
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ }
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": ["dist", "README.md", "CHANGELOG.md", "LICENSE"],
23
+ "sideEffects": false,
24
+ "scripts": {
25
+ "build": "tsc -p tsconfig.json",
26
+ "prepublishOnly": "npm run build"
27
+ },
28
+ "devDependencies": { "typescript": "^5.5.0" },
29
+ "keywords": ["pouchy", "admin", "api", "sdk", "agent-platform"],
30
+ "publishConfig": { "access": "public" }
31
+ }