@pouchy_ai/admin-sdk 0.34.0 → 0.36.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,53 @@
2
2
 
3
3
  All notable changes to `@pouchy_ai/admin-sdk` are documented here.
4
4
 
5
+ ## 0.36.0 — 2026-09-12
6
+
7
+ - **`deleteChannel` reports what happened to the PROVIDER registration**, and
8
+ takes `{ deprovision: false }` to suppress it. Admin API 1.13.0. Additive:
9
+ the option is optional and the response field is new.
10
+
11
+ Create has registered telegram/discord connectors with their provider since
12
+ 1.6.0 (`setWebhook` / the slash command). Delete never unregistered — and the
13
+ asymmetry was worse than an omission, because the delete also destroys the
14
+ stored bot token, so afterwards nothing on the server side could ever do it.
15
+ The bot kept pushing every message it could see to a dead inbound URL, which
16
+ on a fail-closed rate-limited prefix also keeps spending the project's
17
+ limiter quota.
18
+
19
+ Surfaced by an integrator asking whether `DELETE` called `deleteWebhook` —
20
+ the shape of question that is worth answering by reading the code.
21
+
22
+ - `ChannelProvisionCode` gains `webhook_deleted`, `command_deleted` and
23
+ `command_absent`. The union is closed and a published member is never removed,
24
+ so handle an unknown code as informational. `command_absent` is a **skip**,
25
+ not an ok: the Discord command was already gone, and "we removed it" versus
26
+ "there was nothing to remove" are different facts about the provider.
27
+
28
+ ## 0.35.0 — 2026-09-10
29
+
30
+ ### Added
31
+
32
+ - **Four story-package codes join `ADMIN_ERROR_CODES`**, and two of them were
33
+ already on the wire without being in it. `has_pins` and `pins_unknown` are
34
+ the two 409s of `DELETE …/story-packages/{packageId}` (world API 1.35.0):
35
+ an environment revision has pinned this package, versus the package predates
36
+ the pin stamp so whether one points at it is UNKNOWN and is not guessed. They
37
+ shipped through the same VARIABLE indirection that hid
38
+ `story_contract_v2_write_disabled` — the route forwarded `result.reason` as
39
+ `code`, so the vocabulary census could not see them; the route spells them
40
+ out now.
41
+
42
+ `story_package_limit` and `story_package_documents_limit` are the two ceiling
43
+ refusals, newly carrying a code at all. An integrator reported asserting on
44
+ the refusal SENTENCES because they were the only observation point for the
45
+ quota — which made a copy edit a breaking change for them and a number change
46
+ harmless, the exact inversion of what either should cost. The codes retire
47
+ the prose parsing.
48
+
49
+ Distinguishing the two delete refusals matters because their outs differ:
50
+ `has_pins` sends you to an environment, `pins_unknown` sends you to disable.
51
+
5
52
  ## 0.34.0 — 2026-09-08
6
53
 
