@pouchy_ai/world-sdk 0.18.0 → 0.19.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
@@ -1,5 +1,30 @@
1
1
  # @pouchy_ai/world-sdk
2
2
 
3
+ ## 0.19.0
4
+
5
+ - `getApprovedExport(environmentId, worldInstanceId, draftId, editorialId, exportId)`
6
+ — **read an approved script, body included, from a backend.** With `adminKey`
7
+ set it goes to the `/admin` mirror and needs no browser anywhere in your
8
+ deployment; same mechanism as `getProgress` and `getTurn`.
9
+ - **This closes the loop.** Until now nothing returned an export body: the
10
+ collection listing strips it, so the only response that ever carried a script
11
+ was the POST that minted one. Reading required the create verb and an
12
+ hour-lived browser token, which meant a person had to forward the file.
13
+ - **Every field the call needs is in the `world.script_approved` webhook** —
14
+ `exportId` at the top level, and `environmentId`, `worldInstanceId`,
15
+ `evidenceDraftId`, `editorialDraftId` inside `lineage`. Webhook → read, with
16
+ nobody in the middle. The payload still carries no script.
17
+ - **Creating an export is still a human act** and is deliberately NOT mirrored:
18
+ an export is a reviewer's signature on a specific text. `deriveStoryPackageCandidate`
19
+ is not mirrored either — it leads to published canon.
20
+ - New `ApprovedScriptExportSummary`, and `listApprovedExports` is now typed with
21
+ it instead of `unknown[]`. **The summary carries no `content`** — that is the
22
+ point of the split, and treating one as a full row is now a compile error
23
+ rather than a crash reading `content.exportDigest` off `undefined`.
24
+ - Any miss on the item read — wrong project, environment, instance, draft,
25
+ editorial, or no such id — answers the **same** 404, so refusals cannot be used
26
+ to map which objects exist.
27
+
3
28
  ## 0.18.0
4
29
 
5
30
  - `createApprovedExport({ version: 2 })` — the V2 production hand-off: a
package/README.md CHANGED
@@ -160,7 +160,7 @@ copies, and `prune` — the one call here that deletes — refuses without
160
160
  `confirm`, and again unless the archive verifies and has outlived retention.
161
161
 
162
162
  **Production hand-off** — `createApprovedExport`, `listApprovedExports`,
163
- `deriveStoryPackageCandidate`. An approved editorial draft becomes a versioned
163
+ `getApprovedExport`, `deriveStoryPackageCandidate`. An approved editorial draft becomes a versioned
164
164
  approved script export carrying the whole chain: original story package → world
165
165
  instance → ledger range → evidence draft → editorial draft → reviewer.
166
166
  Idempotent on content, so replaying an export is a no-op.
@@ -177,6 +177,14 @@ yields two different, individually stable ids. `content` is a union — narrow o
177
177
  `contractVersion` before reading version-specific fields, and expect an
178
178
  unrecognised `version` to be a 400 rather than a quiet fall back to 1.
179
179
 
180
+ `listApprovedExports` returns **summaries** — identity, provenance, a scene
181
+ count, and no script. `getApprovedExport` returns **one export with its body**,
182
+ and it is the call an unattended backend makes: with `adminKey` set it routes to
183
+ the `/admin` mirror, so no browser is involved anywhere in your deployment.
184
+ Everything it needs arrives in the `world.script_approved` webhook, so the loop
185
+ closes without a person in the middle. Creating an export is deliberately NOT on
186
+ that lane — an export is a reviewer's signature on a specific text.
187
+
180
188
  The Story Package candidate is validated and *returned*; publishing it is a
181
189
  separate act by a person, and only evidence-origin material becomes canon. It
