@pouchy_ai/admin-sdk 0.14.0 → 0.15.1

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,49 @@
2
2
 
3
3
  All notable changes to `@pouchy_ai/admin-sdk` are documented here.
4
4
 
5
+ ## 0.15.1 — 2026-08-03
6
+
7
+ - **Docs fix: `MonthUsage.mauLimit` prescribed a call that does not compile.**
8
+ 0.15.0 documented the account-scope workaround as
9
+ `getUsageHistory({ scope: 'account' })`. `scope` is a **response**
10
+ discriminant the server decides — `GET /usage/history` reads only `months` —
11
+ so the literal fails excess-property checking against the method's own
12
+ declared `{ months?: number }`, and casting past it just appends a query
13
+ parameter nothing reads. The advice is now the call that works: invoke
14
+ `getUsageHistory()` and read the returned `scope`, which is `'account'`
15
+ whenever the server can resolve one and `'project'` when it cannot. Note the
16
+ consequence the old wording hid — there is no way to *force* account scope, so
17
+ a `'project'` series on a multi-project account carries the same
18
+ understatement as `mau` itself.
19
+
20
+ No type or runtime change; every 0.15.0 signature is unchanged.
21
+
22
+ A drift gate now checks every documented `method({ key … })` example in the
23
+ source and the README against the keys that method actually declares, so the
24
+ next piece of prose that outruns the surface fails a merge.
25
+
26
+ ## 0.15.0 — 2026-08-03
27
+
28
+ - **`MonthUsage` now types the whole meter, including credits and voice.** The
29
+ interface declared six fields (`month`, `mau`, `mauLimit`, `sessions`,
30
+ `tokensIn`, `tokensOut`) while `GET /usage` returns sixteen. The rest fell
31
+ through the `[k: string]: unknown` index signature, so they were reachable but
32
+ typed `unknown` — `usage.credits > limit` did not compile, and reading the
33
+ product's metered units from the typed client required a cast. Newly declared:
34
+ - `credits`, `creditsByDay`, `creditLimit` — the per-turn credit meter;
35
+ - `creditsVoice`, `voiceMs`, `voiceCalls` — the realtime-voice slice of
36
+ `credits` and the measured minutes behind it. Voice is the most expensive
37
+ metered unit, so this is the split worth alerting on;
38
+ - `mauTest`, `sessionsByDay`, `mauByDay`, `tokensByDay` — the test-key MAU
39
+ count and the per-day chart buckets.
40
+
41
+ Additive and backwards-compatible: the index signature is retained, and every
42
+ new field is optional so the package stays honest against a deployment that
43
+ predates one. No runtime change — this release is types and docs only.
44
+
45
+ A drift gate now pins the interface against the server's usage reader, so the
46
+ next field added server-side cannot silently skip the package again.
47
+
5
48
  ## 0.14.0 — 2026-08-02
6
49
 
7
50
  - **Channel provider registration is now typed.** The server registers
package/README.md CHANGED
@@ -37,9 +37,12 @@ await admin.updateAgent(agent.agentId, { status: 'published' });
37
37
  const { key } = await admin.createKey({ label: 'prod-backend', env: 'live' });
38
38
  console.log(key); // the plaintext token — shown ONCE
39
39
 
40
- // Read this month's usage
40
+ // Read this month's usage — MAU, tokens, and the credit meter (all typed)
41
41
  const { usage } = await admin.getUsage();
42
42
  console.log(usage.mau, '/', usage.mauLimit, 'MAU');
43
+ console.log(usage.credits, '/', usage.creditLimit, 'credits');
44
+ // Voice is the priciest metered unit — watch its slice, not just the total
45
+ console.log(usage.creditsVoice, 'of those credits were', usage.voiceCalls, 'voice calls');
43
46
 
44
47
  // Equip an agent with ANY skill — including a docs-only skill.md that has no
45
48
  // `tools:` block — entirely via the API:
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const ADMIN_SDK_VERSION = "0.14.0";
1
+ export declare const ADMIN_SDK_VERSION = "0.15.1";
2
2
  export declare const DEFAULT_BASE_URL = "https://pouchy.ai/v1/admin";