7
54
  ### Fixed
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const ADMIN_SDK_VERSION = "0.34.0";
1
+ export declare const ADMIN_SDK_VERSION = "0.36.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
@@ -60,7 +60,7 @@ export interface AdminClientOptions {
60
60
  * published: on this plane the status line never disambiguates, so two of the
61
61
  * durable-run routes answer 409 for two entirely different reasons each, with
62
62
  * different recoveries. `code` is the only thing that tells them apart. */
63
- export declare const ADMIN_ERROR_CODES: readonly ["story_contract_v2_write_disabled", "story_contract_v3_write_disabled", "story_contract_v4_write_disabled", "episode_history_incomplete", "episode_ended", "idempotency_key_reused", "stale_deliberation", "deliberation_disabled", "deliberation_uncalibrated", "deliberation_not_enabled", "deliberation_candidates_exceeded", "schedule_limit_reached", "one_shot_spent", "ghost_row", "channel_limit_reached", "webhook_limit_reached", "run_limit_reached", "reembed_required", "run_terminal", "run_not_parked", "stale_token", "run_not_waiting", "event_mismatch"];
63
+ export declare const ADMIN_ERROR_CODES: readonly ["story_contract_v2_write_disabled", "story_contract_v3_write_disabled", "story_contract_v4_write_disabled", "has_pins", "pins_unknown", "story_package_limit", "story_package_documents_limit", "episode_history_incomplete", "episode_ended", "idempotency_key_reused", "stale_deliberation", "deliberation_disabled", "deliberation_uncalibrated", "deliberation_not_enabled", "deliberation_candidates_exceeded", "schedule_limit_reached", "one_shot_spent", "ghost_row", "channel_limit_reached", "webhook_limit_reached", "run_limit_reached", "reembed_required", "run_terminal", "run_not_parked", "stale_token", "run_not_waiting", "event_mismatch"];
64
64
  /** `AdminApiError.code` values. The `(string & {})` arm keeps the type open for
65
65
  * codes newer than this SDK build while preserving autocomplete — same
66
66
  * doctrine as the companion SDK's `CompanionErrorCodeValue`. */
@@ -401,13 +401,15 @@ export interface ChannelSecretInput {
401
401
  extra?: Record<string, string>;
402
402
  }
403
403
  /** Outcome class of the provider registration the server performs on create,
404
- * and on a rotate / secret replacement. Mirrors the server's `ProvisionStatus`
405
- * (`channels/provision.ts`); `admin-sdk-provision.drift.test.ts` binds them. */
404
+ * on a rotate / secret replacement, and — from admin API 1.13.0 — the
405
+ * UNregistration it performs on delete. Mirrors the server's
406
+ * `ProvisionStatus` (`channels/provision.ts`);
407
+ * `admin-sdk-provision.drift.test.ts` binds them. */
406
408
  export type ChannelProvisionStatus = 'ok' | 'skipped' | 'failed';
407
409
  /** Machine-readable reason for a `ChannelProvisionResult`. The server treats
408
410
  * this vocabulary as part of the response contract (the dashboard keys its
409
411
  * copy off it), so branch on `code`, never on `detail`. */
410
- export type ChannelProvisionCode = 'webhook_set' | 'command_registered' | 'unsupported_type' | 'no_token' | 'no_inbound_url' | 'not_requested' | 'invalid_command_name' | 'app_lookup_failed' | 'upstream_rejected' | 'upstream_unreachable';
412
+ export type ChannelProvisionCode = 'webhook_set' | 'command_registered' | 'unsupported_type' | 'no_token' | 'no_inbound_url' | 'not_requested' | 'invalid_command_name' | 'app_lookup_failed' | 'upstream_rejected' | 'upstream_unreachable' | 'webhook_deleted' | 'command_deleted' | 'command_absent';
411
413
  /** What the provider said when the server registered this connector for you.
412
414
  *
413
415
  * Registration is an enrichment on top of a durable write: the connector
@@ -1083,8 +1085,24 @@ export interface AdminClient {
1083
1085
  * transport, when not suppressed with `autoProvision: false`. */
1084
1086
  provision?: ChannelProvisionResult;
1085
1087
  }>;
1086
- deleteChannel(channelId: string): Promise<{
1088
+ /** Delete a connector — and, for telegram/discord, UNREGISTER it with the
1089
+ * provider first (admin API 1.13.0).
1090
+ *
1091
+ * The ordering is the point: the delete also destroys the stored bot token,
1092
+ * so an unregistration skipped at that moment can never be done afterwards
1093
+ * from the server side — the bot would keep pushing every message it can see
1094
+ * to a dead inbound URL, and only whoever holds the token could stop it.
1095
+ *
1096
+ * Same contract as create-side registration: the connector is removed
1097
+ * whether or not the provider answers, and a `failed` outcome carries
1098
+ * `manualCommand`. Pass `deprovision: false` to keep the provider
1099
+ * registration (for a caller who manages the bot webhook themselves). */
1100
+ deleteChannel(channelId: string, options?: {
1101
+ deprovision?: false;
1102
+ }): Promise<{
1087
1103
  ok: boolean;
1104
+ /** Absent for a transport with no provider registration. */
1105
+ deprovision?: ChannelProvisionResult;
1088
1106
  }>;
1089
1107
  listSchedules(): Promise<{
1090
1108
  schedules: unknown[];
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.34.0';
11
+ export const ADMIN_SDK_VERSION = '0.36.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;
@@ -73,6 +73,10 @@ export const ADMIN_ERROR_CODES = [
73
73
  'story_contract_v2_write_disabled',
74
74
  'story_contract_v3_write_disabled',
75
75
  'story_contract_v4_write_disabled',
76
+ 'has_pins',
77
+ 'pins_unknown',
78
+ 'story_package_limit',
79
+ 'story_package_documents_limit',
76
80
  'episode_history_incomplete',
77
81
  'episode_ended',
78
82
  'idempotency_key_reused',
@@ -330,7 +334,7 @@ export function createAdminClient(opts) {
330
334
  createChannel: (input) => request('POST', '/channels', input),
331
335
  getChannel: (id) => request('GET', `/channels/${encodeURIComponent(id)}`),
332
336
  updateChannel: (id, patch) => request('PATCH', `/channels/${encodeURIComponent(id)}`, patch),
333
- deleteChannel: (id) => request('DELETE', `/channels/${encodeURIComponent(id)}`),
337
+ deleteChannel: (id, options) => request('DELETE', `/channels/${encodeURIComponent(id)}${options?.deprovision === false ? '?deprovision=false' : ''}`),
334
338
  listSchedules: () => request('GET', '/schedules'),
335
339
  createSchedule: (input) => request('POST', '/schedules', input),
336
340
  getSchedule: (id) => request('GET', `/schedules/${encodeURIComponent(id)}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pouchy_ai/admin-sdk",
3
- "version": "0.34.0",
3
+ "version": "0.36.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",