182
190
  takes **version 1 exports only** and refuses a V2 export with 422 — it is the
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.18.0";
7
+ export declare const WORLD_SDK_VERSION = "0.19.0";
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. */
@@ -643,6 +643,29 @@ export interface ApprovedScriptExportContentV2 {
643
643
  * reading anything version-specific; a stored row keeps the version it was
644
644
  * written with, forever. */
645
645
  export type ApprovedScriptExportContent = ApprovedScriptExportContentV1 | ApprovedScriptExportContentV2;
646
+ /** Identity and provenance for every export on an editorial draft, WITHOUT the
647
+ * script. This is what `listApprovedExports` returns.
648
+ *
649
+ * Split from `ApprovedScriptExportRow` deliberately, and the difference is the
650
+ * whole script. Treating a summary as a full row reads `content.exportDigest`
651
+ * off `undefined`; keeping them apart makes that a compile error rather than a
652
+ * crash in front of a user. To get the body, call `getApprovedExport`. */
653
+ export interface ApprovedScriptExportSummary {
654
+ exportId: string;
655
+ draftId: string;
656
+ editorialId: string;
657
+ worldInstanceId: string;
658
+ environmentId: string;
659
+ /** How many scenes the body carries — the shape of what is not here. */
660
+ scenes: number;
661
+ createdAt: string;
662
+ createdBy: string;
663
+ deliveredAt?: string;
664
+ deliveryAttempted?: number;
665
+ deliveryOk?: number;
666
+ approvalTimeSource?: 'stamped' | 'legacy_updated_at';
667
+ approvedContentDigest?: string;
668
+ }
646
669
  export interface ApprovedScriptExportRow {
647
670
  exportId: string;
648
671
  draftId: string;
@@ -655,6 +678,8 @@ export interface ApprovedScriptExportRow {
655
678
  deliveredAt?: string;
656
679
  deliveryAttempted?: number;
657
680
  deliveryOk?: number;
681
+ approvalTimeSource?: 'stamped' | 'legacy_updated_at';
682
+ approvedContentDigest?: string;
658
683
  }
659
684
  /** What `POST /v1/sessions` actually returns for a WORLD mint.
660
685
  *
@@ -1012,8 +1037,30 @@ export declare class PouchyWorldClient {
1012
1037
  version?: 1 | 2;
1013
1038
  }): Promise<ApprovedScriptExportRow>;
1014
1039
  listApprovedExports(environmentId: string, worldInstanceId: string, draftId: string, editorialId: string): Promise<{
1015
- exports: unknown[];
1040
+ exports: ApprovedScriptExportSummary[];
1016
1041
  }>;
1042
+ /** Read ONE approved export, script included — the machine lane's read.
1043
+ *
1044
+ * This is the call an unattended backend makes. With `adminKey` set it goes
1045
+ * to the `/admin` mirror and needs no browser anywhere in your deployment;
1046
+ * with an `adminToken` it goes to the owner plane. Same mechanism as
1047
+ * `getProgress` and `getTurn`.
1048
+ *
1049
+ * Every field it needs is in the `world.script_approved` webhook you
1050
+ * received: `exportId` at the top level, and `environmentId`,
1051
+ * `worldInstanceId`, `evidenceDraftId` and `editorialDraftId` inside
1052
+ * `lineage`. So the webhook → read loop closes without a person in it.
1053
+ *
1054
+ * It READS. It does not create, approve or re-approve: minting an export is
1055
+ * a reviewer signing off on a specific text, and that stays on the owner
1056
+ * plane with a human behind it. What comes back cannot change — `exportId`
1057
+ * is the content digest of the body it returns.
1058
+ *
1059
+ * Narrow `content.contractVersion` before reading version-specific fields.
1060
+ * A miss of any kind — wrong instance, wrong draft, wrong id — is one 404;
1061
+ * they are not told apart, so a caller cannot map an id space by reading
1062
+ * refusals. */
1063
+ getApprovedExport(environmentId: string, worldInstanceId: string, draftId: string, editorialId: string, exportId: string): Promise<ApprovedScriptExportRow>;
1017
1064
  /** The next Story Package as a CANDIDATE — validated, and returned rather
1018
1065
  * than published. Publishing it is a separate act by a person, through
1019
1066
  * `createStoryPackage`. Only evidence-origin material becomes canon.
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.18.0';
26
+ export const WORLD_SDK_VERSION = '0.19.0';
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
@@ -475,6 +475,30 @@ export class PouchyWorldClient {
475
475
  listApprovedExports(environmentId, worldInstanceId, draftId, editorialId) {
476
476
  return this.owner('GET', `/projects/${this.projectId}/environments/${environmentId}/instances/${worldInstanceId}/script-drafts/${draftId}/editorial/${editorialId}/approved-export`);
477
477
  }
478
+ /** Read ONE approved export, script included — the machine lane's read.
479
+ *
480
+ * This is the call an unattended backend makes. With `adminKey` set it goes
481
+ * to the `/admin` mirror and needs no browser anywhere in your deployment;
482
+ * with an `adminToken` it goes to the owner plane. Same mechanism as
483
+ * `getProgress` and `getTurn`.
484
+ *
485
+ * Every field it needs is in the `world.script_approved` webhook you
486
+ * received: `exportId` at the top level, and `environmentId`,
487
+ * `worldInstanceId`, `evidenceDraftId` and `editorialDraftId` inside
488
+ * `lineage`. So the webhook → read loop closes without a person in it.
489
+ *
490
+ * It READS. It does not create, approve or re-approve: minting an export is
491
+ * a reviewer signing off on a specific text, and that stays on the owner
492
+ * plane with a human behind it. What comes back cannot change — `exportId`
493
+ * is the content digest of the body it returns.
494
+ *
495
+ * Narrow `content.contractVersion` before reading version-specific fields.
496
+ * A miss of any kind — wrong instance, wrong draft, wrong id — is one 404;
497
+ * they are not told apart, so a caller cannot map an id space by reading
498
+ * refusals. */
499
+ getApprovedExport(environmentId, worldInstanceId, draftId, editorialId, exportId) {
500
+ return this.read(`/projects/${this.projectId}/environments/${environmentId}/instances/${worldInstanceId}/script-drafts/${draftId}/editorial/${editorialId}/approved-export/${encodeURIComponent(exportId)}`, `/admin/environments/${environmentId}/instances/${worldInstanceId}/script-drafts/${draftId}/editorial/${editorialId}/approved-export/${encodeURIComponent(exportId)}`);
501
+ }
478
502
  /** The next Story Package as a CANDIDATE — validated, and returned rather
479
503
  * than published. Publishing it is a separate act by a person, through
480
504
  * `createStoryPackage`. Only evidence-origin material becomes canon.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pouchy_ai/world-sdk",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
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",