@pouchy_ai/admin-sdk 0.42.0 → 0.44.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,35 @@
2
2
 
3
3
  All notable changes to `@pouchy_ai/admin-sdk` are documented here.
4
4
 
5
+ ## 0.44.0 — 2026-10-09
6
+
7
+ - **`getRecentTraces` and `getTracesSummary` say when the read hit its cap**
8
+ (admin API 1.21.0): `truncated: true` with `sampledRuns`, the pair the
9
+ health read already carried. With `errorsOnly` the recent read scans the
10
+ window's newest runs and keeps the failures, so on a busy project an empty
11
+ list could mean "the newest runs all succeeded" rather than "no failures in
12
+ this window", and nothing told the two apart. Absent on a read under its cap.
13
+ Additive; no existing field changed.
14
+
15
+ ## 0.43.0 — 2026-10-08
16
+
17
+ - **Three period reads** (admin API 1.20.0), the same answers the dashboard
18
+ reads, so a period's numbers can go straight into an integrator's own BI:
19
+ - `getUsageRange({ from, to, tz? })` — usage over any period up to 366 days,
20
+ day by day, with the same-length previous period. `distinct` is an
21
+ estimate of distinct live users over the period (HyperLogLog, about ±5%;
22
+ `complete: false` means a lower bound), with daily estimates for periods up
23
+ to 92 days. `tz` cuts the days in an IANA zone; a day the hourly data does
24
+ not cover is the UTC day of that date, marked `utcFallback`.
25
+ - `getUsageBreakdown({ from, to })` — where the tokens went, by stage and by
26
+ experience; every row is a slice of `totalTokens`, and the remainders
27
+ (`untaggedTokens`, `nonWorldTokens`) are reported rather than dropped.
28
+ - `getRunHistory({ from, to })` — runs, errors, latency and tokens per day and
29
+ per agent from daily rollups, past the 30-day trace retention. Percentiles
30
+ are bucket upper edges, not exact values; `uncoveredDays` names days whose
31
+ runs are missing.
32
+ Additive; no existing method changed.
33
+
5
34
  ## 0.42.0 — 2026-10-08
6
35
 
7
36
  - **`getRecentTraces({ from, to })`: a custom window by UTC day** (admin API
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.42.0";
1
+ export declare const ADMIN_SDK_VERSION = "0.44.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
@@ -378,6 +378,146 @@ export interface MonthUsageHistoryEntry {
378
378
  credits?: number;
379
379
  [k: string]: unknown;
380
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
+ }
381
521
  export interface AuditRow {
382
522
  at: string;
383
523
  type: string;
@@ -1442,6 +1582,17 @@ export interface AdminClient {
1442
1582
  months: MonthUsageHistoryEntry[];
1443
1583
  scope: 'account' | 'project';
1444
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>;
1445
1596
  getBilling(): Promise<{
1446
1597
  billing: {
1447
1598
  plan: string;
@@ -1481,6 +1632,13 @@ export interface AdminClient {
1481
1632
  untilMs?: number;
1482
1633
  };
1483
1634
  degraded: false | 'index' | 'error';
1635
+ /** 0.44.0 (admin API 1.21.0): present only when the read hit its cap.
1636
+ * The rows (with `errorsOnly`, the failures) then come from the window's
1637
+ * newest `sampledRuns` runs only, so an empty `errorsOnly` list is NOT
1638
+ * "no failed runs in this window". */
1639
+ truncated?: true;
1640
+ /** With `truncated`: how many runs the read took. */
1641
+ sampledRuns?: number;
1484
1642
  traces: RecentTrace[];
1485
1643
  }>;
1486
1644
  /** Enabled platform voices for programmatic provisioning. Filter by gender /
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.42.0';
11
+ export const ADMIN_SDK_VERSION = '0.44.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.42.0",
3
+ "version": "0.44.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",