3
3
  /** Deadline for the routes whose server handler declares `maxDuration: 300` —
4
4
  * the server's own ceiling plus headroom, so a client abort can only ever mean
@@ -211,13 +211,59 @@ export interface Instance {
211
211
  lastActiveAt: string;
212
212
  suspended?: boolean;
213
213
  }
214
+ /** The current month's meter, as `GET /usage` returns it.
215
+ *
216
+ * Every field the server sends is declared. The index signature stays for
217
+ * forward compatibility with a newer server, but it is a fallback, not the
218
+ * contract: reaching a field THROUGH it yields `unknown`, so
219
+ * `usage.credits > limit` does not compile and an integrator has to cast — the
220
+ * same untyped-surface friction the channel-provisioning gap caused. The
221
+ * credit/voice fields below are the ones that bit: they are the product's
222
+ * metered units, and they shipped server-side (and in the OpenAPI) while this
223
+ * interface still described only MAU and tokens.
224
+ *
225
+ * All but `month` are optional so the package stays honest against an OLDER
226
+ * deployment that predates a field — a self-hosted server on a prior release
227
+ * really can omit the voice trio, and typing them as required would be the
228
+ * package asserting something it cannot know. */
214
229
  export interface MonthUsage {
215
230
  month: string;
216
231
  mau: number;
232
+ /** Sessions minted by TEST keys — metered but never gated. */
233
+ mauTest?: number;
234
+ /** The plan's monthly MAU cap. ACCOUNT-scoped (pooled across the owner's
235
+ * projects) while `mau` above is this project's slice, so `mau / mauLimit`
236
+ * understates consumption on a multi-project account.
237
+ *
238
+ * For the number the mint gate actually enforces, call `getUsageHistory()`
239
+ * and READ its `scope`: the server pools across the account whenever it can
240
+ * resolve one and answers `scope: 'account'`, falling back to this project's
241
+ * own slice (`'project'`) when it cannot. `scope` is a response
242
+ * discriminant, not a request option — there is no parameter that forces
243
+ * account scope, so a series that comes back `'project'` on a multi-project
244
+ * account means the account could not be resolved, and comparing it against
245
+ * `mauLimit` has the same understatement as `mau` does. */
217
246
  mauLimit: number;
218
247
  sessions: number;
219
248
  tokensIn: number;
220
249
  tokensOut: number;
250
+ /** Per-UTC-day buckets, `{ 'YYYY-MM-DD': n }` — for charts. */
251
+ sessionsByDay?: Record<string, number>;
252
+ mauByDay?: Record<string, number>;
253
+ tokensByDay?: Record<string, number>;
254
+ creditsByDay?: Record<string, number>;
255
+ /** Credits consumed this month: one per completed standard turn, the Pro
256
+ * multiplier per Pro turn, and the per-minute rate for realtime voice. */
257
+ credits?: number;
258
+ /** The VOICE slice of `credits`, and the measured minutes it came from.
259
+ * Project-scoped: the pooled account counter carries no per-source
260
+ * breakdown. Voice is by far the most expensive metered unit, so this is
261
+ * the split to watch before a bill surprises anyone. */
262
+ creditsVoice?: number;
263
+ voiceMs?: number;
264
+ voiceCalls?: number;
265
+ /** The plan's monthly credit allowance (account-level, like `mauLimit`). */
266
+ creditLimit?: number;
221
267
  [k: string]: unknown;
222
268
  }
223
269
  /** One month of the usage-history series. Unlike `MonthUsage` (the current
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.14.0';
11
+ export const ADMIN_SDK_VERSION = '0.15.1';
12
12
  export const DEFAULT_BASE_URL = 'https://pouchy.ai/v1/admin';
13
13
  /** Default per-request timeout (ms). A hung upstream otherwise never rejects. */
14
14
  const DEFAULT_TIMEOUT_MS = 30_000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pouchy_ai/admin-sdk",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
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",