@pouchy_ai/admin-sdk 0.11.0 → 0.13.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.13.0 — 2026-08-02
6
+
7
+ - **`getUsageHistory({ months? })`** over `GET /v1/admin/usage/history` —
8
+ month-over-month `{ months: MonthUsageHistoryEntry[], scope }`, oldest
9
+ first, quiet months zero-filled. The route shipped with the 1.4.x history
10
+ work; this closes the package's own "new mirror ⇒ new method" convention
11
+ gap (a headless operator could read this month but not the history).
12
+ `scope: 'account'` is the pooled series the plan cap compares;
13
+ `'project'` is the fallback when the account can't be resolved.
14
+ `MonthUsageHistoryEntry` is exported.
15
+
16
+ ## 0.12.0 — 2026-08-01
17
+
18
+ - **Typed capability declarations.** `publishCapability` now takes a
19
+ `CapabilityDeclaration` (`ViewDeclaration | ActionDeclaration |
20
+ EventDeclaration`, all exported) — compile-time help for the one call with
21
+ 14+ fields and four closed vocabularies (`sensitivity`, `idempotency`,
22
+ `automation`, `signing`). The server stays the one validator; an index
23
+ signature keeps newer server fields publishable from an older SDK.
24
+ - **Typed agent Data flags.** `Agent` gains `data?: AgentData` — the live
25
+ levers (`enabled`, `actions.enabled` / `autoRun` / `autoRunDailyCap`,
26
+ `events.enabled` / `subscriptions`), usable through
27
+ `updateAgent(id, { data: { … } })`.
28
+ - **Observability readers.** `listActionExecutions({ limit? })` and
29
+ `listEventReceipts({ limit? })` over the new `/v1/admin/actions` +
30
+ `/v1/admin/events` mirrors (Admin API 1.5.0) — the durable Action journal
31
+ (typed rows incl. `authorizedBy: 'automation'`) and Event receipts + wake
32
+ trail, closing the headless loop: publish → test → read back what ran.
33
+
5
34
  ## 0.11.0 — 2026-08-01
6
35
 
7
36
  - **Data capabilities, headless.** Six new methods over the `/v1/admin/capabilities`
package/README.md CHANGED
@@ -198,15 +198,20 @@ Reads (`GET`) are not covered by that bucket. `retryAfter` is available from
198
198
  | Channels | `listChannels` · `createChannel` · `getChannel` · `updateChannel` · `deleteChannel` |
199
199
  | Schedules | `listSchedules` · `createSchedule` · `getSchedule` · `updateSchedule` · `deleteSchedule` |
200
200
  | Durable runs | `listRuns` · `createRun` · `getRun` · `cancelRun` · `resumeRun` · `signalRun` |
201
+ | 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) |
202
+ | Webhooks | `listWebhooks` · `createWebhook` · `updateWebhook` · `rotateWebhookSecret` · `deleteWebhook` · `testWebhook` · `redeliverWebhook` |
203
+ | Reporting | `getUsage` · `getUsageHistory` · `getBilling` · `getTracesSummary` · `getRecentTraces` · `getLogs` · `getProject` · `updateProject` |
204
+ | Escape hatch | `request(method, path, body?)` — any endpoint not yet typed |
201
205
 
202
206
  Channel types are checked at compile time: `createChannel` takes a
203
207
  `CreatableChannelType` (the platform's 31-transport union minus the adapterless
204
208
  `internal-a2a`), and `secret` is a named `ChannelSecretInput`. Per-transport
205
209
  `secret.extra` fields are listed in <https://pouchy.ai/docs/channel-setup>.
