@pouchy_ai/admin-sdk 0.41.0 → 0.43.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 CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  All notable changes to `@pouchy_ai/admin-sdk` are documented here.
4
4
 
5
+ ## 0.43.0 — 2026-10-08
6
+
7
+ - **Three period reads** (admin API 1.20.0), the same answers the dashboard
8
+ reads, so a period's numbers can go straight into an integrator's own BI:
9
+ - `getUsageRange({ from, to, tz? })` — usage over any period up to 366 days,
10
+ day by day, with the same-length previous period. `distinct` is an
11
+ estimate of distinct live users over the period (HyperLogLog, about ±5%;
12
+ `complete: false` means a lower bound), with daily estimates for periods up
13
+ to 92 days. `tz` cuts the days in an IANA zone; a day the hourly data does
14
+ not cover is the UTC day of that date, marked `utcFallback`.
15
+ - `getUsageBreakdown({ from, to })` — where the tokens went, by stage and by
16
+ experience; every row is a slice of `totalTokens`, and the remainders
17
+ (`untaggedTokens`, `nonWorldTokens`) are reported rather than dropped.
18
+ - `getRunHistory({ from, to })` — runs, errors, latency and tokens per day and
19
+ per agent from daily rollups, past the 30-day trace retention. Percentiles
20
+ are bucket upper edges, not exact values; `uncoveredDays` names days whose
21
+ runs are missing.
22
+ Additive; no existing method changed.
23
+
24
+ ## 0.42.0 — 2026-10-08
25
+
26
+ - **`getRecentTraces({ from, to })`: a custom window by UTC day** (admin API
27
+ 1.19.0). The run browser could only look back from now (`sinceHours`); a
28
+ window that ends in the past (last Tuesday's failures) had no expression.
29
+ `from` / `to` are inclusive UTC days, given together, within the 30-day trace
30
+ retention — older is a 400, never an empty list that reads as "no runs".
31
+ `window.untilMs` (exclusive) is typed and present on such a window.
32
+ `sinceHours` alone behaves as before. Additive.
33
+ - **`getUsageHistory()` rows carry `credits`** — the credits charged that
34
+ month (the pooled account figure on `scope: 'account'`), typed as optional
35
+ because an older server does not send it.
36
+
5
37
  ## 0.41.0 — 2026-10-02
6
38
 
7
39
  - **Three world session-mint codes join `ADMIN_ERROR_CODES`.** `POST
package/README.md CHANGED
@@ -474,7 +474,7 @@ Reads (`GET`) are not covered by that bucket. `retryAfter` is available from
474
474
  | Durable runs | `listRuns` · `createRun` · `getRun` · `cancelRun` · `resumeRun` · `signalRun` |
475
475
  | Data capabilities | `listCapabilities` (heads + MASKED signing status) · `publishCapability` (TYPED `CapabilityDeclaration`; immutable next version, idempotent on content) · `setCapabilityDisabled` (per-capability live revoke) · `listCapabilityVersions` (history; rollback = republish an old declaration) · `testReadCapability` · `testActionCapability({ confirmDuplicates: true, … })` (REAL deliveries incl. intentional duplicates — 428 without consent) · `listActionExecutions` (the durable Action journal, incl. `authorizedBy: 'automation'`) · `listEventReceipts` (receipts + wake trail) |
476
476
  | Webhooks | `listWebhooks` · `createWebhook` · `updateWebhook` · `rotateWebhookSecret` · `deleteWebhook` · `testWebhook` · `redeliverWebhook` |
477
- | Reporting | `getUsage` · `getUsageHistory` · `getBilling` · `getTracesSummary` · `getRecentTraces` · `getLogs` · `getProject` · `updateProject` |
477
+ | Reporting | `getUsage` · `getUsageHistory` · `getUsageRange` · `getUsageBreakdown` · `getRunHistory` · `getBilling` · `getTracesSummary` · `getRecentTraces` · `getLogs` · `getProject` · `updateProject` |
478
478
  | Utilities | `extractJson` (structured JSON from prose, schema-shaped) · `synthesizeSpeech` (short TTS clip in a catalog voice, base64 mp3) |
479
479
  | Escape hatch | `request(method, path, body?)` — any endpoint not yet typed |
480
480
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const ADMIN_SDK_VERSION = "0.41.0";
1
+ export declare const ADMIN_SDK_VERSION = "0.43.0";
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
@@ -373,8 +373,151 @@ export interface MonthUsageHistoryEntry {
373
373
  mau: number;
374
374
  mauTest: number;
375
375
  sessions: number;
376
+ /** 0.42.0 (admin API 1.19.0): credits charged that month. Absent from an
377
+ * older server. */
378
+ credits?: number;
376
379
  [k: string]: unknown;
377
380
  }
381
+ /** 0.43.0 (admin API 1.20.0) — the period reads. A period is `from` / `to`,
382
+ * inclusive days "YYYY-MM-DD", at most 366 days; a day after today is clamped
383
+ * (`clampedTo`). A bad period is a 400; a storage fault a 503 — never zeros. */
384
+ export type UsagePeriodParams = {
385
+ from: string;
386
+ to: string;
387
+ };
388
+ export interface UsageDay {
389
+ date: string;
390
+ /** Live sessions started that day. */
391
+ sessions: number;
392
+ /** Live users whose FIRST activity that month fell on this day — NOT
393
+ * distinct users across a period (see `UsageRange.distinct`). */
394
+ activations: number;
395
+ /** Tokens in + out, test instances included. */
396
+ tokens: number;
397
+ credits: number;
398
+ /** `tz` only: no complete hour data covers this local day, so these are the
399
+ * numbers of the UTC day with the same date. */
400
+ utcFallback?: boolean;
401
+ }
402
+ export interface UsageRange {
403
+ from: string;
404
+ to: string;
405
+ clampedTo: boolean;
406
+ /** The zone the days are cut in. */
407
+ timezone: string;
408
+ /** The zone has a non-whole-hour offset: day edges are off by up to 45 min. */
409
+ approximate?: boolean;
410
+ days: UsageDay[];
411
+ totals: {
412
+ sessions: number;
413
+ activations: number;
414
+ tokens: number;
415
+ credits: number;
416
+ };
417
+ /** The same-length period immediately before — the comparison base. */
418
+ previous: {
419
+ from: string;
420
+ to: string;
421
+ totals: {
422
+ sessions: number;
423
+ activations: number;
424
+ tokens: number;
425
+ credits: number;
426
+ };
427
+ };
428
+ /** Whole UTC (billing) months the period touches; `partial` when it cuts one.
429
+ * `mau` is the exact distinct figure for that month. */
430
+ months: Array<{
431
+ month: string;
432
+ mau: number;
433
+ mauTest: number;
434
+ sessions: number;
435
+ tokensIn: number;
436
+ tokensOut: number;
437
+ credits: number;
438
+ partial: boolean;
439
+ }>;
440
+ /** ≈ distinct live users over the period (HyperLogLog, UTC days). Absent when
441
+ * the sketches could not be read. `complete: false` = a lower bound. */
442
+ distinct?: {
443
+ estimate: number;
444
+ relativeError: number;
445
+ complete: boolean;
446
+ /** ≈ daily active users — periods up to 92 days only. */
447
+ byDay?: Array<{
448
+ date: string;
449
+ estimate: number;
450
+ }>;
451
+ };
452
+ }
453
+ export interface UsageSliceRow {
454
+ key: string;
455
+ tokensIn: number;
456
+ tokensOut: number;
457
+ calls: number;
458
+ /** Share of the period's `totalTokens`, 0..1. */
459
+ share: number;
460
+ }
461
+ export interface UsageBreakdown {
462
+ from: string;
463
+ to: string;
464
+ timezone: 'UTC';
465
+ totalTokens: number;
466
+ /** Tagged ancillary stages. Every row is a SLICE of `totalTokens`. */
467
+ byTag: UsageSliceRow[];
468
+ /** Tokens in no tagged stage — the main conversation turns. */
469
+ untaggedTokens: number;
470
+ /** By experience (environment id); `name` while the world still exists. */
471
+ byWorld: Array<UsageSliceRow & {
472
+ name?: string;
473
+ }>;
474
+ nonWorldTokens: number;
475
+ /** `incomplete` = that month's per-day maps do not cover it, so the
476
+ * remainders are upper bounds there. */
477
+ months: Array<{
478
+ month: string;
479
+ tag: 'month' | 'daily' | 'incomplete';
480
+ world: 'month' | 'daily' | 'incomplete';
481
+ }>;
482
+ }
483
+ export interface RunHistorySummary {
484
+ runs: number;
485
+ errors: number;
486
+ okRate: number;
487
+ avgMs: number;
488
+ /** Upper edge of the latency bucket the percentile falls in; `null` = above
489
+ * 120 s. Not an exact value (`latencyApprox`). */
490
+ p50Ms: number | null;
491
+ p95Ms: number | null;
492
+ p99Ms: number | null;
493
+ tokensIn: number;
494
+ tokensOut: number;
495
+ tokensCached: number;
496
+ byTrigger: Record<string, number>;
497
+ }
498
+ export interface RunHistory {
499
+ from: string;
500
+ to: string;
501
+ clampedTo: boolean;
502
+ timezone: 'UTC';
503
+ latencyApprox: true;
504
+ overall: RunHistorySummary;
505
+ /** `agentId` / `name` present while the agent still exists. */
506
+ agents: Array<RunHistorySummary & {
507
+ key: string;
508
+ agentId?: string;
509
+ name?: string;
510
+ }>;
511
+ days: Array<{
512
+ date: string;
513
+ runs: number;
514
+ errors: number;
515
+ p95Ms: number | null;
516
+ tokens: number;
517
+ }>;
518
+ /** Days with live sessions but no rollup — their runs are missing above. */
519
+ uncoveredDays: string[];
520
+ }
378
521
  export interface AuditRow {
379
522
  at: string;
380
523
  type: string;
@@ -1439,6 +1582,17 @@ export interface AdminClient {
1439
1582
  months: MonthUsageHistoryEntry[];
1440
1583
  scope: 'account' | 'project';
1441
1584
  }>;
1585
+ /** 0.43.0: usage over any period up to 366 days, day by day, with the
1586
+ * previous period and a distinct-user estimate. `tz` (an IANA zone) cuts
1587
+ * the days in that zone. */
1588
+ getUsageRange(params: UsagePeriodParams & {
1589
+ tz?: string;
1590
+ }): Promise<UsageRange>;
1591
+ /** 0.43.0: where a period's tokens went — by stage and by experience. */
1592
+ getUsageBreakdown(params: UsagePeriodParams): Promise<UsageBreakdown>;
1593
+ /** 0.43.0: run history from daily rollups, past the 30-day trace retention.
1594
+ * Percentiles are bucket upper edges. */
1595
+ getRunHistory(params: UsagePeriodParams): Promise<RunHistory>;
1442
1596
  getBilling(): Promise<{
1443
1597
  billing: {
1444
1598
  plan: string;
@@ -1461,12 +1615,21 @@ export interface AdminClient {
1461
1615
  getRecentTraces(params?: {
1462
1616
  agentId?: string;
1463
1617
  sinceHours?: number;
1618
+ /** 0.42.0 (admin API 1.19.0): a custom window by UTC day, inclusive,
1619
+ * both required together. Run traces are kept 30 days, so `from` must
1620
+ * fall within the last 30 UTC days — older is a 400, not an empty list.
1621
+ * `sinceHours` is ignored when these are given. */
1622
+ from?: string;
1623
+ to?: string;
1464
1624
  errorsOnly?: boolean;
1465
1625
  limit?: number;
1466
1626
  }): Promise<{
1467
1627
  sinceHours: number;
1628
+ /** `untilMs` (exclusive) is present only on a custom window ending
1629
+ * before now. */
1468
1630
  window: {
1469
1631
  sinceMs: number;
1632
+ untilMs?: number;
1470
1633
  };
1471
1634
  degraded: false | 'index' | 'error';
1472
1635
  traces: RecentTrace[];
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.41.0';
11
+ export const ADMIN_SDK_VERSION = '0.43.0';
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;
@@ -400,6 +400,9 @@ export function createAdminClient(opts) {
400
400
  redeliverWebhook: (id) => request('POST', `/webhooks/deliveries/${encodeURIComponent(id)}/redeliver`),
401
401
  getUsage: () => request('GET', '/usage'),
402
402
  getUsageHistory: (params = {}) => request('GET', `/usage/history${qs(params)}`),
403
+ getUsageRange: (params) => request('GET', `/usage/range${qs(params)}`),
404
+ getUsageBreakdown: (params) => request('GET', `/usage/breakdown${qs(params)}`),
405
+ getRunHistory: (params) => request('GET', `/health/history${qs(params)}`),
403
406
  getBilling: () => request('GET', '/billing'),
404
407
  getTracesSummary: (params) => request('GET', `/traces/summary${qs(params)}`),
405
408
  getRecentTraces: (params = {}) => request('GET', `/traces/recent${qs({ ...params, errorsOnly: params.errorsOnly ? '1' : undefined })}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pouchy_ai/admin-sdk",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
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",