@pouchy_ai/world-sdk 0.28.0 → 0.28.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
@@ -1,5 +1,16 @@
1
1
  # @pouchy_ai/world-sdk
2
2
 
3
+ ## 0.28.1
4
+
5
+ - **`WorldApiError.errorId`** — the server's lookup reference (`err_…`) for a
6
+ persisted 5xx, when the envelope carried one. An uncaught world-plane fault is
7
+ sanitized to "An unexpected error occurred." before it leaves the server; the
8
+ `errorId` on that envelope is the one thing an operator can resolve to the
9
+ real cause, and the client read `error` / `code` / `retryAfterSec` and dropped
10
+ it — so a 5xx gave you `500 server_error` and nothing to quote. Additive;
11
+ absent on every 4xx and on a 5xx that was not persisted; string-only, like
12
+ `serverCode`. Quote it in a support request.
13
+
3
14
  ## 0.28.0
4
15
 
5
16
  - **`WorldApiError.serverCode`** — the server's own machine-readable `code`
package/README.md CHANGED
@@ -251,7 +251,8 @@ an `approved` editorial can be exported.
251
251
  `newTurnId` / `isReservedTurnId` (idempotency), `describeTurn` (read a result
252
252
  without guessing), `WorldApiError` with typed codes, `.retryable`,
253
253
  `serverCode` (the server's own `code` on a refusal — which 409, since `code`
254
- maps the status), and `rejectedEffects` (which of YOUR proposed ops the world
254
+ maps the status), `errorId` (the server's `err_…` lookup reference on a
255
+ persisted 5xx — quote it in a support request), and `rejectedEffects` (which of YOUR proposed ops the world
255
256
  refused, and why — validation is all-or-nothing, so one bad op moves nothing).
256
257
 
257
258
  ## When a signed door refuses you
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * a project is running — which is exactly the field you reach for when a
5
5
  * customer's integration behaves like an older SDK than they say they have.
6
6
  * It sat at '0.1.0' for eight releases before anything compared the two. */
7
- export declare const WORLD_SDK_VERSION = "0.28.0";
7
+ export declare const WORLD_SDK_VERSION = "0.28.1";
8
8
  export declare const DEFAULT_BASE_URL = "https://pouchy.ai/v1";
9
9
  /** One direction a beat could take. The WHOLE of what a deliberation shows a
10
10
  * player: no reasoning, no role secrets, no simulated effects, no scores. */
@@ -61,6 +61,13 @@ export declare class WorldApiError extends Error {
61
61
  * dropped `code` on the floor, so the one carrier an integrator could
62
62
  * branch on never arrived. */
63
63
  readonly serverCode?: string;
64
+ /** The server's lookup reference for a persisted 5xx (`err_…`), when the
65
+ * envelope carried one. A world-plane fault is sanitized to "An unexpected
66
+ * error occurred." before it leaves the server; the `errorId` is the ONE
67
+ * greppable thing the operator can resolve to the real cause — quote it in
68
+ * a support request. Absent on every 4xx and on a 5xx that was not
69
+ * persisted (0.28.1; until then the client dropped it). */
70
+ readonly errorId?: string;
64
71
  readonly retryAfterSec?: number;
65
72
  /** Why the world refused the effects you proposed — per op, with the
66
73
  * server's own reason and code.
@@ -90,6 +97,7 @@ export declare class WorldApiError extends Error {
90
97
  message: string;
91
98
  detail?: string;
92
99
  serverCode?: string;
100
+ errorId?: string;
93
101
  retryAfterSec?: number;
94
102
  rejectedEffects?: readonly {
95
103
  readonly index: number;
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import { createHash, createHmac, randomUUID } from 'node:crypto';
23
23
  * a project is running — which is exactly the field you reach for when a
24
24
  * customer's integration behaves like an older SDK than they say they have.
25
25
  * It sat at '0.1.0' for eight releases before anything compared the two. */
26
- export const WORLD_SDK_VERSION = '0.28.0';
26
+ export const WORLD_SDK_VERSION = '0.28.1';
27
27
  export const DEFAULT_BASE_URL = 'https://pouchy.ai/v1';
28
28
  /** Read the commit turn id out of an envelope, so the signature covers the id
29
29
  * the server will commit under. The payload half is base64url JSON; the
@@ -71,6 +71,13 @@ export class WorldApiError extends Error {
71
71
  * dropped `code` on the floor, so the one carrier an integrator could
72
72
  * branch on never arrived. */
73
73
  serverCode;
74
+ /** The server's lookup reference for a persisted 5xx (`err_…`), when the
75
+ * envelope carried one. A world-plane fault is sanitized to "An unexpected
76
+ * error occurred." before it leaves the server; the `errorId` is the ONE
77
+ * greppable thing the operator can resolve to the real cause — quote it in
78
+ * a support request. Absent on every 4xx and on a 5xx that was not
79
+ * persisted (0.28.1; until then the client dropped it). */
80
+ errorId;
74
81
  retryAfterSec;
75
82
  /** Why the world refused the effects you proposed — per op, with the
76
83
  * server's own reason and code.
@@ -97,6 +104,8 @@ export class WorldApiError extends Error {
97
104
  this.detail = input.detail;
98
105
  if (input.serverCode !== undefined)
99
106
  this.serverCode = input.serverCode;
107
+ if (input.errorId !== undefined)
108
+ this.errorId = input.errorId;
100
109
  if (input.retryAfterSec !== undefined)
101
110
  this.retryAfterSec = input.retryAfterSec;
102
111
  if (input.rejectedEffects !== undefined)
@@ -940,12 +949,18 @@ export class PouchyWorldClient {
940
949
  const serverCode = parsed && typeof parsed === 'object' && typeof parsed.code === 'string'
941
950
  ? parsed.code
942
951
  : undefined;
952
+ // Same string-only rule as `serverCode`: the envelope's lookup ref, or
953
+ // nothing — never a coerced non-string.
954
+ const errorId = parsed && typeof parsed === 'object' && typeof parsed.errorId === 'string'
955
+ ? parsed.errorId || undefined
956
+ : undefined;
943
957
  throw new WorldApiError({
944
958
  code: codeForStatus(response.status),
945
959
  status: response.status,
946
960
  message: `${method} ${path} → ${response.status}`,
947
961
  ...(detail !== undefined ? { detail } : {}),
948
962
  ...(serverCode !== undefined ? { serverCode } : {}),
963
+ ...(errorId !== undefined ? { errorId } : {}),
949
964
  ...(retryAfterSec !== undefined ? { retryAfterSec } : {}),
950
965
  ...(rejectedEffects !== undefined ? { rejectedEffects } : {})
951
966
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pouchy_ai/world-sdk",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "Server-side TypeScript client for Pouchy World \u2014 story packages, world definitions, world sessions, coordinated turns, trusted events, replay verification and script drafts. Node only: it holds a project Secret Key and a source signing key, which never belong in a browser or a mobile app.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",