206
- | Data capabilities | `listCapabilities` (heads + MASKED signing status) · `publishCapability` (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) |
207
- | Webhooks | `listWebhooks` · `createWebhook` · `updateWebhook` · `rotateWebhookSecret` · `deleteWebhook` · `testWebhook` · `redeliverWebhook` |
208
- | Reporting | `getUsage` · `getBilling` · `getTracesSummary` · `getRecentTraces` · `getLogs` · `getProject` · `updateProject` |
209
- | Escape hatch | `request(method, path, body?)` any endpoint not yet typed |
210
+
211
+ Capability **signing-key management is deliberately not mirrored** here: the
212
+ one-time `pcsk_`/`pesk_` plaintext reveal stays a human act on the owner
213
+ plane (dashboard / owner API). `listCapabilities` returns masked key status
214
+ only.
210
215
 
211
216
  ### Durable runs
212
217
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const ADMIN_SDK_VERSION = "0.11.0";
1
+ export declare const ADMIN_SDK_VERSION = "0.13.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
@@ -99,6 +99,30 @@ export declare class AdminApiError extends Error {
99
99
  export type Env = 'live' | 'test';
100
100
  export type AgentStatus = 'draft' | 'published';
101
101
  export type ModelTier = 'standard' | 'pro';
102
+ /** The agent template's Data plane flags — the LIVE half of every Data
103
+ * authorization (the pinned half is the published declaration). All fields
104
+ * are live levers: flipping one off stops that plane on the next turn of
105
+ * sessions already running. */
106
+ export interface AgentData {
107
+ /** Parent gate: instances get `read_data` + the pinned capability menu. */
108
+ enabled?: boolean;
109
+ actions?: {
110
+ /** Exposes the confirm-gated `run_action` gateway (needs `enabled`). */
111
+ enabled?: boolean;
112
+ /** Operator half of event-to-action automation (≤5 action names; the
113
+ * declaration must also say `automation: 'allowed'`). */
114
+ autoRun?: string[];
115
+ /** Automated runs per user per UTC day, 1..50 (default 10). */
116
+ autoRunDailyCap?: number;
117
+ };
118
+ events?: {
119
+ /** Lets your backend POST published events at this agent's instances. */
120
+ enabled?: boolean;
121
+ /** Subscription routing: an event POSTed WITHOUT agentId fans out to
122
+ * every subscribed, events-enabled agent (≤10 capability names). */
123
+ subscriptions?: string[];
124
+ };
125
+ }
102
126
  export interface Agent {
103
127
  agentId: string;
104
128
  name: string;
@@ -106,10 +130,67 @@ export interface Agent {
106
130
  systemPrompt: string;
107
131
  status?: AgentStatus;
108
132
  modelTier?: ModelTier;
133
+ /** Agent Data plane flags (see AgentData). */
134
+ data?: AgentData;
109
135
  templateRev: number;
110
136
  createdAt: string;
111
137
  [k: string]: unknown;
112
138
  }
139
+ export type CapabilitySensitivity = 'public' | 'personal' | 'intimate';
140
+ export interface ViewDeclaration {
141
+ kind: 'view';
142
+ /** The agent's business vocabulary (e.g. `Order`), not a table name. */
143
+ name: string;
144
+ description: string;
145
+ sensitivity?: CapabilitySensitivity;
146
+ /** ONE exact lowercase hostname; every endpoint must live on it. */
147
+ audience: string;
148
+ /** HTTPS GET endpoint — declared `filters` arrive as query parameters. */
149
+ endpoint: string;
150
+ /** Output allowlist — extra fields your endpoint returns never reach the agent. */
151
+ fields: string[];
152
+ filters?: string[];
153
+ [k: string]: unknown;
154
+ }
155
+ export interface ActionDeclaration {
156
+ kind: 'action';
157
+ name: string;
158
+ description: string;
159
+ sensitivity?: CapabilitySensitivity;
160
+ audience: string;
161
+ /** HTTPS POST endpoint — receives `{"actionId","action","args"}` signed. */
162
+ endpoint: string;
163
+ args?: string[];
164
+ /** The contract's only Phase-1 mode. */
165
+ idempotency: 'action_id';
166
+ /** Signed read-only `GET ?actionId=` resolver for `unknown` outcomes. */
167
+ reconcile?: {
168
+ endpoint: string;
169
+ };
170
+ /** Declared + validated today, NOT yet dispatched (forward-compat). */
171
+ compensate?: {
172
+ endpoint: string;
173
+ };
174
+ /** Author's pinned safety claim: eligible for event-driven automation
175
+ * (still needs the agent's live `autoRun` grant). */
176
+ automation?: 'allowed';
177
+ [k: string]: unknown;
178
+ }
179
+ export interface EventDeclaration {
180
+ kind: 'event';
181
+ name: string;
182
+ description: string;
183
+ sensitivity?: CapabilitySensitivity;
184
+ /** The declared emitter id — bound at ingress, never payload-decided. */
185
+ source: string;
186
+ schemaVersion: number;
187
+ /** Payload field mined as the subject reference (an EXISTING instance). */
188
+ subjectField: string;
189
+ /** Demand POUCHY-SOURCE-V1 per-source signatures on ingress. */
190
+ signing?: 'required';
191
+ [k: string]: unknown;
192
+ }
193
+ export type CapabilityDeclaration = ViewDeclaration | ActionDeclaration | EventDeclaration;
113
194
  export interface SecretKey {
114
195
  keyId: string;
115
196
  label: string;
@@ -139,6 +220,16 @@ export interface MonthUsage {
139
220
  tokensOut: number;
140
221
  [k: string]: unknown;
141
222
  }
223
+ /** One month of the usage-history series. Unlike `MonthUsage` (the current
224
+ * month's full meter incl. day buckets and the cap), history rows are the
225
+ * compact per-month rollup the server keeps for every past month. */
226
+ export interface MonthUsageHistoryEntry {
227
+ month: string;
228
+ mau: number;
229
+ mauTest: number;
230
+ sessions: number;
231
+ [k: string]: unknown;
232
+ }
142
233
  export interface AuditRow {
143
234
  at: string;
144
235
  type: string;
@@ -589,8 +680,10 @@ export interface AdminClient {
589
680
  /** Create a schedule. `externalUserId` and `prompt` are required alongside
590
681
  * `agentId`; the schedule fires by `intervalMinutes` (recurring, >=5) or
591
682
  * `runAt` (one-shot **epoch milliseconds** — an ISO string is silently
592
- * ignored by the server) there is NO cron field. Returns the stored
593
- * record, whose id lives on `.id`. */
683
+ * ignored by the server; must be in the future a past `runAt` is a 400,
684
+ * with a 60s clock-skew grace) there is NO cron field. A storage outage
685
+ * answers 503, not a validation 400. Returns the stored record, whose id
686
+ * lives on `.id`. */
594
687
  createSchedule(input: {
595
688
  agentId: string;
596
689
  externalUserId: string;
@@ -712,7 +805,7 @@ export interface AdminClient {
712
805
  * bytes mint version+1 and never rewrite an old one. Publishing is NOT
713
806
  * revocation — the per-agent data flags and `setCapabilityDisabled` are
714
807
  * the live levers. */
715
- publishCapability(declaration: Record<string, unknown>): Promise<{
808
+ publishCapability(declaration: CapabilityDeclaration): Promise<{
716
809
  revision: {
717
810
  capabilityId: string;
718
811
  version: number;
@@ -757,6 +850,48 @@ export interface AdminClient {
757
850
  args?: Record<string, unknown>;
758
851
  externalUserId?: string;
759
852
  }): Promise<Record<string, unknown>>;
853
+ /** The durable Action journal, newest first (limit clamped to 1..100,
854
+ * default 50) — every run_action ever dispatched, with pinned revision,
855
+ * canonical intent, outcome status and reconcile trail. `unknown` is
856
+ * shown as unknown, never dressed up; `authorizedBy: 'automation'` marks
857
+ * event-driven runs (absent = a user approved). Same rows as the
858
+ * owner-plane viewer (one server-side shaper, two doors). */
859
+ listActionExecutions(params?: {
860
+ limit?: number;
861
+ }): Promise<{
862
+ executions: Array<{
863
+ actionId: string;
864
+ capabilityId: string;
865
+ version: number;
866
+ revisionHash: string;
867
+ status: 'dispatching' | 'committed' | 'rejected' | 'unknown';
868
+ intent: Record<string, string>;
869
+ intentHash: string;
870
+ subject: {
871
+ kind: string;
872
+ externalUserId?: string;
873
+ } | null;
874
+ confirmId: string;
875
+ authorizedBy?: 'user' | 'automation';
876
+ createdAt: number;
877
+ settledAt?: number;
878
+ remoteStatus?: number;
879
+ receipt?: string;
880
+ reconcileAttempts?: number;
881
+ reconcileLastAt?: number | null;
882
+ reconcileLastResult?: string | null;
883
+ [k: string]: unknown;
884
+ }>;
885
+ }>;
886
+ /** Event receipts + wake trail, newest first (limit clamped to 1..100,
887
+ * default 50). Pure metadata — the payload was mined for the subject and
888
+ * discarded at ingress. The wake trail records acceptance, turn and
889
+ * delivery milestones SEPARATELY: accepted never implies a turn ran. */
890
+ listEventReceipts(params?: {
891
+ limit?: number;
892
+ }): Promise<{
893
+ receipts: Array<Record<string, unknown>>;
894
+ }>;
760
895
  listWebhooks(): Promise<{
761
896
  webhooks: unknown[];
762
897
  }>;
@@ -795,6 +930,18 @@ export interface AdminClient {
795
930
  getUsage(): Promise<{
796
931
  usage: MonthUsage;
797
932
  }>;
933
+ /** Month-over-month usage series, oldest first; quiet months zero-fill
934
+ * rather than drop. `scope: 'account'` means the pooled account series —
935
+ * the figure the plan cap actually compares (a multi-project account's
936
+ * pooled number differs from any one project's slice); `'project'` is the
937
+ * fallback when the account can't be resolved. */
938
+ getUsageHistory(params?: {
939
+ /** Window size in months, clamped server-side to 1..24 (default 12). */
940
+ months?: number;
941
+ }): Promise<{
942
+ months: MonthUsageHistoryEntry[];
943
+ scope: 'account' | 'project';
944
+ }>;
798
945
  getBilling(): Promise<{
799
946
  billing: {
800
947
  plan: string;
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.0';
11
+ export const ADMIN_SDK_VERSION = '0.13.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;
@@ -291,6 +291,8 @@ export function createAdminClient(opts) {
291
291
  setCapabilityDisabled: (name, disabled) => request('PATCH', `/capabilities/${encodeURIComponent(name)}`, { disabled }),
292
292
  listCapabilityVersions: (name) => request('GET', `/capabilities/${encodeURIComponent(name)}/versions`),
293
293
  testReadCapability: (name, input = {}) => request('POST', `/capabilities/${encodeURIComponent(name)}/test-read`, input),
294
+ listActionExecutions: (params = {}) => request('GET', `/actions${qs(params)}`),
295
+ listEventReceipts: (params = {}) => request('GET', `/events${qs(params)}`),
294
296
  testActionCapability: (name, input) => request('POST', `/capabilities/${encodeURIComponent(name)}/test-action`, input),
295
297
  listWebhooks: () => request('GET', '/webhooks'),
296
298
  createWebhook: (input) => request('POST', '/webhooks', input),
@@ -300,6 +302,7 @@ export function createAdminClient(opts) {
300
302
  testWebhook: (id) => request('POST', `/webhooks/${encodeURIComponent(id)}/test`),
301
303
  redeliverWebhook: (id) => request('POST', `/webhooks/deliveries/${encodeURIComponent(id)}/redeliver`),
302
304
  getUsage: () => request('GET', '/usage'),
305
+ getUsageHistory: (params = {}) => request('GET', `/usage/history${qs(params)}`),
303
306
  getBilling: () => request('GET', '/billing'),
304
307
  getTracesSummary: (params) => request('GET', `/traces/summary${qs(params)}`),
305
308
  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.11.0",
3
+ "version": "0.13.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",