@zweer/mage-space-client 1.1.1 → 1.1.2

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/dist/index.cjs CHANGED
@@ -952,6 +952,14 @@ var HistoryService = class {
952
952
  //#endregion
953
953
  //#region lib/http.ts
954
954
  const DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
955
+ /**
956
+ * Known RSC error digests mapped to human-readable messages.
957
+ * Discovered via reverse engineering; the server does not expose error details.
958
+ */
959
+ const KNOWN_DIGESTS = {
960
+ "709776019": "Username already taken (duplicate character/reference username)",
961
+ "1853426377": "Username already taken (duplicate character/reference username)"
962
+ };
955
963
  var HttpClient = class {
956
964
  registry;
957
965
  fetchImpl;
@@ -989,8 +997,11 @@ var HttpClient = class {
989
997
  }
990
998
  if (!res.ok) {
991
999
  const body = await safeText(res);
992
- const suffix = body.length > 0 ? ` — ${body.slice(0, 200)}` : "";
993
- throw new MageSpaceError(`Action "${params.action}" failed: HTTP ${res.status}${suffix}`);
1000
+ const digest = body.match(/E\{"digest":"([^"]+)"\}/)?.[1];
1001
+ const knownDigest = digest !== void 0 ? KNOWN_DIGESTS[digest] : void 0;
1002
+ const hint = knownDigest ? ` — ${knownDigest}` : digest ? ` (server digest: ${digest})` : "";
1003
+ const raw = body.length > 0 ? ` — ${body.slice(0, 200)}` : "";
1004
+ throw new MageSpaceError(`Action "${params.action}" failed: HTTP ${res.status}${hint}${raw}`);
994
1005
  }
995
1006
  return {
996
1007
  data: parseServerActionResponse(await res.text()),
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../lib/types.ts","../lib/actions.ts","../lib/http.ts","../lib/auth.ts","../lib/characters.ts","../lib/references.ts","../lib/client.ts","../lib/errors.ts","../lib/rsc.ts","../lib/seed.ts","../lib/index.ts"],"mappings":";;;;;;;;;KASY,aA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EAKxD,UAAU,oBAAoB,QAAQ;;EAKtC,cAAc,mBAAmB,UAAU,cAAc,QAAQ;;EAKjE,UAAU,oBAAoB;;EAK9B,YAAY,UAAU,qBAAqB,QAAQ;;EAKnD,cAAc,UAAU,uBAAuB,QAAQ;;EAKvD,aAAa,QAAQ,mBAAmB;;EAKxC,cAAc,mBAAmB,UAAU,iBAAiB;;EAK5D,oBAAoB,sBAAsB,UAAU,iBAAiB;;EAKrE,eAAe,oBAAoB,UAAU,iBAAiB;;EAK9D,oBAAoB,uBAAuB,UAAU,iBAAiB;;EAKtE,kBAAkB,QAAQ;;EAK1B,UAAU;;;;;;cCnIC,uBAAuB;EAClC,YAAY,iBAAiB;IAAY;;;;cAO9B,kBAAkB;EAC7B,YAAY,iBAAiB;IAAY;;;;cAO9B,uBAAuB;EAClC,YAAY,iBAAiB;IAAY;;;;cAO9B,yBAAyB;WAElB;EADlB,YACkB,gBAChB;IAAY;;;;cAQH,wBAAwB;WAGjB;EAFlB,YACE,iBACgB,2BAChB;IAAY;;;;cAQH,sBAAsB;EACjC,YAAY,iBAAiB;IAAY;;;;cAO9B,qBAAqB;EAChC,YAAY,iBAAiB;IAAY;;;;;;;;;;;;;;;;;iBCL3B,gBAAgB,eAAe;;iBAmE/B,mBACd,gBACA,MAAM,sBACN,OAAM;;;;;;iBA4CQ,0BAA0B,aAAa,eAAe;;;;;;;;;;;;iBA8BtD,aAAa,GAAG,iBAAiB;;;;;;;;;;;;cC3LpC,eAAe;;;;cCVf"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../lib/types.ts","../lib/actions.ts","../lib/http.ts","../lib/auth.ts","../lib/characters.ts","../lib/references.ts","../lib/client.ts","../lib/errors.ts","../lib/rsc.ts","../lib/seed.ts","../lib/index.ts"],"mappings":";;;;;;;;;KASY,aAAa,eAAe,OAAO,gBAAgB,QAAQ;;UAOtD;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;;KAQU;;KAmCA,eAAe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AU,qBAAqB,QAAQ;;EAKnD,cAAc,UAAU,uBAAuB,QAAQ;;EAKvD,aAAa,QAAQ,mBAAmB;;EAKxC,cAAc,mBAAmB,UAAU,iBAAiB;;EAK5D,oBAAoB,sBAAsB,UAAU,iBAAiB;;EAKrE,eAAe,oBAAoB,UAAU,iBAAiB;;EAK9D,oBAAoB,uBAAuB,UAAU,iBAAiB;;EAKtE,kBAAkB,QAAQ;;EAK1B,UAAU;;;;;;cCnIC,uBAAuB;EAClC,YAAY,iBAAiB;IAAY;;;;cAO9B,kBAAkB;EAC7B,YAAY,iBAAiB;IAAY;;;;cAO9B,uBAAuB;EAClC,YAAY,iBAAiB;IAAY;;;;cAO9B,yBAAyB;WAElB;EADlB,YACkB,gBAChB;IAAY;;;;cAQH,wBAAwB;WAGjB;EAFlB,YACE,iBACgB,2BAChB;IAAY;;;;cAQH,sBAAsB;EACjC,YAAY,iBAAiB;IAAY;;;;cAO9B,qBAAqB;EAChC,YAAY,iBAAiB;IAAY;;;;;;;;;;;;;;;;;iBCL3B,gBAAgB,eAAe;;iBAmE/B,mBACd,gBACA,MAAM,sBACN,OAAM;;;;;;iBA4CQ,0BAA0B,aAAa,eAAe;;;;;;;;;;;;iBA8BtD,aAAa,GAAG,iBAAiB;;;;;;;;;;;;cC3LpC,eAAe;;;;cCVf"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../lib/types.ts","../lib/actions.ts","../lib/http.ts","../lib/auth.ts","../lib/characters.ts","../lib/references.ts","../lib/client.ts","../lib/errors.ts","../lib/rsc.ts","../lib/seed.ts","../lib/index.ts"],"mappings":";;;;;;;;;KASY,aAAa,eAAe,OAAO,gBAAgB,QAAQ;;UAOtD;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;;KAQU;;KAmCA,eAAe;;UAGV;;EAEf;;EAEA,QAAQ;;EAER;;;;;;;;;;UAWe;EACf,QAAQ,QAAQ;EAChB,KAAK,UAAU,iBAAiB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mBAAmB,UAAU,iBAAiB;;EAK5D,oBAAoB,sBAAsB,UAAU,iBAAiB;;EAKrE,eAAe,oBAAoB,UAAU,iBAAiB;;EAK9D,oBAAoB,uBAAuB,UAAU,iBAAiB;;EAKtE,kBAAkB,QAAQ;;EAK1B,UAAU;;;;;;cCnIC,uBAAuB;EAClC,YAAY,iBAAiB;IAAY;;;;cAO9B,kBAAkB;EAC7B,YAAY,iBAAiB;IAAY;;;;cAO9B,uBAAuB;EAClC,YAAY,iBAAiB;IAAY;;;;cAO9B,yBAAyB;WAElB;EADlB,YACkB,gBAChB;IAAY;;;;cAQH,wBAAwB;WAGjB;EAFlB,YACE,iBACgB,2BAChB;IAAY;;;;cAQH,sBAAsB;EACjC,YAAY,iBAAiB;IAAY;;;;cAO9B,qBAAqB;EAChC,YAAY,iBAAiB;IAAY;;;;;;;;;;;;;;;;;iBCL3B,gBAAgB,eAAe;;iBAmE/B,mBACd,gBACA,MAAM,sBACN,OAAM;;;;;;iBA4CQ,0BAA0B,aAAa,eAAe;;;;;;;;;;;;iBA8BtD,aAAa,GAAG,iBAAiB;;;;;;;;;;;;cC3LpC,eAAe;;;;cCVf"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../lib/types.ts","../lib/actions.ts","../lib/http.ts","../lib/auth.ts","../lib/characters.ts","../lib/references.ts","../lib/client.ts","../lib/errors.ts","../lib/rsc.ts","../lib/seed.ts","../lib/index.ts"],"mappings":";;;;;;;;;KASY,aAAa,eAAe,OAAO,gBAAgB,QAAQ;;UAOtD;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;;KAQU;;KAmCA,eAAe;;UAGV;;EAEf;;EAEA,QAAQ;;EAER;;;;;;;;;;UAWe;EACf,QAAQ,QAAQ;EAChB,KAAK,UAAU,iBAAiB;;KAOtB;KACA;;KAEA;;KAEA;;UAGK;EACf;EACA;EACA;EACA;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;;E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AAoB,uBAAuB,UAAU,iBAAiB;;EAKtE,kBAAkB,QAAQ;;EAK1B,UAAU;;;;;;cCnIC,uBAAuB;EAClC,YAAY,iBAAiB;IAAY;;;;cAO9B,kBAAkB;EAC7B,YAAY,iBAAiB;IAAY;;;;cAO9B,uBAAuB;EAClC,YAAY,iBAAiB;IAAY;;;;cAO9B,yBAAyB;WAElB;EADlB,YACkB,gBAChB;IAAY;;;;cAQH,wBAAwB;WAGjB;EAFlB,YACE,iBACgB,2BAChB;IAAY;;;;cAQH,sBAAsB;EACjC,YAAY,iBAAiB;IAAY;;;;cAO9B,qBAAqB;EAChC,YAAY,iBAAiB;IAAY;;;;;;;;;;;;;;;;;iBCL3B,gBAAgB,eAAe;;iBAmE/B,mBACd,gBACA,MAAM,sBACN,OAAM;;;;;;iBA4CQ,0BAA0B,aAAa,eAAe;;;;;;;;;;;;iBA8BtD,aAAa,GAAG,iBAAiB;;;;;;;;;;;;cC3LpC,eAAe;;;;cCVf"}
package/dist/index.mjs CHANGED
@@ -951,6 +951,14 @@ var HistoryService = class {
951
951
  //#endregion
952
952
  //#region lib/http.ts
953
953
  const DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
954
+ /**
955
+ * Known RSC error digests mapped to human-readable messages.
956
+ * Discovered via reverse engineering; the server does not expose error details.
957
+ */
958
+ const KNOWN_DIGESTS = {
959
+ "709776019": "Username already taken (duplicate character/reference username)",
960
+ "1853426377": "Username already taken (duplicate character/reference username)"
961
+ };
954
962
  var HttpClient = class {
955
963
  registry;
956
964
  fetchImpl;
@@ -988,8 +996,11 @@ var HttpClient = class {
988
996
  }
989
997
  if (!res.ok) {
990
998
  const body = await safeText(res);
991
- const suffix = body.length > 0 ? ` — ${body.slice(0, 200)}` : "";
992
- throw new MageSpaceError(`Action "${params.action}" failed: HTTP ${res.status}${suffix}`);
999
+ const digest = body.match(/E\{"digest":"([^"]+)"\}/)?.[1];
1000
+ const knownDigest = digest !== void 0 ? KNOWN_DIGESTS[digest] : void 0;
1001
+ const hint = knownDigest ? ` — ${knownDigest}` : digest ? ` (server digest: ${digest})` : "";
1002
+ const raw = body.length > 0 ? ` — ${body.slice(0, 200)}` : "";
1003
+ throw new MageSpaceError(`Action "${params.action}" failed: HTTP ${res.status}${hint}${raw}`);
993
1004
  }
994
1005
  return {
995
1006
  data: parseServerActionResponse(await res.text()),
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["UNDEFINED"],"sources":["../lib/errors.ts","../lib/actions.ts","../lib/rsc.ts","../lib/characters.ts","../lib/auth.ts","../lib/generation.ts","../lib/history.ts","../lib/http.ts","../lib/references.ts","../lib/seed.ts","../lib/client.ts","../lib/index.ts"],"sourcesContent":["/** Typed error hierarchy for the mage.space client. */\n\n/** Base class for every error thrown by this library. */\nexport class MageSpaceError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'MageSpaceError';\n }\n}\n\n/** Authentication failures (token refresh, session creation). */\nexport class AuthError extends MageSpaceError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'AuthError';\n }\n}\n\n/** Action-hash discovery failures (page/chunk fetch, empty registry). */\nexport class DiscoveryError extends MageSpaceError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'DiscoveryError';\n }\n}\n\n/** A Server Action returned 404, indicating a stale (post-deploy) hash. */\nexport class StaleActionError extends MageSpaceError {\n constructor(\n public readonly action: string,\n options?: { cause?: unknown },\n ) {\n super(`Action \"${action}\" returned 404 (stale hash)`, options);\n this.name = 'StaleActionError';\n }\n}\n\n/** Failures while submitting or polling a generation job. */\nexport class GenerationError extends MageSpaceError {\n constructor(\n message: string,\n public readonly code?: number,\n options?: { cause?: unknown },\n ) {\n super(message, options);\n this.name = 'GenerationError';\n }\n}\n\n/** Failure to parse a React Server Component (RSC) wire response. */\nexport class RscParseError extends MageSpaceError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'RscParseError';\n }\n}\n\n/** A wait/poll operation exceeded its deadline or was aborted. */\nexport class TimeoutError extends MageSpaceError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Guard for irreversible operations: throws unless `{ confirm: true }` is passed.\n *\n * @throws {MageSpaceError} when confirmation is missing.\n */\nexport function requireConfirm(action: string, opts?: { confirm?: boolean }): void {\n if (opts?.confirm !== true) {\n throw new MageSpaceError(\n `${action} is irreversible and requires explicit confirmation: pass { confirm: true }`,\n );\n }\n}\n","/**\n * Action-hash discovery and caching.\n *\n * mage.space's Server Action hashes change on every Vercel deploy, so the client\n * discovers them from the page's JS bundles and caches the result. The registry\n * serves hashes from a warm seed / cache and only re-discovers when a hash goes\n * stale (a request 404s) or when explicitly refreshed.\n */\nimport { DiscoveryError } from './errors.js';\nimport type { ActionCache, ActionName, ActionSnapshot, FetchLike } from './types.js';\n\n/** `createServerReference)(\"<hash>\", callServer, void 0, findSourceMapURL, \"<fn>\")` */\nconst CREATE_SERVER_REF_RE = /createServerReference\\)\\(\"([0-9a-f]+)\"[^)]*?\"([^\"]+)\"\\)/g;\n/** `/_next/static/chunks/....js` references in the page HTML. */\nconst CHUNK_RE = /\\/_next\\/static\\/chunks\\/[^\"'`()\\s]+?\\.js/g;\n/**\n * Default pages scraped during discovery. Server Actions are split per route, so\n * a single page misses route-specific actions (e.g. `deleteReference` lives only\n * in the `/references` bundle) — scrape the main routes and union their chunks.\n */\nconst DISCOVERY_PAGES = ['/explore', '/creations', '/characters', '/references'];\n\n/** Default in-process snapshot cache. */\nexport class InMemoryActionCache implements ActionCache {\n private snapshot: ActionSnapshot | null = null;\n\n async load(): Promise<ActionSnapshot | null> {\n return this.snapshot;\n }\n\n async save(snapshot: ActionSnapshot): Promise<void> {\n this.snapshot = snapshot;\n }\n}\n\nexport interface DiscoveryOptions {\n fetch: FetchLike;\n baseUrl: string;\n /** Single page to scrape for chunk references (overrides {@link discoveryPaths}). */\n discoveryPath?: string;\n /** Pages to scrape and union (default: the main app routes). */\n discoveryPaths?: string[];\n}\n\n/**\n * Discover the current Server Action hashes by scraping the page HTML for JS\n * chunk URLs and extracting `createServerReference(...)` calls from each chunk.\n *\n * @throws {DiscoveryError} on network failure or when nothing is discovered.\n */\nexport async function discoverActions(opts: DiscoveryOptions): Promise<ActionSnapshot> {\n const { fetch, baseUrl } = opts;\n const pages =\n opts.discoveryPath !== undefined\n ? [opts.discoveryPath]\n : (opts.discoveryPaths ?? DISCOVERY_PAGES);\n\n let deploymentId = '';\n const chunkPaths = new Set<string>();\n for (const page of pages) {\n let res: Response;\n try {\n res = await fetch(`${baseUrl}${page}`, { headers: { accept: 'text/html' } });\n } catch {\n // A single unreachable page must not abort discovery.\n continue;\n }\n if (!res.ok) {\n continue;\n }\n if (deploymentId === '') {\n deploymentId = res.headers.get('x-deployment-id') ?? '';\n }\n const html = await res.text();\n for (const match of html.matchAll(CHUNK_RE)) {\n const chunkPath = match[0];\n if (chunkPath !== undefined) {\n chunkPaths.add(chunkPath);\n }\n }\n }\n if (chunkPaths.size === 0) {\n throw new DiscoveryError('No JS chunk references found in discovery pages');\n }\n\n const hashes: ActionSnapshot['hashes'] = {};\n await Promise.all(\n [...chunkPaths].map(async (path) => {\n try {\n const chunkRes = await fetch(`${baseUrl}${path}`, {\n headers: { accept: 'application/javascript' },\n });\n if (!chunkRes.ok) {\n return;\n }\n // Fallback: CDN-cached page HTML may omit x-deployment-id; chunk responses\n // are served by the deployment and usually carry it.\n if (deploymentId === '') {\n deploymentId = chunkRes.headers.get('x-deployment-id') ?? '';\n }\n const js = await chunkRes.text();\n for (const match of js.matchAll(CREATE_SERVER_REF_RE)) {\n const hash = match[1];\n const fn = match[2];\n if (hash !== undefined && fn !== undefined && !(fn in hashes)) {\n hashes[fn] = hash;\n }\n }\n } catch {\n // A single failed chunk must not abort discovery.\n }\n }),\n );\n\n if (Object.keys(hashes).length === 0) {\n throw new DiscoveryError('No server action hashes discovered in JS chunks');\n }\n return { deploymentId, hashes, discoveredAt: Date.now() };\n}\n\nexport interface ActionRegistryOptions {\n fetch: FetchLike;\n baseUrl: string;\n cache?: ActionCache;\n seed?: ActionSnapshot;\n discoveryPath?: string;\n discoveryPaths?: string[];\n /** Re-discover when the snapshot is older than this (ms). 0 = never by age. */\n maxAgeMs?: number;\n}\n\n/**\n * Serves action hashes from a warm seed / pluggable cache, discovering lazily and\n * refreshing on staleness. Concurrent refreshes are de-duplicated (single-flight).\n */\nexport class ActionRegistry {\n private readonly fetch: FetchLike;\n private readonly baseUrl: string;\n private readonly cache: ActionCache;\n private readonly seed: ActionSnapshot | undefined;\n private readonly discoveryPath: string | undefined;\n private readonly discoveryPaths: string[] | undefined;\n private readonly maxAgeMs: number;\n private snapshot: ActionSnapshot | null = null;\n private inflight: Promise<ActionSnapshot> | null = null;\n\n constructor(opts: ActionRegistryOptions) {\n this.fetch = opts.fetch;\n this.baseUrl = opts.baseUrl;\n this.cache = opts.cache ?? new InMemoryActionCache();\n this.seed = opts.seed;\n this.discoveryPath = opts.discoveryPath;\n this.discoveryPaths = opts.discoveryPaths;\n this.maxAgeMs = opts.maxAgeMs ?? 0;\n }\n\n private isStale(snapshot: ActionSnapshot): boolean {\n return this.maxAgeMs > 0 && Date.now() - snapshot.discoveredAt > this.maxAgeMs;\n }\n\n /** Return the current snapshot, loading from cache/seed or discovering as needed. */\n async getSnapshot(): Promise<ActionSnapshot> {\n if (this.snapshot !== null && !this.isStale(this.snapshot)) {\n return this.snapshot;\n }\n const cached = await this.cache.load();\n if (cached !== null && !this.isStale(cached)) {\n this.snapshot = cached;\n return cached;\n }\n if (this.seed !== undefined) {\n this.snapshot = this.seed;\n await this.cache.save(this.seed);\n return this.seed;\n }\n return this.refresh();\n }\n\n /** Force re-discovery. Concurrent callers share one in-flight discovery. */\n async refresh(): Promise<ActionSnapshot> {\n if (this.inflight !== null) {\n return this.inflight;\n }\n this.inflight = (async () => {\n try {\n const fresh = await discoverActions({\n fetch: this.fetch,\n baseUrl: this.baseUrl,\n discoveryPath: this.discoveryPath,\n discoveryPaths: this.discoveryPaths,\n });\n this.snapshot = fresh;\n await this.cache.save(fresh);\n return fresh;\n } finally {\n this.inflight = null;\n }\n })();\n return this.inflight;\n }\n\n /** Resolve a function name to its current hash + deployment id. */\n async getHash(action: ActionName | string): Promise<{ hash: string; deploymentId: string }> {\n let snapshot = await this.getSnapshot();\n let hash = snapshot.hashes[action];\n if (hash === undefined) {\n snapshot = await this.refresh();\n hash = snapshot.hashes[action];\n }\n if (hash === undefined) {\n throw new DiscoveryError(`Action \"${action}\" not found after discovery`);\n }\n return { hash, deploymentId: snapshot.deploymentId };\n }\n\n /** Drop the cached snapshot and re-discover (called on a stale 404). */\n async invalidate(): Promise<ActionSnapshot> {\n this.snapshot = null;\n return this.refresh();\n }\n}\n","/**\n * Minimal parser for the React Server Component (RSC) \"Flight\" wire format used\n * by Next.js Server Action responses.\n *\n * The wire format is a sequence of newline-delimited rows:\n *\n * ```text\n * 0:{\"a\":\"$@1\",\"f\":\"\",\"b\":\"buildId\"}\n * 1:{\"history_id\":\"e3357fb8-...\",\"architecture_config\":\"$T0:0:architectureConfig\"}\n * ```\n *\n * Each row is `<hexId>:<jsonPayload>`. Values may contain sentinels:\n * - `$undefined` → `undefined`\n * - `$@<id>` → reference to another row (a resolved promise)\n * - `$$...` → an escaped literal string starting with `$`\n * - `$<other>` → a typed marker (kept verbatim, best-effort)\n *\n * @remarks\n * The exact envelope for some read actions (e.g. `getHistoryById`) should be\n * confirmed against live traffic via the rev-eng Playwright flow; this parser is\n * intentionally tolerant and falls back to the last JSON row when the row-0\n * `{ a: ... }` envelope is absent.\n */\nimport { RscParseError } from './errors.js';\n\nconst REF_RE = /^\\$@([0-9a-f]+)$/i;\n/** A plain row reference like `$5` (not a promise `$@5`, nor a `$D`/`$S`/... marker). */\nconst HEX_REF_RE = /^\\$([0-9a-f]+)$/i;\nconst ROW_ID_RE = /^[0-9a-f]+$/i;\n\n/** Return the char index after consuming exactly `byteLen` UTF-8 bytes from `start`. */\nfunction endOfUtf8Slice(text: string, start: number, byteLen: number): number {\n let bytes = 0;\n let i = start;\n while (i < text.length && bytes < byteLen) {\n const cp = text.codePointAt(i) as number;\n bytes += cp <= 0x7f ? 1 : cp <= 0x7ff ? 2 : cp <= 0xffff ? 3 : 4;\n i += cp > 0xffff ? 2 : 1;\n }\n return i;\n}\n\n/**\n * Parse the raw Flight text into a map of `rowId → value`.\n *\n * @remarks\n * Most rows are `id:<json>\\n`, but text rows are length-delimited:\n * `id:T<hexlen>,<hexlen UTF-8 bytes>` and are NOT newline-terminated — the next\n * row begins immediately after the counted bytes. A naive line split therefore\n * glues the following data row onto a multi-line prompt (which is exactly why\n * large `getHistoryPaginated` responses failed to parse). This parser is\n * position/length aware so length-delimited rows are consumed exactly and every\n * subsequent row stays isolated.\n */\nexport function parseFlightRows(text: string): Map<string, unknown> {\n const rows = new Map<string, unknown>();\n const n = text.length;\n let pos = 0;\n while (pos < n) {\n if (text[pos] === '\\n') {\n pos += 1;\n continue;\n }\n const colon = text.indexOf(':', pos);\n if (colon === -1) {\n break;\n }\n const id = text.slice(pos, colon);\n if (!ROW_ID_RE.test(id)) {\n // Not a row boundary; skip to the next line and resync.\n const nl = text.indexOf('\\n', pos);\n if (nl === -1) {\n break;\n }\n pos = nl + 1;\n continue;\n }\n if (text[colon + 1] === 'T') {\n // Length-delimited text row: T<hexlen>,<bytes> (no trailing newline).\n const comma = text.indexOf(',', colon + 2);\n if (comma === -1) {\n break;\n }\n const byteLen = Number.parseInt(text.slice(colon + 2, comma), 16);\n const start = comma + 1;\n const end = endOfUtf8Slice(text, start, byteLen);\n rows.set(id, text.slice(start, end));\n pos = end;\n continue;\n }\n // Any other row is a single line terminated by \\n.\n const nl = text.indexOf('\\n', colon + 1);\n const payload = nl === -1 ? text.slice(colon + 1) : text.slice(colon + 1, nl);\n pos = nl === -1 ? n : nl + 1;\n const first = payload[0];\n if (first === undefined) {\n continue;\n }\n const looksJson =\n first === '{' ||\n first === '[' ||\n first === '\"' ||\n first === '-' ||\n (first >= '0' && first <= '9') ||\n payload === 'true' ||\n payload === 'false' ||\n payload === 'null';\n if (!looksJson) {\n // Module/element/hint rows (e.g. `1:I[...]`, `2:\"$Sreact...\"`) are not data.\n continue;\n }\n try {\n rows.set(id, JSON.parse(payload));\n } catch {\n // Ignore rows that are not valid JSON.\n }\n }\n return rows;\n}\n\n/** Recursively resolve Flight sentinels/references within a parsed value. */\nexport function resolveFlightValue(\n value: unknown,\n rows: Map<string, unknown>,\n seen: Set<string> = new Set(),\n): unknown {\n if (typeof value === 'string') {\n if (value === '$undefined') {\n return undefined;\n }\n const ref = REF_RE.exec(value) ?? HEX_REF_RE.exec(value);\n if (ref) {\n const refId = ref[1];\n if (refId === undefined || seen.has(refId)) {\n return undefined;\n }\n seen.add(refId);\n const target = rows.get(refId);\n return target === undefined ? undefined : resolveFlightValue(target, rows, seen);\n }\n if (value.startsWith('$$')) {\n return value.slice(1);\n }\n // $D<iso> → Date object (React Flight Date sentinel).\n if (value.startsWith('$D')) {\n return new Date(value.slice(2));\n }\n // Other `$`-prefixed markers are kept verbatim.\n return value;\n }\n if (Array.isArray(value)) {\n return value.map((entry) => resolveFlightValue(entry, rows, seen));\n }\n if (value !== null && typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n out[key] = resolveFlightValue(entry, rows, seen);\n }\n return out;\n }\n return value;\n}\n\n/**\n * Parse a Server Action response and return the action's resolved return value.\n *\n * @throws {RscParseError} when the response contains no parseable rows.\n */\nexport function parseServerActionResponse<T = unknown>(text: string): T {\n const rows = parseFlightRows(text);\n if (rows.size === 0) {\n throw new RscParseError('Empty or unparseable RSC response');\n }\n const root = rows.get('0');\n if (root !== null && typeof root === 'object' && !Array.isArray(root) && 'a' in root) {\n return resolveFlightValue((root as Record<string, unknown>).a, rows) as T;\n }\n // Fallback: the highest-id row usually carries the payload.\n let lastId: string | null = null;\n for (const id of rows.keys()) {\n if (lastId === null || Number.parseInt(id, 16) > Number.parseInt(lastId, 16)) {\n lastId = id;\n }\n }\n return resolveFlightValue(lastId === null ? undefined : rows.get(lastId), rows) as T;\n}\n\n/**\n * Unwrap a single-object result that some Server Actions (notably the\n * `*Parallel` family) wrap in a one-element array.\n *\n * @remarks\n * `getCreationsPaginatedParallel` and `getMentionSuggestionsParallel` return their\n * payload as `[value]` on the RSC wire (`1:[\"$@2\"]`), whereas most actions return\n * the value directly. This normalizes object-returning actions to the value; it is\n * a no-op when the response is already the object. Do NOT use it for actions whose\n * genuine return type is an array (e.g. `getReferences`).\n */\nexport function unwrapResult<T>(value: unknown): T {\n return (Array.isArray(value) && value.length === 1 ? value[0] : value) as T;\n}\n","/**\n * Character & reference management.\n *\n * Covers the verified Server Actions from `docs/api/characters.md`: search\n * (`getMentionSuggestionsParallel`), full CRUD, pagination, publish/unpublish,\n * and base64 image uploads.\n *\n * @remarks\n * Read operations pass the caller's `uid` in the body; write operations rely on\n * the `__session` cookie (the server derives the uid from it). All actions are\n * posted to the `/explore` page where their bundles are loaded.\n */\nimport type { AuthManager } from './auth.js';\nimport type { HttpClient } from './http.js';\nimport { unwrapResult } from './rsc.js';\nimport type {\n Character,\n CharacterPage,\n CharacterSearchResult,\n CreateCharacterInput,\n GenerateVoiceOptions,\n ListCharactersOptions,\n SearchCharactersOptions,\n UpdateCharacterInput,\n VoiceResult,\n} from './types.js';\n\n/** Character actions are served from the `/explore` page. */\nconst CHARACTERS_PATH = '/explore';\nconst DEFAULT_SEARCH_LIMIT = 10;\n\nexport class CharactersService {\n constructor(\n private readonly http: HttpClient,\n private readonly auth: AuthManager,\n ) {}\n\n /** Search the caller's characters (and optionally public references) by name. */\n async search(opts: SearchCharactersOptions): Promise<CharacterSearchResult> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const body = {\n query: opts.query,\n uid,\n limit: opts.limit ?? DEFAULT_SEARCH_LIMIT,\n includePublicReferences: opts.includePublicReferences ?? false,\n referenceModalities: opts.referenceModalities ?? ['image', 'audio'],\n };\n const { data } = await this.http.callAction<CharacterSearchResult>({\n action: 'getMentionSuggestionsParallel',\n path: CHARACTERS_PATH,\n args: [body],\n session,\n });\n return unwrapResult<CharacterSearchResult>(data);\n }\n\n /** Create a new character from an already-uploaded image URL. */\n async create(input: CreateCharacterInput): Promise<Character> {\n const session = await this.auth.getSession();\n const body = {\n name: input.name,\n username: input.username,\n image_url: input.image_url,\n audio_url: input.audio_url ?? null,\n description: input.description ?? null,\n tags: input.tags ?? [],\n visibility: input.visibility ?? 'private',\n moderation: input.moderation ?? [],\n };\n const { data } = await this.http.callAction<Character>({\n action: 'createCharacter',\n path: CHARACTERS_PATH,\n args: [body],\n session,\n });\n return data;\n }\n\n /** Update a character's mutable fields (name, description, tags, visibility, voice). */\n async update(id: string, patch: UpdateCharacterInput): Promise<Character> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<Character>({\n action: 'updateCharacter',\n path: CHARACTERS_PATH,\n args: [id, patch],\n session,\n });\n return data;\n }\n\n /** Soft-delete a character. */\n async delete(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n\n /** Fetch a single character by id; resolves to `null` when it does not exist. */\n async get(id: string): Promise<Character | null> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<Character | null>({\n action: 'getCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n return data ?? null;\n }\n\n /** Fetch multiple characters by id in a single call. */\n async getMany(ids: string[]): Promise<Character[]> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<Character[]>({\n action: 'getCharacters',\n path: CHARACTERS_PATH,\n args: [ids],\n session,\n });\n return data ?? [];\n }\n\n /** Make a character public. */\n async publish(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'publishCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n\n /** Make a character private. */\n async unpublish(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'unpublishCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n\n /**\n * Upload a character reference image (base64 data URL) and return its CDN URL.\n *\n * @param dataUrl - `data:image/jpeg;base64,...` (JPEG preferred; PNG/WebP ok).\n */\n async uploadImage(dataUrl: string): Promise<string> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const { data } = await this.http.callAction<string>({\n action: 'uploadCharacterImage',\n path: CHARACTERS_PATH,\n args: [dataUrl, uid],\n session,\n });\n return data;\n }\n\n /**\n * Browse characters with pagination.\n *\n * @remarks\n * Omit `uid` to browse the public/featured feed; pass it to page through a\n * single user's characters.\n */\n async listPaginated(opts: ListCharactersOptions = {}): Promise<CharacterPage> {\n const session = await this.auth.getSession();\n const limit = opts.limit ?? 100;\n const offset = opts.offset ?? 0;\n const filters: Record<string, unknown> = {};\n if (opts.uid !== undefined) {\n filters.uid = opts.uid;\n }\n if (opts.visibility !== undefined) {\n filters.visibility = opts.visibility;\n }\n if (opts.modality !== undefined) {\n filters.modality = opts.modality;\n }\n if (opts.featured !== undefined) {\n filters.featured = opts.featured;\n }\n const { data } = await this.http.callAction<CharacterPage>({\n action: 'getCharactersPaginated',\n path: CHARACTERS_PATH,\n args: [limit, offset, filters],\n session,\n });\n return data;\n }\n\n /**\n * Generate a voice for a character from its reference image.\n *\n * @remarks Costs gems (not covered by the unlimited tier).\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async generateVoice(opts: GenerateVoiceOptions): Promise<VoiceResult> {\n const [authToken, session] = await Promise.all([\n this.auth.getIdToken(),\n this.auth.getSession(),\n ]);\n const { data } = await this.http.callAction<VoiceResult>({\n action: 'generateCharacterVoice',\n path: CHARACTERS_PATH,\n args: [{ imageUrl: opts.imageUrl, guidancePrompt: opts.guidancePrompt ?? '' }, authToken],\n session,\n });\n return data;\n }\n\n /**\n * Follow a (public) character.\n *\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async follow(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'followCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n\n /**\n * Unfollow a character.\n *\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async unfollow(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'unfollowCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n}\n","/**\n * Firebase authentication: refresh token → ID token → session cookie.\n *\n * The refresh token is the only long-lived credential the caller supplies.\n * From it we mint a Firebase ID token (~1h) via the Secure Token REST API, and\n * exchange that for a `__session` cookie (~24h) via the `createUserSession`\n * Server Action. Both are cached and refreshed 5 minutes before expiry.\n */\nimport { decodeJwt } from 'jose';\nimport { AuthError } from './errors.js';\nimport type { HttpClient } from './http.js';\nimport type { AuthTokens, FetchLike, SessionState } from './types.js';\n\nconst DEFAULT_FIREBASE_API_KEY = 'AIzaSyAzUV2NNUOlLTL04jwmUw9oLhjteuv6Qr4';\nconst SECURE_TOKEN_URL = 'https://securetoken.googleapis.com/v1/token';\nconst EXPIRY_BUFFER_MS = 5 * 60 * 1000;\nconst SESSION_DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;\nconst ID_TOKEN_DEFAULT_TTL_S = 3600;\n\ninterface SecureTokenResponse {\n id_token?: string;\n refresh_token?: string;\n user_id?: string;\n expires_in?: string;\n}\n\nexport interface AuthManagerOptions {\n refreshToken: string;\n http: HttpClient;\n fetch: FetchLike;\n firebaseApiKey?: string;\n /** Page path for the `createUserSession` action (default `/creations`). */\n sessionPath?: string;\n}\n\nexport class AuthManager {\n private refreshToken: string;\n private readonly http: HttpClient;\n private readonly fetchImpl: FetchLike;\n private readonly apiKey: string;\n private readonly sessionPath: string;\n private tokens: AuthTokens | null = null;\n private session: SessionState | null = null;\n\n constructor(opts: AuthManagerOptions) {\n this.refreshToken = opts.refreshToken;\n this.http = opts.http;\n this.fetchImpl = opts.fetch;\n this.apiKey = opts.firebaseApiKey ?? DEFAULT_FIREBASE_API_KEY;\n this.sessionPath = opts.sessionPath ?? '/creations';\n }\n\n /** Return a valid Firebase ID token, refreshing via the refresh token if needed. */\n async getIdToken(): Promise<string> {\n if (this.tokens !== null && Date.now() < this.tokens.expiresAt - EXPIRY_BUFFER_MS) {\n return this.tokens.idToken;\n }\n return (await this.refreshTokens()).idToken;\n }\n\n /** Return the Firebase uid (fetching an ID token first if necessary). */\n async getUserId(): Promise<string> {\n if (this.tokens !== null) {\n return this.tokens.userId;\n }\n return (await this.refreshTokens()).userId;\n }\n\n /** Return a valid `__session` cookie, creating one via `createUserSession` if needed. */\n async getSession(): Promise<string> {\n if (this.session !== null && Date.now() < this.session.expiresAt - EXPIRY_BUFFER_MS) {\n return this.session.cookie;\n }\n const idToken = await this.getIdToken();\n const result = await this.http.callAction<unknown>({\n action: 'createUserSession',\n path: this.sessionPath,\n args: [idToken],\n });\n const cookie = extractSessionCookie(result.headers);\n if (cookie === null) {\n throw new AuthError('createUserSession did not return a __session cookie');\n }\n const expiresAt = jwtExpiryMs(cookie) ?? Date.now() + SESSION_DEFAULT_TTL_MS;\n this.session = { cookie, expiresAt };\n return cookie;\n }\n\n private async refreshTokens(): Promise<AuthTokens> {\n const body = new URLSearchParams({\n grant_type: 'refresh_token',\n refresh_token: this.refreshToken,\n });\n const res = await this.fetchImpl(`${SECURE_TOKEN_URL}?key=${this.apiKey}`, {\n method: 'POST',\n headers: { 'content-type': 'application/x-www-form-urlencoded' },\n body: body.toString(),\n });\n if (!res.ok) {\n throw new AuthError(\n `Token refresh failed: HTTP ${res.status} (refresh token may be invalid or revoked)`,\n );\n }\n const json = (await res.json()) as SecureTokenResponse;\n if (json.id_token === undefined || json.user_id === undefined) {\n throw new AuthError('Token refresh response missing id_token/user_id');\n }\n if (json.refresh_token !== undefined) {\n this.refreshToken = json.refresh_token;\n }\n const ttlS = json.expires_in === undefined ? ID_TOKEN_DEFAULT_TTL_S : Number(json.expires_in);\n const expiresAt = jwtExpiryMs(json.id_token) ?? Date.now() + ttlS * 1000;\n this.tokens = {\n idToken: json.id_token,\n refreshToken: this.refreshToken,\n userId: json.user_id,\n expiresAt,\n };\n return this.tokens;\n }\n}\n\n/** Read the `exp` claim (ms) from a JWT, or `null` if it cannot be decoded. */\nfunction jwtExpiryMs(jwt: string): number | null {\n try {\n const { exp } = decodeJwt(jwt);\n return typeof exp === 'number' ? exp * 1000 : null;\n } catch {\n return null;\n }\n}\n\n/** Extract the `__session` value from a `Set-Cookie` response header. */\nfunction extractSessionCookie(headers: Headers): string | null {\n const withGetSetCookie = headers as Headers & { getSetCookie?: () => string[] };\n const list =\n typeof withGetSetCookie.getSetCookie === 'function'\n ? withGetSetCookie.getSetCookie()\n : headers.get('set-cookie') !== null\n ? [headers.get('set-cookie') as string]\n : [];\n for (const cookie of list) {\n const match = /(?:^|;\\s*)__session=([^;]+)/.exec(cookie);\n if (match !== null && match[1] !== undefined) {\n return match[1];\n }\n }\n return null;\n}\n","/**\n * Image generation: submit a job via `runArchitecture`, then poll\n * `getHistoryById` until the job succeeds, fails, or times out.\n */\nimport type { AuthManager } from './auth.js';\nimport { GenerationError, TimeoutError } from './errors.js';\nimport type { HttpClient } from './http.js';\nimport type {\n ArchitectureConfig,\n CharacterRef,\n GenerateOptions,\n GenerateVideoOptions,\n GenerationMode,\n HistoryItem,\n VideoArchitectureConfig,\n WaitOptions,\n} from './types.js';\n\n/** Generation actions are served from the `/explore` page. */\nconst GENERATION_PATH = '/explore';\n/** RSC sentinel for an absent value. */\nconst UNDEFINED = '$undefined';\n/** Default concept id for mango-v3-pro (from docs — verify per model via rev-eng). */\nconst DEFAULT_CONCEPT_ID = '0cd8c7ed2e554d0f98f20c8cf8c0f7c';\n/** Default concept id for berry-2 video (from docs — verify per model via rev-eng). */\nconst DEFAULT_BERRY_CONCEPT_ID = '0b1fa74f7347406392422d24f2885684';\n\nconst DEFAULT_POLL_INTERVAL_MS = 4000;\nconst DEFAULT_TIMEOUT_MS = 5 * 60 * 1000;\n\nexport class GenerationService {\n constructor(\n private readonly http: HttpClient,\n private readonly auth: AuthManager,\n ) {}\n\n /** Submit an image generation job and return its `historyId`. */\n async submit(opts: GenerateOptions): Promise<{ historyId: string }> {\n const config: ArchitectureConfig = {\n seed: opts.seed ?? null,\n prompt: opts.prompt,\n model_id: opts.model ?? 'mango-v3-pro',\n fast_mode: opts.fastMode ?? false,\n resolution: opts.resolution ?? '1K',\n architecture: opts.architecture ?? 'mango',\n aspect_ratio: opts.aspectRatio ?? 'portrait',\n image: opts.image ?? UNDEFINED,\n additional_images: opts.additionalImages ?? [],\n characters: mapCharacters(opts.characters),\n references: mapCharacters(opts.references),\n audio_references: [],\n moodboard: UNDEFINED,\n };\n return this.runArchitecture(config, opts.conceptId ?? DEFAULT_CONCEPT_ID, opts.generationMode);\n }\n\n /** Submit a video generation job (Berry-2 family) and return its `historyId`. */\n async submitVideo(opts: GenerateVideoOptions): Promise<{ historyId: string }> {\n const config: VideoArchitectureConfig = {\n seed: opts.seed ?? null,\n prompt: opts.prompt,\n model_id: opts.model ?? 'berry-2',\n fast_mode: opts.fastMode ?? false,\n resolution: opts.resolution ?? '480p',\n architecture: opts.architecture ?? 'berry',\n berry_aspect_ratio: opts.aspectRatio ?? '9:16',\n duration: opts.duration ?? '3',\n image: opts.image ?? UNDEFINED,\n additional_images: opts.additionalImages ?? [],\n characters: mapCharacters(opts.characters),\n references: mapCharacters(opts.references),\n audio_references: [],\n };\n return this.runArchitecture(\n config,\n opts.conceptId ?? DEFAULT_BERRY_CONCEPT_ID,\n opts.generationMode,\n );\n }\n\n /** Shared `runArchitecture` call for image and video configs. */\n private async runArchitecture(\n config: ArchitectureConfig | VideoArchitectureConfig,\n conceptId: string,\n generationMode: GenerationMode = 'unlimited',\n ): Promise<{ historyId: string }> {\n const [authToken, session] = await Promise.all([\n this.auth.getIdToken(),\n this.auth.getSession(),\n ]);\n\n const args = [\n {\n architectureConfig: config,\n architectureConfigToSave: '$0:0:architectureConfig',\n authToken,\n conceptId,\n activePowerPack: null,\n generationMode,\n },\n ];\n\n const { data } = await this.http.callAction<Record<string, unknown>>({\n action: 'runArchitecture',\n path: GENERATION_PATH,\n args,\n session,\n });\n\n if (data !== null && typeof data === 'object' && 'error_code' in data) {\n const code = Number(data.error_code);\n throw new GenerationError(errorMessageForCode(code), code);\n }\n const historyId = data !== null && typeof data === 'object' ? data.history_id : undefined;\n if (typeof historyId !== 'string') {\n throw new GenerationError('runArchitecture did not return a history_id');\n }\n return { historyId };\n }\n\n /** Fetch a single history record by id. */\n async getHistory(historyId: string): Promise<HistoryItem> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<HistoryItem>({\n action: 'getHistoryById',\n path: GENERATION_PATH,\n args: [historyId],\n session,\n });\n return data;\n }\n\n /** Cancel a running generation job. */\n async cancelJob(historyId: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'cancelArchitectureJob',\n path: GENERATION_PATH,\n args: [historyId],\n session,\n });\n }\n\n /** Poll until the job leaves the `running` state, returning the final record. */\n async waitForResult(historyId: string, opts: WaitOptions = {}): Promise<HistoryItem> {\n const intervalMs = opts.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const deadline = Date.now() + timeoutMs;\n\n for (;;) {\n if (opts.signal?.aborted === true) {\n throw new TimeoutError('waitForResult was aborted');\n }\n const item = await this.getHistory(historyId);\n if (item.status === 'success') {\n return item;\n }\n if (item.status === 'error') {\n throw new GenerationError(`Generation failed: ${JSON.stringify(item.error ?? null)}`);\n }\n if (Date.now() > deadline) {\n throw new TimeoutError(\n `Generation timed out after ${timeoutMs}ms (last status: ${item.status})`,\n );\n }\n await delay(intervalMs, opts.signal);\n }\n }\n}\n\nfunction delay(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(resolve, ms);\n signal?.addEventListener(\n 'abort',\n () => {\n clearTimeout(timer);\n reject(new TimeoutError('waitForResult was aborted'));\n },\n { once: true },\n );\n });\n}\n\n/** Normalize characters for an `architectureConfig`, defaulting absent audio to the RSC sentinel. */\nfunction mapCharacters(characters: CharacterRef[] = []): CharacterRef[] {\n return characters.map((c) => ({\n id: c.id,\n name: c.name,\n username: c.username,\n image_url: c.image_url,\n audio_url: c.audio_url ?? UNDEFINED,\n }));\n}\n\nfunction errorMessageForCode(code: number): string {\n switch (code) {\n case 400:\n return 'Bad request (wrong generationMode for your subscription tier?)';\n case 401:\n return 'Authentication failed (token expired or invalid)';\n case 403:\n return 'User is banned';\n case 4031:\n return 'Prompt blocked by content moderation';\n default:\n return `Generation error (code ${code})`;\n }\n}\n","/** Generation history listing via `getHistoryPaginated`. */\nimport type { AuthManager } from './auth.js';\nimport { requireConfirm } from './errors.js';\nimport type { HttpClient } from './http.js';\nimport { unwrapResult } from './rsc.js';\nimport type {\n ConfirmOptions,\n CreationPage,\n GenerationResult,\n HistoryPage,\n ListCreationsOptions,\n ListHistoryOptions,\n} from './types.js';\n\n/** History actions are served from the `/creations` page. */\nconst HISTORY_PATH = '/creations';\nconst DEFAULT_LIMIT = 10;\n/** RSC sentinel for an absent value. */\nconst UNDEFINED = '$undefined';\n\nexport class HistoryService {\n constructor(\n private readonly http: HttpClient,\n private readonly auth: AuthManager,\n ) {}\n\n /** List generation history for the authenticated user. */\n async list(opts: ListHistoryOptions = {}): Promise<HistoryPage> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const limit = opts.limit ?? DEFAULT_LIMIT;\n const offset = opts.offset ?? 0;\n const status = opts.status === 'all' ? UNDEFINED : (opts.status ?? 'success');\n const filters = { status, type: UNDEFINED };\n\n const { data } = await this.http.callAction<HistoryPage>({\n action: 'getHistoryPaginated',\n path: HISTORY_PATH,\n args: [uid, limit, offset, filters],\n session,\n });\n return unwrapResult<HistoryPage>(data);\n }\n\n /** List the user's permanently saved creations. */\n async listCreations(opts: ListCreationsOptions = {}): Promise<CreationPage> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const limit = opts.limit ?? DEFAULT_LIMIT;\n const offset = opts.offset ?? 0;\n const { data } = await this.http.callAction<CreationPage>({\n action: 'getCreationsPaginatedParallel',\n path: HISTORY_PATH,\n args: [uid, limit, offset],\n session,\n });\n return unwrapResult<CreationPage>(data);\n }\n\n /**\n * Save a completed generation result as a permanent creation.\n *\n * @param result - the `result` object of a completed history item.\n * @remarks The API returns no body; call {@link listCreations} to retrieve the\n * saved creation.\n */\n async saveCreation(result: GenerationResult): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'saveCreation',\n path: HISTORY_PATH,\n args: [result],\n session,\n });\n }\n\n /**\n * Permanently delete a history item. Irreversible — requires `{ confirm: true }`.\n */\n async deleteHistory(historyId: string, opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteHistory', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteHistory',\n path: HISTORY_PATH,\n args: [historyId],\n session,\n });\n }\n\n /**\n * Permanently delete many history items. Irreversible — requires `{ confirm: true }`.\n *\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async deleteManyHistories(historyIds: string[], opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteManyHistories', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteManyHistories',\n path: HISTORY_PATH,\n args: [historyIds],\n session,\n });\n }\n\n /**\n * Permanently delete a saved creation. Irreversible — requires `{ confirm: true }`.\n */\n async deleteCreation(creationId: string, opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteCreation', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteCreation',\n path: HISTORY_PATH,\n args: [creationId],\n session,\n });\n }\n\n /**\n * Permanently delete many creations. Irreversible — requires `{ confirm: true }`.\n *\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async deleteManyCreations(creationIds: string[], opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteManyCreations', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteManyCreations',\n path: HISTORY_PATH,\n args: [creationIds],\n session,\n });\n }\n}\n","/**\n * Internal HTTP client for Next.js Server Action calls.\n *\n * Every call is a `POST` to a page path with a `next-action` header carrying the\n * action hash, a JSON-array body, and an RSC response that is parsed into the\n * action's return value. A 404 is treated as a stale hash: the registry is\n * invalidated and the call is retried once against freshly discovered hashes.\n */\nimport type { ActionRegistry } from './actions.js';\nimport { MageSpaceError } from './errors.js';\nimport { parseServerActionResponse } from './rsc.js';\nimport type { FetchLike } from './types.js';\n\nconst DEFAULT_USER_AGENT =\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' +\n '(KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36';\n\nexport interface CallActionParams {\n /** Server Action function name (resolved to a hash via the registry). */\n action: string;\n /** Page path to POST to (e.g. `/explore`, `/creations`). */\n path: string;\n /** Request body — always a JSON array of arguments. */\n args: unknown[];\n /** `__session` cookie value for authenticated actions. */\n session?: string;\n}\n\nexport interface CallActionResult<T> {\n data: T;\n headers: Headers;\n deploymentId: string;\n}\n\nexport class HttpClient {\n constructor(\n private readonly registry: ActionRegistry,\n private readonly fetchImpl: FetchLike,\n private readonly baseUrl: string,\n private readonly userAgent: string = DEFAULT_USER_AGENT,\n ) {}\n\n async callAction<T = unknown>(\n params: CallActionParams,\n retried = false,\n ): Promise<CallActionResult<T>> {\n const { hash, deploymentId } = await this.registry.getHash(params.action);\n\n const headers: Record<string, string> = {\n accept: 'text/x-component',\n 'content-type': 'text/plain;charset=UTF-8',\n 'next-action': hash,\n 'x-deployment-id': deploymentId,\n origin: this.baseUrl,\n referer: `${this.baseUrl}${params.path}`,\n 'user-agent': this.userAgent,\n };\n if (params.session !== undefined) {\n headers.cookie = `__session=${params.session}`;\n }\n\n const res = await this.fetchImpl(`${this.baseUrl}${params.path}`, {\n method: 'POST',\n headers,\n body: JSON.stringify(params.args),\n });\n\n // A stale (post-deploy) hash surfaces as a 404 OR as a 200 with HTML\n // (Next.js returns the page shell instead of the RSC action response).\n const contentType = res.headers.get('content-type') ?? '';\n const isHtmlFallback = res.ok && contentType.includes('text/html');\n if ((res.status === 404 || isHtmlFallback) && !retried) {\n // Consume the body to prevent socket leaks.\n await safeText(res);\n await this.registry.invalidate();\n return this.callAction<T>(params, true);\n }\n if (!res.ok) {\n const body = await safeText(res);\n const suffix = body.length > 0 ? ` — ${body.slice(0, 200)}` : '';\n throw new MageSpaceError(`Action \"${params.action}\" failed: HTTP ${res.status}${suffix}`);\n }\n\n const text = await res.text();\n const data = parseServerActionResponse<T>(text);\n return {\n data,\n headers: res.headers,\n deploymentId: res.headers.get('x-deployment-id') ?? deploymentId,\n };\n }\n}\n\nasync function safeText(res: Response): Promise<string> {\n try {\n return await res.text();\n } catch {\n return '';\n }\n}\n","/**\n * Reference asset management.\n *\n * References are reusable image/audio assets (generic references, objects,\n * outfits, poses) applied across generations — distinct from characters, which\n * are trained identities. Covers upload, create, update, and listing (own +\n * public feed) per `docs/api/references.md`.\n */\nimport type { AuthManager } from './auth.js';\nimport { requireConfirm } from './errors.js';\nimport type { HttpClient } from './http.js';\nimport type {\n ConfirmOptions,\n CreateReferenceInput,\n ListReferencesOptions,\n Modality,\n Reference,\n ReferencePage,\n UpdateReferenceInput,\n} from './types.js';\n\n/** Reference actions are served from the `/explore` page. */\nconst REFERENCES_PATH = '/explore';\nconst DEFAULT_PAGE_LIMIT = 20;\n\nexport class ReferencesService {\n constructor(\n private readonly http: HttpClient,\n private readonly auth: AuthManager,\n ) {}\n\n /**\n * Upload a reference image (base64 data URL) and return its CDN URL.\n *\n * @param dataUrl - `data:image/jpeg;base64,...` (JPEG preferred; PNG/WebP ok).\n */\n async uploadImage(dataUrl: string): Promise<string> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const { data } = await this.http.callAction<string>({\n action: 'uploadReferenceImage',\n path: REFERENCES_PATH,\n args: [dataUrl, uid],\n session,\n });\n return data;\n }\n\n /** Create a reusable reference from an uploaded image/audio URL. */\n async create(input: CreateReferenceInput): Promise<Reference> {\n const session = await this.auth.getSession();\n const body = {\n name: input.name,\n username: input.username,\n image_url: input.image_url,\n audio_url: input.audio_url ?? null,\n modality: input.modality ?? 'image',\n variant: input.variant ?? 'reference',\n description: input.description ?? null,\n tags: input.tags ?? [],\n visibility: input.visibility ?? 'private',\n moderation: input.moderation ?? [],\n };\n const { data } = await this.http.callAction<Reference>({\n action: 'createReference',\n path: REFERENCES_PATH,\n args: [body],\n session,\n });\n return data;\n }\n\n /** Update a reference's mutable fields (name, description, tags, visibility). */\n async update(id: string, patch: UpdateReferenceInput): Promise<Reference> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<Reference>({\n action: 'updateReference',\n path: REFERENCES_PATH,\n args: [id, patch],\n session,\n });\n return data;\n }\n\n /**\n * Permanently delete a reference (soft-delete). Irreversible — requires\n * `{ confirm: true }`.\n */\n async delete(id: string, opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteReference', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteReference',\n path: REFERENCES_PATH,\n args: [id],\n session,\n });\n }\n\n /** List the caller's own references for a given modality (default `image`). */\n async list(modality: Modality = 'image'): Promise<Reference[]> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const { data } = await this.http.callAction<Reference[]>({\n action: 'getReferences',\n path: REFERENCES_PATH,\n args: [uid, modality],\n session,\n });\n return data ?? [];\n }\n\n /**\n * Browse references with pagination.\n *\n * @remarks\n * Omit `uid` to browse the public/featured feed; pass it to page through a\n * single user's references.\n */\n async listPaginated(opts: ListReferencesOptions = {}): Promise<ReferencePage> {\n const session = await this.auth.getSession();\n const limit = opts.limit ?? DEFAULT_PAGE_LIMIT;\n const offset = opts.offset ?? 0;\n const filters: Record<string, unknown> = {\n visibility: opts.visibility ?? 'public',\n orderBy: opts.orderBy ?? 'top',\n featuredOnly: opts.featuredOnly ?? false,\n modality: opts.modality ?? 'image',\n };\n if (opts.uid !== undefined) {\n filters.uid = opts.uid;\n }\n const { data } = await this.http.callAction<ReferencePage>({\n action: 'getReferencesPaginated',\n path: REFERENCES_PATH,\n args: [limit, offset, filters],\n session,\n });\n return data;\n }\n}\n","import type { ActionSnapshot } from './types.js';\n\n/**\n * Bundled action-hash snapshot from the mage.space Vercel deploy discovered on\n * 2026-08-24 (`docs/api/actions.md`).\n *\n * @remarks\n * Used as a warm seed so the very first call does not pay the discovery cost.\n * Hashes change on every deploy; when one goes stale the client re-discovers\n * automatically (404 → invalidate → refresh).\n */\nexport const SEED_SNAPSHOT: ActionSnapshot = {\n deploymentId: 'dpl_2w2igPYTRJKeDaX6iAUMbGwDEWZC',\n discoveredAt: Date.parse('2026-08-24T13:15:00.000Z'),\n hashes: {\n createUserSession: '60b45776be93d57b1f43deaf8d6f9a837c6b9c169b',\n deleteUserSession: '0044441bb36afa0ba15ca13c4cf3a831ac81108c7a',\n getUserHydrationData: '40b253dcab658b78ba3673c5244f96578f22d65606',\n runArchitecture: '40c4d7d5e695e1a2e2992174b75562ef5df377b206',\n getHistoryById: '4042bfb22d370cd4e3f0f41812e826a63c179cb8a8',\n cancelArchitectureJob: '401dc98670483cb67cc9b1b6a623c4fa7cb71348a2',\n cancelAllRunningArchitectureJobs: '0004b976add66997b6518bd2d25f04444b8df4e3b2',\n getMentionSuggestionsParallel: '7fe1156be29ed3824514220877818246e7649234fa',\n createCharacter: '401ceece486398904b9ba48daa7fc0ac951fb72168',\n updateCharacter: '6057ae8c4ae8868e3a4b045845814b0689ac61a1e0',\n deleteCharacter: '4071b6010bffdf242150e0322cd0966463268414d8',\n getCharacter: '40ce38eb438c78fa51ee09be911ba0c3b02d7cbcad',\n getCharacters: '40c74f795b040ec3d0841360b532eb938932fc4bc3',\n getCharactersPaginated: '709855baaecec89ad7b73ca44621fe93dfd93fcdee',\n publishCharacter: '40b489876c75c1cd836a108742da4753fb2f671565',\n unpublishCharacter: '40c785b54f5c25bd50cfaebc6817f9d0b9f5e6e145',\n uploadCharacterImage: '60ef3377c68f0cf34c60646d9356e622a9230a68e5',\n uploadReferenceImage: '60c497b22c1b65f8a4e78055c5d9e0c2bc49e2c7bd',\n createReference: '403a057e1bd8967b3bb728df1722019d14ca7c4e14',\n updateReference: '60819ffb5ec61122bc4dd52b2232fd486a155d23c6',\n deleteReference: '409098eedd49e49ac5f0275d8af9c70a0988e9859c',\n getReferences: '605e5d2876598666c4681f8f08f4ecbe7488d1762d',\n getReferencesPaginated: '702382e902dbe43b4343265b6a251c30b878eae08a',\n getCreationsPaginatedParallel: '7f5eb618ca5c4c243c51a04c5dea108aefe8aa37d2',\n getHistoryPaginated: '7817d35897de571dfa2c6c525ee7bff73ba6d590d6',\n clearUserHistory: '4038b8e21b2e6eac7c78c076ef04f1db91718cfd69',\n deleteHistory: '40f4de31887560f79274b13f8abd3a282f6c3321f7',\n deleteManyHistories: '4006a9773613e8ea05421e6f2c91fe6417fe33d892',\n deleteCreation: '40ceaf58a77a287e3146d5792b147dba9df5ec0257',\n deleteManyCreations: '4092a1e1531442421916268184300f37a4478900ed',\n saveCreation: '60860eb37a9862d41d7b92af9bbe572652e076bc43',\n saveManyCreations: '400f59bf4b0ce788050b25259aecc9bf7839f8ba11',\n generateCharacterVoice: '60b54e75a5c3de2b0e4df7ebec5cf6ef1aaeb2ed35',\n followCharacter: '403b46c309f4239df7579c00654881afd855fc1757',\n unfollowCharacter: '400dd84b2d0f2f582df6c72092ea5249678b68d4d5',\n getFilteredCharacterIds: '403b8603d61033bbe1c30c9d1c12133b9ed4e16348',\n getFilteredReferenceIds: '40a87aa0793c102e72b7858e1024c0c2f01c96a720',\n getConceptsParallel: '7f5cf8a4696938e3a148c3c293922fbcd0f8cdbd08',\n getConcept: '408caa15371b2240267a5521c4130fefcff4ba515d',\n getModel: '40f88ee2580ed9a6ae6ff3bf6ec5840b22946dbba3',\n getModels: '70fbe28eadea3cb6d563b1f5bf50c2ad179535e6e8',\n getArticlesParallel: '7f743849b6ddf8eeb21eefceb2b93c93b6d19f203f',\n searchUsersParallel: '7ff9c981309e38b9efb215d0943b34380401a93362',\n getEmbeddingParallel: '7fa14c0b84ee996caad1a598bc2b021bd9545a3383',\n getLatestPublishedArticleCached: '7f0e2eb3e1407b27b2cc338235134b3fbf25c88ddc',\n hasPurchasedGemsParallel: '7f223962cad80e4dbdd3df7dc2039f65a42c461d87',\n syncStripeSubscriptionParallel: '7f19bb611b725a3cb8d99dc5d72ab11e0595087f6e',\n getSubscriptionPlayUsage: '40c9d7d3d029eee45885df18797dbca20315ff4fca',\n saveContentSettings: '4095ebf4d1b43894777ef2e3e06b9a556275fafcf0',\n deleteUser: '40692c054de95018353e0c8512082f6f9103cac6d7',\n getMyUserMembership: '007ce34998f2bf4f19be3cf46e3cfcb387110ae5d5',\n getActiveUserBan: '60e4352df1676fbe169421c5709479f1534cccb371',\n getCreditBalance: '009364b01be29ea5b25711fff2c6284af88caa4e4c',\n getCreditBalanceBreakdown: '00ddc14328cf19e8fbec823474a7169214cfd30603',\n getActivePowerPack: '00a6404083c8958fcd47607a088c1d1a7a5dfd4514',\n getUnusedPowerPacks: '00b5d80d96598fc2db4641fff117cfa47b37f2482f',\n getPowerPackStatsById: '4027b533e8532d2f35cbbb7518160d7569b738cb20',\n getLastGemPurchaseType: '008f0fb3448464f9f0e5ac2b6b15fc5fb59d8ccce4',\n getCheckoutUrlWithStripeDirect: '7c0f0773c703de16b1abe5f869c2164108473c5820',\n getPortalUrlWithStripeDirect: '60655cb929f6eb281aef8c25311806cfaed5aeb8af',\n removeInactiveSubscriptions: '00b5b012ef33665bb3cdf3f8e931483a0d8dc96461',\n hasCreatedImageReference: '002876b36888ccf790e8e5b9413ae951d07594a4c3',\n createLink: '40ffeee6dd712d83ce286aa22d07446822adb5ec02',\n tempToPermanentFile: '40f30eb9909274b48fa7654e7648cdf188bf3e015d',\n uploadTempCreationImage: '60f0c8b2c98566eb131e69ec1e8ee95c78ad4c332f',\n uploadUserImage: '604d67807ffec2bcdaf936e03c27c7fcc8e49880f8',\n getUserAudioUploadUrl: '7019e155efbd5aa4eb2200a48d6f7265cf6aa686e9',\n getUserVideoUploadUrl: '70cab2e17fe2c04a964489850642235ada2cb0adf3',\n processVideoFromUrl: '70901405c8bff0dcb9ea40053f1176caeb1b99ae4c',\n processAudio: '60bd5fa2fd7c30e53ef2a22342408ed1aab0a766a7',\n segmentImage: '40d827c38726f2d2bbc559f94eafe0f1fc84b50e70',\n moderateMedia: '403006c99a6b3cd6e684c163e0df35f44e403f7ca7',\n checkSharedUsernameAvailable: '6000cca07091fb38d8a77fad195b95b2ea73634895',\n getCreationTagCountsParallel: '7f0f20d7a26711c076aefeb73e65273ac1572381d8',\n updateCreations: '4055ce23f7e1fac54bfceb33b816f9574b82d2127d',\n getCreationsPaginated: '780d8f5e01f24e1342e5e4a475321123eb156dcf2a',\n resolveMoodboardRuntimeSelection: '40080c3021ac4c02f675c25a7443b03ee96e57837a',\n saveProfileCollections: '4071958ca110ab37fe59be3b019bfc39b1fa0c9143',\n banUser: '70c46c18b6223613cee3a4f17ce076672f29a6bba5',\n undoTemporaryBanUser: '40199a810acd4149e53fc182ba1ff9e8a7dde19283',\n temporaryBanUser: '788b8a43fb42b87cd942e3d0229307bea6497ef8e9',\n getCharacterFollowStatus: '40d220eb13610f029b46bbcfc7c9117478b3b738f2',\n reportCharacter: '400525e8101daa2496bad7a7c7e91c5cca00d574c2',\n toggleFeatureCharacter: '40a640496a2e6bf7cb124405c74f8a928aeccbf964',\n getSiteAlertParallel: '7f382e755e1d8d7670272b36656280dd661aa9abce',\n getChatsParallel: '7f741bb8b517b0ba95f6b941ab1ce0efcb870341f6',\n getChatMessages: '40f8886c57d93aae7265d1805af5765589e2be7d15',\n markChatRead: '408c569fdaa0d2ab12e0b8019cf661a99c9d182f68',\n getPostMediaFeedParallel: '7f9ce48dd331eb4103e9d2d18b23b6008e3bf5c502',\n createAutoCreationCampaign: '404c84350ce7aba35a332ab3129334ed19cfb107fd',\n },\n};\n","/**\n * {@link MageSpaceClient} — the public facade that wires together action\n * discovery, authentication, generation, and history.\n */\nimport { ActionRegistry } from './actions.js';\nimport { AuthManager } from './auth.js';\nimport { CharactersService } from './characters.js';\nimport { GenerationService } from './generation.js';\nimport { HistoryService } from './history.js';\nimport { HttpClient } from './http.js';\nimport { ReferencesService } from './references.js';\nimport { SEED_SNAPSHOT } from './seed.js';\nimport type {\n ActionSnapshot,\n ConfirmOptions,\n CreationPage,\n FetchLike,\n GenerateOptions,\n GenerateVideoOptions,\n GenerationResult,\n HistoryItem,\n HistoryPage,\n ListCreationsOptions,\n ListHistoryOptions,\n MageSpaceClientOptions,\n WaitOptions,\n} from './types.js';\n\nconst DEFAULT_BASE_URL = 'https://www.mage.space';\n\nexport class MageSpaceClient {\n private readonly registry: ActionRegistry;\n private readonly auth: AuthManager;\n private readonly generationService: GenerationService;\n private readonly historyService: HistoryService;\n\n /** Character management (search, CRUD, pagination, uploads). */\n readonly characters: CharactersService;\n\n /** Reference asset management (upload, create, update, list, feed). */\n readonly references: ReferencesService;\n\n constructor(options: MageSpaceClientOptions) {\n if (!options.refreshToken) {\n throw new Error('MageSpaceClient requires a refreshToken');\n }\n const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;\n const fetchImpl: FetchLike = options.fetch ?? ((input, init) => fetch(input, init));\n\n this.registry = new ActionRegistry({\n fetch: fetchImpl,\n baseUrl,\n cache: options.cache,\n seed: options.seed ?? SEED_SNAPSHOT,\n });\n const http = new HttpClient(this.registry, fetchImpl, baseUrl, options.userAgent);\n this.auth = new AuthManager({\n refreshToken: options.refreshToken,\n http,\n fetch: fetchImpl,\n firebaseApiKey: options.firebaseApiKey,\n });\n this.generationService = new GenerationService(http, this.auth);\n this.historyService = new HistoryService(http, this.auth);\n this.characters = new CharactersService(http, this.auth);\n this.references = new ReferencesService(http, this.auth);\n }\n\n /** Submit a generation job; returns its `historyId`. */\n generate(options: GenerateOptions): Promise<{ historyId: string }> {\n return this.generationService.submit(options);\n }\n\n /** Submit a video generation job (Berry-2 family); returns its `historyId`. */\n generateVideo(options: GenerateVideoOptions): Promise<{ historyId: string }> {\n return this.generationService.submitVideo(options);\n }\n\n /** Fetch the current state of a generation by id. */\n getResult(historyId: string): Promise<HistoryItem> {\n return this.generationService.getHistory(historyId);\n }\n\n /** Poll until a generation finishes (or fails / times out). */\n waitForResult(historyId: string, options?: WaitOptions): Promise<HistoryItem> {\n return this.generationService.waitForResult(historyId, options);\n }\n\n /** Cancel a running generation job. */\n cancelJob(historyId: string): Promise<void> {\n return this.generationService.cancelJob(historyId);\n }\n\n /** List past generations for the authenticated user. */\n listHistory(options?: ListHistoryOptions): Promise<HistoryPage> {\n return this.historyService.list(options);\n }\n\n /** List the user's permanently saved creations. */\n listCreations(options?: ListCreationsOptions): Promise<CreationPage> {\n return this.historyService.listCreations(options);\n }\n\n /** Save a completed generation result as a permanent creation. */\n saveCreation(result: GenerationResult): Promise<void> {\n return this.historyService.saveCreation(result);\n }\n\n /** Permanently delete a history item. Irreversible — requires `{ confirm: true }`. */\n deleteHistory(historyId: string, options?: ConfirmOptions): Promise<void> {\n return this.historyService.deleteHistory(historyId, options);\n }\n\n /** Permanently delete many history items. Irreversible — requires `{ confirm: true }`. */\n deleteManyHistories(historyIds: string[], options?: ConfirmOptions): Promise<void> {\n return this.historyService.deleteManyHistories(historyIds, options);\n }\n\n /** Permanently delete a saved creation. Irreversible — requires `{ confirm: true }`. */\n deleteCreation(creationId: string, options?: ConfirmOptions): Promise<void> {\n return this.historyService.deleteCreation(creationId, options);\n }\n\n /** Permanently delete many creations. Irreversible — requires `{ confirm: true }`. */\n deleteManyCreations(creationIds: string[], options?: ConfirmOptions): Promise<void> {\n return this.historyService.deleteManyCreations(creationIds, options);\n }\n\n /** Force re-discovery of the Server Action hashes. */\n refreshActions(): Promise<ActionSnapshot> {\n return this.registry.refresh();\n }\n\n /** Return the authenticated user's Firebase uid. */\n getUid(): Promise<string> {\n return this.auth.getUserId();\n }\n}\n","/** Public entry point for `@zweer/mage-space-client`. */\nexport const VERSION = '0.0.0';\n\nexport { ActionRegistry, discoverActions, InMemoryActionCache } from './actions.js';\nexport { CharactersService } from './characters.js';\nexport { MageSpaceClient } from './client.js';\nexport {\n AuthError,\n DiscoveryError,\n GenerationError,\n MageSpaceError,\n RscParseError,\n StaleActionError,\n TimeoutError,\n} from './errors.js';\nexport { ReferencesService } from './references.js';\nexport {\n parseFlightRows,\n parseServerActionResponse,\n resolveFlightValue,\n unwrapResult,\n} from './rsc.js';\nexport { SEED_SNAPSHOT } from './seed.js';\nexport type * from './types.js';\n"],"mappings":";;;;AAGA,IAAa,iBAAb,cAAoC,MAAM;CACxC,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,YAAb,cAA+B,eAAe;CAC5C,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,iBAAb,cAAoC,eAAe;CACjD,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,mBAAb,cAAsC,eAAe;CAEjC;CADlB,YACE,QACA,SACA;EACA,MAAM,WAAW,OAAO,8BAA8B,OAAO;EAH7C,KAAA,SAAA;EAIhB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,kBAAb,cAAqC,eAAe;CAGhC;CAFlB,YACE,SACA,MACA,SACA;EACA,MAAM,SAAS,OAAO;EAHN,KAAA,OAAA;EAIhB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,gBAAb,cAAmC,eAAe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CAC9C;;CAGA,cAAc,SAA+D;EAC3E,OAAO,KAAK,kBAAkB,YAAY,OAAO;CACnD;;CAGA,UAAU,WAAyC;EACjD,OAAO,KAAK,kBAAkB,WAAW,SAAS;CACpD;;CAGA,cAAc,WAAmB,SAA6C;EAC5E,OAAO,KAAK,kBAAkB,cAAc,WAAW,OAAO;CAChE;;CAGA,UAAU,WAAkC;EAC1C,OAAO,KAAK,kBAAkB,UAAU,SAAS;CACnD;;CAGA,YAAY,SAAoD;EAC9D,OAAO,KAAK,eAAe,KAAK,OAAO;CACzC;;CAGA,cAAc,SAAuD;EACnE,OAAO,KAAK,eAAe,cAAc,OAAO;CAClD;;CAGA,aAAa,QAAyC;EACpD,OAAO,KAAK,eAAe,aAAa,MAAM;CAChD;;CAGA,cAAc,WAAmB,SAAyC;EACxE,OAAO,KAAK,eAAe,cAAc,WAAW,OAAO;CAC7D;;CAGA,oBAAoB,YAAsB,SAAyC;EACjF,OAAO,KAAK,eAAe,oBAAoB,YAAY,OAAO;CACpE;;CAGA,eAAe,YAAoB,SAAyC;EAC1E,OAAO,KAAK,eAAe,eAAe,YAAY,OAAO;CAC/D;;CAGA,oBAAoB,aAAuB,SAAyC;EAClF,OAAO,KAAK,eAAe,oBAAoB,aAAa,OAAO;CACrE;;CAGA,iBAA0C;EACxC,OAAO,KAAK,SAAS,QAAQ;CAC/B;;CAGA,SAA0B;EACxB,OAAO,KAAK,KAAK,UAAU;CAC7B;AACF;;;;ACxIA,MAAa,UAAU"}
1
+ {"version":3,"file":"index.mjs","names":["UNDEFINED"],"sources":["../lib/errors.ts","../lib/actions.ts","../lib/rsc.ts","../lib/characters.ts","../lib/auth.ts","../lib/generation.ts","../lib/history.ts","../lib/http.ts","../lib/references.ts","../lib/seed.ts","../lib/client.ts","../lib/index.ts"],"sourcesContent":["/** Typed error hierarchy for the mage.space client. */\n\n/** Base class for every error thrown by this library. */\nexport class MageSpaceError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'MageSpaceError';\n }\n}\n\n/** Authentication failures (token refresh, session creation). */\nexport class AuthError extends MageSpaceError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'AuthError';\n }\n}\n\n/** Action-hash discovery failures (page/chunk fetch, empty registry). */\nexport class DiscoveryError extends MageSpaceError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'DiscoveryError';\n }\n}\n\n/** A Server Action returned 404, indicating a stale (post-deploy) hash. */\nexport class StaleActionError extends MageSpaceError {\n constructor(\n public readonly action: string,\n options?: { cause?: unknown },\n ) {\n super(`Action \"${action}\" returned 404 (stale hash)`, options);\n this.name = 'StaleActionError';\n }\n}\n\n/** Failures while submitting or polling a generation job. */\nexport class GenerationError extends MageSpaceError {\n constructor(\n message: string,\n public readonly code?: number,\n options?: { cause?: unknown },\n ) {\n super(message, options);\n this.name = 'GenerationError';\n }\n}\n\n/** Failure to parse a React Server Component (RSC) wire response. */\nexport class RscParseError extends MageSpaceError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'RscParseError';\n }\n}\n\n/** A wait/poll operation exceeded its deadline or was aborted. */\nexport class TimeoutError extends MageSpaceError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Guard for irreversible operations: throws unless `{ confirm: true }` is passed.\n *\n * @throws {MageSpaceError} when confirmation is missing.\n */\nexport function requireConfirm(action: string, opts?: { confirm?: boolean }): void {\n if (opts?.confirm !== true) {\n throw new MageSpaceError(\n `${action} is irreversible and requires explicit confirmation: pass { confirm: true }`,\n );\n }\n}\n","/**\n * Action-hash discovery and caching.\n *\n * mage.space's Server Action hashes change on every Vercel deploy, so the client\n * discovers them from the page's JS bundles and caches the result. The registry\n * serves hashes from a warm seed / cache and only re-discovers when a hash goes\n * stale (a request 404s) or when explicitly refreshed.\n */\nimport { DiscoveryError } from './errors.js';\nimport type { ActionCache, ActionName, ActionSnapshot, FetchLike } from './types.js';\n\n/** `createServerReference)(\"<hash>\", callServer, void 0, findSourceMapURL, \"<fn>\")` */\nconst CREATE_SERVER_REF_RE = /createServerReference\\)\\(\"([0-9a-f]+)\"[^)]*?\"([^\"]+)\"\\)/g;\n/** `/_next/static/chunks/....js` references in the page HTML. */\nconst CHUNK_RE = /\\/_next\\/static\\/chunks\\/[^\"'`()\\s]+?\\.js/g;\n/**\n * Default pages scraped during discovery. Server Actions are split per route, so\n * a single page misses route-specific actions (e.g. `deleteReference` lives only\n * in the `/references` bundle) — scrape the main routes and union their chunks.\n */\nconst DISCOVERY_PAGES = ['/explore', '/creations', '/characters', '/references'];\n\n/** Default in-process snapshot cache. */\nexport class InMemoryActionCache implements ActionCache {\n private snapshot: ActionSnapshot | null = null;\n\n async load(): Promise<ActionSnapshot | null> {\n return this.snapshot;\n }\n\n async save(snapshot: ActionSnapshot): Promise<void> {\n this.snapshot = snapshot;\n }\n}\n\nexport interface DiscoveryOptions {\n fetch: FetchLike;\n baseUrl: string;\n /** Single page to scrape for chunk references (overrides {@link discoveryPaths}). */\n discoveryPath?: string;\n /** Pages to scrape and union (default: the main app routes). */\n discoveryPaths?: string[];\n}\n\n/**\n * Discover the current Server Action hashes by scraping the page HTML for JS\n * chunk URLs and extracting `createServerReference(...)` calls from each chunk.\n *\n * @throws {DiscoveryError} on network failure or when nothing is discovered.\n */\nexport async function discoverActions(opts: DiscoveryOptions): Promise<ActionSnapshot> {\n const { fetch, baseUrl } = opts;\n const pages =\n opts.discoveryPath !== undefined\n ? [opts.discoveryPath]\n : (opts.discoveryPaths ?? DISCOVERY_PAGES);\n\n let deploymentId = '';\n const chunkPaths = new Set<string>();\n for (const page of pages) {\n let res: Response;\n try {\n res = await fetch(`${baseUrl}${page}`, { headers: { accept: 'text/html' } });\n } catch {\n // A single unreachable page must not abort discovery.\n continue;\n }\n if (!res.ok) {\n continue;\n }\n if (deploymentId === '') {\n deploymentId = res.headers.get('x-deployment-id') ?? '';\n }\n const html = await res.text();\n for (const match of html.matchAll(CHUNK_RE)) {\n const chunkPath = match[0];\n if (chunkPath !== undefined) {\n chunkPaths.add(chunkPath);\n }\n }\n }\n if (chunkPaths.size === 0) {\n throw new DiscoveryError('No JS chunk references found in discovery pages');\n }\n\n const hashes: ActionSnapshot['hashes'] = {};\n await Promise.all(\n [...chunkPaths].map(async (path) => {\n try {\n const chunkRes = await fetch(`${baseUrl}${path}`, {\n headers: { accept: 'application/javascript' },\n });\n if (!chunkRes.ok) {\n return;\n }\n // Fallback: CDN-cached page HTML may omit x-deployment-id; chunk responses\n // are served by the deployment and usually carry it.\n if (deploymentId === '') {\n deploymentId = chunkRes.headers.get('x-deployment-id') ?? '';\n }\n const js = await chunkRes.text();\n for (const match of js.matchAll(CREATE_SERVER_REF_RE)) {\n const hash = match[1];\n const fn = match[2];\n if (hash !== undefined && fn !== undefined && !(fn in hashes)) {\n hashes[fn] = hash;\n }\n }\n } catch {\n // A single failed chunk must not abort discovery.\n }\n }),\n );\n\n if (Object.keys(hashes).length === 0) {\n throw new DiscoveryError('No server action hashes discovered in JS chunks');\n }\n return { deploymentId, hashes, discoveredAt: Date.now() };\n}\n\nexport interface ActionRegistryOptions {\n fetch: FetchLike;\n baseUrl: string;\n cache?: ActionCache;\n seed?: ActionSnapshot;\n discoveryPath?: string;\n discoveryPaths?: string[];\n /** Re-discover when the snapshot is older than this (ms). 0 = never by age. */\n maxAgeMs?: number;\n}\n\n/**\n * Serves action hashes from a warm seed / pluggable cache, discovering lazily and\n * refreshing on staleness. Concurrent refreshes are de-duplicated (single-flight).\n */\nexport class ActionRegistry {\n private readonly fetch: FetchLike;\n private readonly baseUrl: string;\n private readonly cache: ActionCache;\n private readonly seed: ActionSnapshot | undefined;\n private readonly discoveryPath: string | undefined;\n private readonly discoveryPaths: string[] | undefined;\n private readonly maxAgeMs: number;\n private snapshot: ActionSnapshot | null = null;\n private inflight: Promise<ActionSnapshot> | null = null;\n\n constructor(opts: ActionRegistryOptions) {\n this.fetch = opts.fetch;\n this.baseUrl = opts.baseUrl;\n this.cache = opts.cache ?? new InMemoryActionCache();\n this.seed = opts.seed;\n this.discoveryPath = opts.discoveryPath;\n this.discoveryPaths = opts.discoveryPaths;\n this.maxAgeMs = opts.maxAgeMs ?? 0;\n }\n\n private isStale(snapshot: ActionSnapshot): boolean {\n return this.maxAgeMs > 0 && Date.now() - snapshot.discoveredAt > this.maxAgeMs;\n }\n\n /** Return the current snapshot, loading from cache/seed or discovering as needed. */\n async getSnapshot(): Promise<ActionSnapshot> {\n if (this.snapshot !== null && !this.isStale(this.snapshot)) {\n return this.snapshot;\n }\n const cached = await this.cache.load();\n if (cached !== null && !this.isStale(cached)) {\n this.snapshot = cached;\n return cached;\n }\n if (this.seed !== undefined) {\n this.snapshot = this.seed;\n await this.cache.save(this.seed);\n return this.seed;\n }\n return this.refresh();\n }\n\n /** Force re-discovery. Concurrent callers share one in-flight discovery. */\n async refresh(): Promise<ActionSnapshot> {\n if (this.inflight !== null) {\n return this.inflight;\n }\n this.inflight = (async () => {\n try {\n const fresh = await discoverActions({\n fetch: this.fetch,\n baseUrl: this.baseUrl,\n discoveryPath: this.discoveryPath,\n discoveryPaths: this.discoveryPaths,\n });\n this.snapshot = fresh;\n await this.cache.save(fresh);\n return fresh;\n } finally {\n this.inflight = null;\n }\n })();\n return this.inflight;\n }\n\n /** Resolve a function name to its current hash + deployment id. */\n async getHash(action: ActionName | string): Promise<{ hash: string; deploymentId: string }> {\n let snapshot = await this.getSnapshot();\n let hash = snapshot.hashes[action];\n if (hash === undefined) {\n snapshot = await this.refresh();\n hash = snapshot.hashes[action];\n }\n if (hash === undefined) {\n throw new DiscoveryError(`Action \"${action}\" not found after discovery`);\n }\n return { hash, deploymentId: snapshot.deploymentId };\n }\n\n /** Drop the cached snapshot and re-discover (called on a stale 404). */\n async invalidate(): Promise<ActionSnapshot> {\n this.snapshot = null;\n return this.refresh();\n }\n}\n","/**\n * Minimal parser for the React Server Component (RSC) \"Flight\" wire format used\n * by Next.js Server Action responses.\n *\n * The wire format is a sequence of newline-delimited rows:\n *\n * ```text\n * 0:{\"a\":\"$@1\",\"f\":\"\",\"b\":\"buildId\"}\n * 1:{\"history_id\":\"e3357fb8-...\",\"architecture_config\":\"$T0:0:architectureConfig\"}\n * ```\n *\n * Each row is `<hexId>:<jsonPayload>`. Values may contain sentinels:\n * - `$undefined` → `undefined`\n * - `$@<id>` → reference to another row (a resolved promise)\n * - `$$...` → an escaped literal string starting with `$`\n * - `$<other>` → a typed marker (kept verbatim, best-effort)\n *\n * @remarks\n * The exact envelope for some read actions (e.g. `getHistoryById`) should be\n * confirmed against live traffic via the rev-eng Playwright flow; this parser is\n * intentionally tolerant and falls back to the last JSON row when the row-0\n * `{ a: ... }` envelope is absent.\n */\nimport { RscParseError } from './errors.js';\n\nconst REF_RE = /^\\$@([0-9a-f]+)$/i;\n/** A plain row reference like `$5` (not a promise `$@5`, nor a `$D`/`$S`/... marker). */\nconst HEX_REF_RE = /^\\$([0-9a-f]+)$/i;\nconst ROW_ID_RE = /^[0-9a-f]+$/i;\n\n/** Return the char index after consuming exactly `byteLen` UTF-8 bytes from `start`. */\nfunction endOfUtf8Slice(text: string, start: number, byteLen: number): number {\n let bytes = 0;\n let i = start;\n while (i < text.length && bytes < byteLen) {\n const cp = text.codePointAt(i) as number;\n bytes += cp <= 0x7f ? 1 : cp <= 0x7ff ? 2 : cp <= 0xffff ? 3 : 4;\n i += cp > 0xffff ? 2 : 1;\n }\n return i;\n}\n\n/**\n * Parse the raw Flight text into a map of `rowId → value`.\n *\n * @remarks\n * Most rows are `id:<json>\\n`, but text rows are length-delimited:\n * `id:T<hexlen>,<hexlen UTF-8 bytes>` and are NOT newline-terminated — the next\n * row begins immediately after the counted bytes. A naive line split therefore\n * glues the following data row onto a multi-line prompt (which is exactly why\n * large `getHistoryPaginated` responses failed to parse). This parser is\n * position/length aware so length-delimited rows are consumed exactly and every\n * subsequent row stays isolated.\n */\nexport function parseFlightRows(text: string): Map<string, unknown> {\n const rows = new Map<string, unknown>();\n const n = text.length;\n let pos = 0;\n while (pos < n) {\n if (text[pos] === '\\n') {\n pos += 1;\n continue;\n }\n const colon = text.indexOf(':', pos);\n if (colon === -1) {\n break;\n }\n const id = text.slice(pos, colon);\n if (!ROW_ID_RE.test(id)) {\n // Not a row boundary; skip to the next line and resync.\n const nl = text.indexOf('\\n', pos);\n if (nl === -1) {\n break;\n }\n pos = nl + 1;\n continue;\n }\n if (text[colon + 1] === 'T') {\n // Length-delimited text row: T<hexlen>,<bytes> (no trailing newline).\n const comma = text.indexOf(',', colon + 2);\n if (comma === -1) {\n break;\n }\n const byteLen = Number.parseInt(text.slice(colon + 2, comma), 16);\n const start = comma + 1;\n const end = endOfUtf8Slice(text, start, byteLen);\n rows.set(id, text.slice(start, end));\n pos = end;\n continue;\n }\n // Any other row is a single line terminated by \\n.\n const nl = text.indexOf('\\n', colon + 1);\n const payload = nl === -1 ? text.slice(colon + 1) : text.slice(colon + 1, nl);\n pos = nl === -1 ? n : nl + 1;\n const first = payload[0];\n if (first === undefined) {\n continue;\n }\n const looksJson =\n first === '{' ||\n first === '[' ||\n first === '\"' ||\n first === '-' ||\n (first >= '0' && first <= '9') ||\n payload === 'true' ||\n payload === 'false' ||\n payload === 'null';\n if (!looksJson) {\n // Module/element/hint rows (e.g. `1:I[...]`, `2:\"$Sreact...\"`) are not data.\n continue;\n }\n try {\n rows.set(id, JSON.parse(payload));\n } catch {\n // Ignore rows that are not valid JSON.\n }\n }\n return rows;\n}\n\n/** Recursively resolve Flight sentinels/references within a parsed value. */\nexport function resolveFlightValue(\n value: unknown,\n rows: Map<string, unknown>,\n seen: Set<string> = new Set(),\n): unknown {\n if (typeof value === 'string') {\n if (value === '$undefined') {\n return undefined;\n }\n const ref = REF_RE.exec(value) ?? HEX_REF_RE.exec(value);\n if (ref) {\n const refId = ref[1];\n if (refId === undefined || seen.has(refId)) {\n return undefined;\n }\n seen.add(refId);\n const target = rows.get(refId);\n return target === undefined ? undefined : resolveFlightValue(target, rows, seen);\n }\n if (value.startsWith('$$')) {\n return value.slice(1);\n }\n // $D<iso> → Date object (React Flight Date sentinel).\n if (value.startsWith('$D')) {\n return new Date(value.slice(2));\n }\n // Other `$`-prefixed markers are kept verbatim.\n return value;\n }\n if (Array.isArray(value)) {\n return value.map((entry) => resolveFlightValue(entry, rows, seen));\n }\n if (value !== null && typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n out[key] = resolveFlightValue(entry, rows, seen);\n }\n return out;\n }\n return value;\n}\n\n/**\n * Parse a Server Action response and return the action's resolved return value.\n *\n * @throws {RscParseError} when the response contains no parseable rows.\n */\nexport function parseServerActionResponse<T = unknown>(text: string): T {\n const rows = parseFlightRows(text);\n if (rows.size === 0) {\n throw new RscParseError('Empty or unparseable RSC response');\n }\n const root = rows.get('0');\n if (root !== null && typeof root === 'object' && !Array.isArray(root) && 'a' in root) {\n return resolveFlightValue((root as Record<string, unknown>).a, rows) as T;\n }\n // Fallback: the highest-id row usually carries the payload.\n let lastId: string | null = null;\n for (const id of rows.keys()) {\n if (lastId === null || Number.parseInt(id, 16) > Number.parseInt(lastId, 16)) {\n lastId = id;\n }\n }\n return resolveFlightValue(lastId === null ? undefined : rows.get(lastId), rows) as T;\n}\n\n/**\n * Unwrap a single-object result that some Server Actions (notably the\n * `*Parallel` family) wrap in a one-element array.\n *\n * @remarks\n * `getCreationsPaginatedParallel` and `getMentionSuggestionsParallel` return their\n * payload as `[value]` on the RSC wire (`1:[\"$@2\"]`), whereas most actions return\n * the value directly. This normalizes object-returning actions to the value; it is\n * a no-op when the response is already the object. Do NOT use it for actions whose\n * genuine return type is an array (e.g. `getReferences`).\n */\nexport function unwrapResult<T>(value: unknown): T {\n return (Array.isArray(value) && value.length === 1 ? value[0] : value) as T;\n}\n","/**\n * Character & reference management.\n *\n * Covers the verified Server Actions from `docs/api/characters.md`: search\n * (`getMentionSuggestionsParallel`), full CRUD, pagination, publish/unpublish,\n * and base64 image uploads.\n *\n * @remarks\n * Read operations pass the caller's `uid` in the body; write operations rely on\n * the `__session` cookie (the server derives the uid from it). All actions are\n * posted to the `/explore` page where their bundles are loaded.\n */\nimport type { AuthManager } from './auth.js';\nimport type { HttpClient } from './http.js';\nimport { unwrapResult } from './rsc.js';\nimport type {\n Character,\n CharacterPage,\n CharacterSearchResult,\n CreateCharacterInput,\n GenerateVoiceOptions,\n ListCharactersOptions,\n SearchCharactersOptions,\n UpdateCharacterInput,\n VoiceResult,\n} from './types.js';\n\n/** Character actions are served from the `/explore` page. */\nconst CHARACTERS_PATH = '/explore';\nconst DEFAULT_SEARCH_LIMIT = 10;\n\nexport class CharactersService {\n constructor(\n private readonly http: HttpClient,\n private readonly auth: AuthManager,\n ) {}\n\n /** Search the caller's characters (and optionally public references) by name. */\n async search(opts: SearchCharactersOptions): Promise<CharacterSearchResult> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const body = {\n query: opts.query,\n uid,\n limit: opts.limit ?? DEFAULT_SEARCH_LIMIT,\n includePublicReferences: opts.includePublicReferences ?? false,\n referenceModalities: opts.referenceModalities ?? ['image', 'audio'],\n };\n const { data } = await this.http.callAction<CharacterSearchResult>({\n action: 'getMentionSuggestionsParallel',\n path: CHARACTERS_PATH,\n args: [body],\n session,\n });\n return unwrapResult<CharacterSearchResult>(data);\n }\n\n /** Create a new character from an already-uploaded image URL. */\n async create(input: CreateCharacterInput): Promise<Character> {\n const session = await this.auth.getSession();\n const body = {\n name: input.name,\n username: input.username,\n image_url: input.image_url,\n audio_url: input.audio_url ?? null,\n description: input.description ?? null,\n tags: input.tags ?? [],\n visibility: input.visibility ?? 'private',\n moderation: input.moderation ?? [],\n };\n const { data } = await this.http.callAction<Character>({\n action: 'createCharacter',\n path: CHARACTERS_PATH,\n args: [body],\n session,\n });\n return data;\n }\n\n /** Update a character's mutable fields (name, description, tags, visibility, voice). */\n async update(id: string, patch: UpdateCharacterInput): Promise<Character> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<Character>({\n action: 'updateCharacter',\n path: CHARACTERS_PATH,\n args: [id, patch],\n session,\n });\n return data;\n }\n\n /** Soft-delete a character. */\n async delete(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n\n /** Fetch a single character by id; resolves to `null` when it does not exist. */\n async get(id: string): Promise<Character | null> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<Character | null>({\n action: 'getCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n return data ?? null;\n }\n\n /** Fetch multiple characters by id in a single call. */\n async getMany(ids: string[]): Promise<Character[]> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<Character[]>({\n action: 'getCharacters',\n path: CHARACTERS_PATH,\n args: [ids],\n session,\n });\n return data ?? [];\n }\n\n /** Make a character public. */\n async publish(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'publishCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n\n /** Make a character private. */\n async unpublish(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'unpublishCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n\n /**\n * Upload a character reference image (base64 data URL) and return its CDN URL.\n *\n * @param dataUrl - `data:image/jpeg;base64,...` (JPEG preferred; PNG/WebP ok).\n */\n async uploadImage(dataUrl: string): Promise<string> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const { data } = await this.http.callAction<string>({\n action: 'uploadCharacterImage',\n path: CHARACTERS_PATH,\n args: [dataUrl, uid],\n session,\n });\n return data;\n }\n\n /**\n * Browse characters with pagination.\n *\n * @remarks\n * Omit `uid` to browse the public/featured feed; pass it to page through a\n * single user's characters.\n */\n async listPaginated(opts: ListCharactersOptions = {}): Promise<CharacterPage> {\n const session = await this.auth.getSession();\n const limit = opts.limit ?? 100;\n const offset = opts.offset ?? 0;\n const filters: Record<string, unknown> = {};\n if (opts.uid !== undefined) {\n filters.uid = opts.uid;\n }\n if (opts.visibility !== undefined) {\n filters.visibility = opts.visibility;\n }\n if (opts.modality !== undefined) {\n filters.modality = opts.modality;\n }\n if (opts.featured !== undefined) {\n filters.featured = opts.featured;\n }\n const { data } = await this.http.callAction<CharacterPage>({\n action: 'getCharactersPaginated',\n path: CHARACTERS_PATH,\n args: [limit, offset, filters],\n session,\n });\n return data;\n }\n\n /**\n * Generate a voice for a character from its reference image.\n *\n * @remarks Costs gems (not covered by the unlimited tier).\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async generateVoice(opts: GenerateVoiceOptions): Promise<VoiceResult> {\n const [authToken, session] = await Promise.all([\n this.auth.getIdToken(),\n this.auth.getSession(),\n ]);\n const { data } = await this.http.callAction<VoiceResult>({\n action: 'generateCharacterVoice',\n path: CHARACTERS_PATH,\n args: [{ imageUrl: opts.imageUrl, guidancePrompt: opts.guidancePrompt ?? '' }, authToken],\n session,\n });\n return data;\n }\n\n /**\n * Follow a (public) character.\n *\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async follow(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'followCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n\n /**\n * Unfollow a character.\n *\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async unfollow(id: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'unfollowCharacter',\n path: CHARACTERS_PATH,\n args: [id],\n session,\n });\n }\n}\n","/**\n * Firebase authentication: refresh token → ID token → session cookie.\n *\n * The refresh token is the only long-lived credential the caller supplies.\n * From it we mint a Firebase ID token (~1h) via the Secure Token REST API, and\n * exchange that for a `__session` cookie (~24h) via the `createUserSession`\n * Server Action. Both are cached and refreshed 5 minutes before expiry.\n */\nimport { decodeJwt } from 'jose';\nimport { AuthError } from './errors.js';\nimport type { HttpClient } from './http.js';\nimport type { AuthTokens, FetchLike, SessionState } from './types.js';\n\nconst DEFAULT_FIREBASE_API_KEY = 'AIzaSyAzUV2NNUOlLTL04jwmUw9oLhjteuv6Qr4';\nconst SECURE_TOKEN_URL = 'https://securetoken.googleapis.com/v1/token';\nconst EXPIRY_BUFFER_MS = 5 * 60 * 1000;\nconst SESSION_DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;\nconst ID_TOKEN_DEFAULT_TTL_S = 3600;\n\ninterface SecureTokenResponse {\n id_token?: string;\n refresh_token?: string;\n user_id?: string;\n expires_in?: string;\n}\n\nexport interface AuthManagerOptions {\n refreshToken: string;\n http: HttpClient;\n fetch: FetchLike;\n firebaseApiKey?: string;\n /** Page path for the `createUserSession` action (default `/creations`). */\n sessionPath?: string;\n}\n\nexport class AuthManager {\n private refreshToken: string;\n private readonly http: HttpClient;\n private readonly fetchImpl: FetchLike;\n private readonly apiKey: string;\n private readonly sessionPath: string;\n private tokens: AuthTokens | null = null;\n private session: SessionState | null = null;\n\n constructor(opts: AuthManagerOptions) {\n this.refreshToken = opts.refreshToken;\n this.http = opts.http;\n this.fetchImpl = opts.fetch;\n this.apiKey = opts.firebaseApiKey ?? DEFAULT_FIREBASE_API_KEY;\n this.sessionPath = opts.sessionPath ?? '/creations';\n }\n\n /** Return a valid Firebase ID token, refreshing via the refresh token if needed. */\n async getIdToken(): Promise<string> {\n if (this.tokens !== null && Date.now() < this.tokens.expiresAt - EXPIRY_BUFFER_MS) {\n return this.tokens.idToken;\n }\n return (await this.refreshTokens()).idToken;\n }\n\n /** Return the Firebase uid (fetching an ID token first if necessary). */\n async getUserId(): Promise<string> {\n if (this.tokens !== null) {\n return this.tokens.userId;\n }\n return (await this.refreshTokens()).userId;\n }\n\n /** Return a valid `__session` cookie, creating one via `createUserSession` if needed. */\n async getSession(): Promise<string> {\n if (this.session !== null && Date.now() < this.session.expiresAt - EXPIRY_BUFFER_MS) {\n return this.session.cookie;\n }\n const idToken = await this.getIdToken();\n const result = await this.http.callAction<unknown>({\n action: 'createUserSession',\n path: this.sessionPath,\n args: [idToken],\n });\n const cookie = extractSessionCookie(result.headers);\n if (cookie === null) {\n throw new AuthError('createUserSession did not return a __session cookie');\n }\n const expiresAt = jwtExpiryMs(cookie) ?? Date.now() + SESSION_DEFAULT_TTL_MS;\n this.session = { cookie, expiresAt };\n return cookie;\n }\n\n private async refreshTokens(): Promise<AuthTokens> {\n const body = new URLSearchParams({\n grant_type: 'refresh_token',\n refresh_token: this.refreshToken,\n });\n const res = await this.fetchImpl(`${SECURE_TOKEN_URL}?key=${this.apiKey}`, {\n method: 'POST',\n headers: { 'content-type': 'application/x-www-form-urlencoded' },\n body: body.toString(),\n });\n if (!res.ok) {\n throw new AuthError(\n `Token refresh failed: HTTP ${res.status} (refresh token may be invalid or revoked)`,\n );\n }\n const json = (await res.json()) as SecureTokenResponse;\n if (json.id_token === undefined || json.user_id === undefined) {\n throw new AuthError('Token refresh response missing id_token/user_id');\n }\n if (json.refresh_token !== undefined) {\n this.refreshToken = json.refresh_token;\n }\n const ttlS = json.expires_in === undefined ? ID_TOKEN_DEFAULT_TTL_S : Number(json.expires_in);\n const expiresAt = jwtExpiryMs(json.id_token) ?? Date.now() + ttlS * 1000;\n this.tokens = {\n idToken: json.id_token,\n refreshToken: this.refreshToken,\n userId: json.user_id,\n expiresAt,\n };\n return this.tokens;\n }\n}\n\n/** Read the `exp` claim (ms) from a JWT, or `null` if it cannot be decoded. */\nfunction jwtExpiryMs(jwt: string): number | null {\n try {\n const { exp } = decodeJwt(jwt);\n return typeof exp === 'number' ? exp * 1000 : null;\n } catch {\n return null;\n }\n}\n\n/** Extract the `__session` value from a `Set-Cookie` response header. */\nfunction extractSessionCookie(headers: Headers): string | null {\n const withGetSetCookie = headers as Headers & { getSetCookie?: () => string[] };\n const list =\n typeof withGetSetCookie.getSetCookie === 'function'\n ? withGetSetCookie.getSetCookie()\n : headers.get('set-cookie') !== null\n ? [headers.get('set-cookie') as string]\n : [];\n for (const cookie of list) {\n const match = /(?:^|;\\s*)__session=([^;]+)/.exec(cookie);\n if (match !== null && match[1] !== undefined) {\n return match[1];\n }\n }\n return null;\n}\n","/**\n * Image generation: submit a job via `runArchitecture`, then poll\n * `getHistoryById` until the job succeeds, fails, or times out.\n */\nimport type { AuthManager } from './auth.js';\nimport { GenerationError, TimeoutError } from './errors.js';\nimport type { HttpClient } from './http.js';\nimport type {\n ArchitectureConfig,\n CharacterRef,\n GenerateOptions,\n GenerateVideoOptions,\n GenerationMode,\n HistoryItem,\n VideoArchitectureConfig,\n WaitOptions,\n} from './types.js';\n\n/** Generation actions are served from the `/explore` page. */\nconst GENERATION_PATH = '/explore';\n/** RSC sentinel for an absent value. */\nconst UNDEFINED = '$undefined';\n/** Default concept id for mango-v3-pro (from docs — verify per model via rev-eng). */\nconst DEFAULT_CONCEPT_ID = '0cd8c7ed2e554d0f98f20c8cf8c0f7c';\n/** Default concept id for berry-2 video (from docs — verify per model via rev-eng). */\nconst DEFAULT_BERRY_CONCEPT_ID = '0b1fa74f7347406392422d24f2885684';\n\nconst DEFAULT_POLL_INTERVAL_MS = 4000;\nconst DEFAULT_TIMEOUT_MS = 5 * 60 * 1000;\n\nexport class GenerationService {\n constructor(\n private readonly http: HttpClient,\n private readonly auth: AuthManager,\n ) {}\n\n /** Submit an image generation job and return its `historyId`. */\n async submit(opts: GenerateOptions): Promise<{ historyId: string }> {\n const config: ArchitectureConfig = {\n seed: opts.seed ?? null,\n prompt: opts.prompt,\n model_id: opts.model ?? 'mango-v3-pro',\n fast_mode: opts.fastMode ?? false,\n resolution: opts.resolution ?? '1K',\n architecture: opts.architecture ?? 'mango',\n aspect_ratio: opts.aspectRatio ?? 'portrait',\n image: opts.image ?? UNDEFINED,\n additional_images: opts.additionalImages ?? [],\n characters: mapCharacters(opts.characters),\n references: mapCharacters(opts.references),\n audio_references: [],\n moodboard: UNDEFINED,\n };\n return this.runArchitecture(config, opts.conceptId ?? DEFAULT_CONCEPT_ID, opts.generationMode);\n }\n\n /** Submit a video generation job (Berry-2 family) and return its `historyId`. */\n async submitVideo(opts: GenerateVideoOptions): Promise<{ historyId: string }> {\n const config: VideoArchitectureConfig = {\n seed: opts.seed ?? null,\n prompt: opts.prompt,\n model_id: opts.model ?? 'berry-2',\n fast_mode: opts.fastMode ?? false,\n resolution: opts.resolution ?? '480p',\n architecture: opts.architecture ?? 'berry',\n berry_aspect_ratio: opts.aspectRatio ?? '9:16',\n duration: opts.duration ?? '3',\n image: opts.image ?? UNDEFINED,\n additional_images: opts.additionalImages ?? [],\n characters: mapCharacters(opts.characters),\n references: mapCharacters(opts.references),\n audio_references: [],\n };\n return this.runArchitecture(\n config,\n opts.conceptId ?? DEFAULT_BERRY_CONCEPT_ID,\n opts.generationMode,\n );\n }\n\n /** Shared `runArchitecture` call for image and video configs. */\n private async runArchitecture(\n config: ArchitectureConfig | VideoArchitectureConfig,\n conceptId: string,\n generationMode: GenerationMode = 'unlimited',\n ): Promise<{ historyId: string }> {\n const [authToken, session] = await Promise.all([\n this.auth.getIdToken(),\n this.auth.getSession(),\n ]);\n\n const args = [\n {\n architectureConfig: config,\n architectureConfigToSave: '$0:0:architectureConfig',\n authToken,\n conceptId,\n activePowerPack: null,\n generationMode,\n },\n ];\n\n const { data } = await this.http.callAction<Record<string, unknown>>({\n action: 'runArchitecture',\n path: GENERATION_PATH,\n args,\n session,\n });\n\n if (data !== null && typeof data === 'object' && 'error_code' in data) {\n const code = Number(data.error_code);\n throw new GenerationError(errorMessageForCode(code), code);\n }\n const historyId = data !== null && typeof data === 'object' ? data.history_id : undefined;\n if (typeof historyId !== 'string') {\n throw new GenerationError('runArchitecture did not return a history_id');\n }\n return { historyId };\n }\n\n /** Fetch a single history record by id. */\n async getHistory(historyId: string): Promise<HistoryItem> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<HistoryItem>({\n action: 'getHistoryById',\n path: GENERATION_PATH,\n args: [historyId],\n session,\n });\n return data;\n }\n\n /** Cancel a running generation job. */\n async cancelJob(historyId: string): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'cancelArchitectureJob',\n path: GENERATION_PATH,\n args: [historyId],\n session,\n });\n }\n\n /** Poll until the job leaves the `running` state, returning the final record. */\n async waitForResult(historyId: string, opts: WaitOptions = {}): Promise<HistoryItem> {\n const intervalMs = opts.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const deadline = Date.now() + timeoutMs;\n\n for (;;) {\n if (opts.signal?.aborted === true) {\n throw new TimeoutError('waitForResult was aborted');\n }\n const item = await this.getHistory(historyId);\n if (item.status === 'success') {\n return item;\n }\n if (item.status === 'error') {\n throw new GenerationError(`Generation failed: ${JSON.stringify(item.error ?? null)}`);\n }\n if (Date.now() > deadline) {\n throw new TimeoutError(\n `Generation timed out after ${timeoutMs}ms (last status: ${item.status})`,\n );\n }\n await delay(intervalMs, opts.signal);\n }\n }\n}\n\nfunction delay(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(resolve, ms);\n signal?.addEventListener(\n 'abort',\n () => {\n clearTimeout(timer);\n reject(new TimeoutError('waitForResult was aborted'));\n },\n { once: true },\n );\n });\n}\n\n/** Normalize characters for an `architectureConfig`, defaulting absent audio to the RSC sentinel. */\nfunction mapCharacters(characters: CharacterRef[] = []): CharacterRef[] {\n return characters.map((c) => ({\n id: c.id,\n name: c.name,\n username: c.username,\n image_url: c.image_url,\n audio_url: c.audio_url ?? UNDEFINED,\n }));\n}\n\nfunction errorMessageForCode(code: number): string {\n switch (code) {\n case 400:\n return 'Bad request (wrong generationMode for your subscription tier?)';\n case 401:\n return 'Authentication failed (token expired or invalid)';\n case 403:\n return 'User is banned';\n case 4031:\n return 'Prompt blocked by content moderation';\n default:\n return `Generation error (code ${code})`;\n }\n}\n","/** Generation history listing via `getHistoryPaginated`. */\nimport type { AuthManager } from './auth.js';\nimport { requireConfirm } from './errors.js';\nimport type { HttpClient } from './http.js';\nimport { unwrapResult } from './rsc.js';\nimport type {\n ConfirmOptions,\n CreationPage,\n GenerationResult,\n HistoryPage,\n ListCreationsOptions,\n ListHistoryOptions,\n} from './types.js';\n\n/** History actions are served from the `/creations` page. */\nconst HISTORY_PATH = '/creations';\nconst DEFAULT_LIMIT = 10;\n/** RSC sentinel for an absent value. */\nconst UNDEFINED = '$undefined';\n\nexport class HistoryService {\n constructor(\n private readonly http: HttpClient,\n private readonly auth: AuthManager,\n ) {}\n\n /** List generation history for the authenticated user. */\n async list(opts: ListHistoryOptions = {}): Promise<HistoryPage> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const limit = opts.limit ?? DEFAULT_LIMIT;\n const offset = opts.offset ?? 0;\n const status = opts.status === 'all' ? UNDEFINED : (opts.status ?? 'success');\n const filters = { status, type: UNDEFINED };\n\n const { data } = await this.http.callAction<HistoryPage>({\n action: 'getHistoryPaginated',\n path: HISTORY_PATH,\n args: [uid, limit, offset, filters],\n session,\n });\n return unwrapResult<HistoryPage>(data);\n }\n\n /** List the user's permanently saved creations. */\n async listCreations(opts: ListCreationsOptions = {}): Promise<CreationPage> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const limit = opts.limit ?? DEFAULT_LIMIT;\n const offset = opts.offset ?? 0;\n const { data } = await this.http.callAction<CreationPage>({\n action: 'getCreationsPaginatedParallel',\n path: HISTORY_PATH,\n args: [uid, limit, offset],\n session,\n });\n return unwrapResult<CreationPage>(data);\n }\n\n /**\n * Save a completed generation result as a permanent creation.\n *\n * @param result - the `result` object of a completed history item.\n * @remarks The API returns no body; call {@link listCreations} to retrieve the\n * saved creation.\n */\n async saveCreation(result: GenerationResult): Promise<void> {\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'saveCreation',\n path: HISTORY_PATH,\n args: [result],\n session,\n });\n }\n\n /**\n * Permanently delete a history item. Irreversible — requires `{ confirm: true }`.\n */\n async deleteHistory(historyId: string, opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteHistory', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteHistory',\n path: HISTORY_PATH,\n args: [historyId],\n session,\n });\n }\n\n /**\n * Permanently delete many history items. Irreversible — requires `{ confirm: true }`.\n *\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async deleteManyHistories(historyIds: string[], opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteManyHistories', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteManyHistories',\n path: HISTORY_PATH,\n args: [historyIds],\n session,\n });\n }\n\n /**\n * Permanently delete a saved creation. Irreversible — requires `{ confirm: true }`.\n */\n async deleteCreation(creationId: string, opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteCreation', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteCreation',\n path: HISTORY_PATH,\n args: [creationId],\n session,\n });\n }\n\n /**\n * Permanently delete many creations. Irreversible — requires `{ confirm: true }`.\n *\n * @experimental Request body inferred from JS bundle; not yet verified live.\n */\n async deleteManyCreations(creationIds: string[], opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteManyCreations', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteManyCreations',\n path: HISTORY_PATH,\n args: [creationIds],\n session,\n });\n }\n}\n","/**\n * Internal HTTP client for Next.js Server Action calls.\n *\n * Every call is a `POST` to a page path with a `next-action` header carrying the\n * action hash, a JSON-array body, and an RSC response that is parsed into the\n * action's return value. A 404 is treated as a stale hash: the registry is\n * invalidated and the call is retried once against freshly discovered hashes.\n */\nimport type { ActionRegistry } from './actions.js';\nimport { MageSpaceError } from './errors.js';\nimport { parseServerActionResponse } from './rsc.js';\nimport type { FetchLike } from './types.js';\n\nconst DEFAULT_USER_AGENT =\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' +\n '(KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36';\n\n/**\n * Known RSC error digests mapped to human-readable messages.\n * Discovered via reverse engineering; the server does not expose error details.\n */\nconst KNOWN_DIGESTS: Record<string, string> = {\n '709776019': 'Username already taken (duplicate character/reference username)',\n '1853426377': 'Username already taken (duplicate character/reference username)',\n};\n\nexport interface CallActionParams {\n /** Server Action function name (resolved to a hash via the registry). */\n action: string;\n /** Page path to POST to (e.g. `/explore`, `/creations`). */\n path: string;\n /** Request body — always a JSON array of arguments. */\n args: unknown[];\n /** `__session` cookie value for authenticated actions. */\n session?: string;\n}\n\nexport interface CallActionResult<T> {\n data: T;\n headers: Headers;\n deploymentId: string;\n}\n\nexport class HttpClient {\n constructor(\n private readonly registry: ActionRegistry,\n private readonly fetchImpl: FetchLike,\n private readonly baseUrl: string,\n private readonly userAgent: string = DEFAULT_USER_AGENT,\n ) {}\n\n async callAction<T = unknown>(\n params: CallActionParams,\n retried = false,\n ): Promise<CallActionResult<T>> {\n const { hash, deploymentId } = await this.registry.getHash(params.action);\n\n const headers: Record<string, string> = {\n accept: 'text/x-component',\n 'content-type': 'text/plain;charset=UTF-8',\n 'next-action': hash,\n 'x-deployment-id': deploymentId,\n origin: this.baseUrl,\n referer: `${this.baseUrl}${params.path}`,\n 'user-agent': this.userAgent,\n };\n if (params.session !== undefined) {\n headers.cookie = `__session=${params.session}`;\n }\n\n const res = await this.fetchImpl(`${this.baseUrl}${params.path}`, {\n method: 'POST',\n headers,\n body: JSON.stringify(params.args),\n });\n\n // A stale (post-deploy) hash surfaces as a 404 OR as a 200 with HTML\n // (Next.js returns the page shell instead of the RSC action response).\n const contentType = res.headers.get('content-type') ?? '';\n const isHtmlFallback = res.ok && contentType.includes('text/html');\n if ((res.status === 404 || isHtmlFallback) && !retried) {\n // Consume the body to prevent socket leaks.\n await safeText(res);\n await this.registry.invalidate();\n return this.callAction<T>(params, true);\n }\n if (!res.ok) {\n const body = await safeText(res);\n // RSC error rows look like: `1:E{\"digest\":\"...\"}` — extract the digest when possible.\n const rscErrorMatch = body.match(/E\\{\"digest\":\"([^\"]+)\"\\}/);\n const digest = rscErrorMatch?.[1];\n const knownDigest = digest !== undefined ? KNOWN_DIGESTS[digest] : undefined;\n const hint = knownDigest ? ` — ${knownDigest}` : digest ? ` (server digest: ${digest})` : '';\n const raw = body.length > 0 ? ` — ${body.slice(0, 200)}` : '';\n throw new MageSpaceError(`Action \"${params.action}\" failed: HTTP ${res.status}${hint}${raw}`);\n }\n\n const text = await res.text();\n const data = parseServerActionResponse<T>(text);\n return {\n data,\n headers: res.headers,\n deploymentId: res.headers.get('x-deployment-id') ?? deploymentId,\n };\n }\n}\n\nasync function safeText(res: Response): Promise<string> {\n try {\n return await res.text();\n } catch {\n return '';\n }\n}\n","/**\n * Reference asset management.\n *\n * References are reusable image/audio assets (generic references, objects,\n * outfits, poses) applied across generations — distinct from characters, which\n * are trained identities. Covers upload, create, update, and listing (own +\n * public feed) per `docs/api/references.md`.\n */\nimport type { AuthManager } from './auth.js';\nimport { requireConfirm } from './errors.js';\nimport type { HttpClient } from './http.js';\nimport type {\n ConfirmOptions,\n CreateReferenceInput,\n ListReferencesOptions,\n Modality,\n Reference,\n ReferencePage,\n UpdateReferenceInput,\n} from './types.js';\n\n/** Reference actions are served from the `/explore` page. */\nconst REFERENCES_PATH = '/explore';\nconst DEFAULT_PAGE_LIMIT = 20;\n\nexport class ReferencesService {\n constructor(\n private readonly http: HttpClient,\n private readonly auth: AuthManager,\n ) {}\n\n /**\n * Upload a reference image (base64 data URL) and return its CDN URL.\n *\n * @param dataUrl - `data:image/jpeg;base64,...` (JPEG preferred; PNG/WebP ok).\n */\n async uploadImage(dataUrl: string): Promise<string> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const { data } = await this.http.callAction<string>({\n action: 'uploadReferenceImage',\n path: REFERENCES_PATH,\n args: [dataUrl, uid],\n session,\n });\n return data;\n }\n\n /** Create a reusable reference from an uploaded image/audio URL. */\n async create(input: CreateReferenceInput): Promise<Reference> {\n const session = await this.auth.getSession();\n const body = {\n name: input.name,\n username: input.username,\n image_url: input.image_url,\n audio_url: input.audio_url ?? null,\n modality: input.modality ?? 'image',\n variant: input.variant ?? 'reference',\n description: input.description ?? null,\n tags: input.tags ?? [],\n visibility: input.visibility ?? 'private',\n moderation: input.moderation ?? [],\n };\n const { data } = await this.http.callAction<Reference>({\n action: 'createReference',\n path: REFERENCES_PATH,\n args: [body],\n session,\n });\n return data;\n }\n\n /** Update a reference's mutable fields (name, description, tags, visibility). */\n async update(id: string, patch: UpdateReferenceInput): Promise<Reference> {\n const session = await this.auth.getSession();\n const { data } = await this.http.callAction<Reference>({\n action: 'updateReference',\n path: REFERENCES_PATH,\n args: [id, patch],\n session,\n });\n return data;\n }\n\n /**\n * Permanently delete a reference (soft-delete). Irreversible — requires\n * `{ confirm: true }`.\n */\n async delete(id: string, opts?: ConfirmOptions): Promise<void> {\n requireConfirm('deleteReference', opts);\n const session = await this.auth.getSession();\n await this.http.callAction({\n action: 'deleteReference',\n path: REFERENCES_PATH,\n args: [id],\n session,\n });\n }\n\n /** List the caller's own references for a given modality (default `image`). */\n async list(modality: Modality = 'image'): Promise<Reference[]> {\n const [uid, session] = await Promise.all([this.auth.getUserId(), this.auth.getSession()]);\n const { data } = await this.http.callAction<Reference[]>({\n action: 'getReferences',\n path: REFERENCES_PATH,\n args: [uid, modality],\n session,\n });\n return data ?? [];\n }\n\n /**\n * Browse references with pagination.\n *\n * @remarks\n * Omit `uid` to browse the public/featured feed; pass it to page through a\n * single user's references.\n */\n async listPaginated(opts: ListReferencesOptions = {}): Promise<ReferencePage> {\n const session = await this.auth.getSession();\n const limit = opts.limit ?? DEFAULT_PAGE_LIMIT;\n const offset = opts.offset ?? 0;\n const filters: Record<string, unknown> = {\n visibility: opts.visibility ?? 'public',\n orderBy: opts.orderBy ?? 'top',\n featuredOnly: opts.featuredOnly ?? false,\n modality: opts.modality ?? 'image',\n };\n if (opts.uid !== undefined) {\n filters.uid = opts.uid;\n }\n const { data } = await this.http.callAction<ReferencePage>({\n action: 'getReferencesPaginated',\n path: REFERENCES_PATH,\n args: [limit, offset, filters],\n session,\n });\n return data;\n }\n}\n","import type { ActionSnapshot } from './types.js';\n\n/**\n * Bundled action-hash snapshot from the mage.space Vercel deploy discovered on\n * 2026-08-24 (`docs/api/actions.md`).\n *\n * @remarks\n * Used as a warm seed so the very first call does not pay the discovery cost.\n * Hashes change on every deploy; when one goes stale the client re-discovers\n * automatically (404 → invalidate → refresh).\n */\nexport const SEED_SNAPSHOT: ActionSnapshot = {\n deploymentId: 'dpl_2w2igPYTRJKeDaX6iAUMbGwDEWZC',\n discoveredAt: Date.parse('2026-08-24T13:15:00.000Z'),\n hashes: {\n createUserSession: '60b45776be93d57b1f43deaf8d6f9a837c6b9c169b',\n deleteUserSession: '0044441bb36afa0ba15ca13c4cf3a831ac81108c7a',\n getUserHydrationData: '40b253dcab658b78ba3673c5244f96578f22d65606',\n runArchitecture: '40c4d7d5e695e1a2e2992174b75562ef5df377b206',\n getHistoryById: '4042bfb22d370cd4e3f0f41812e826a63c179cb8a8',\n cancelArchitectureJob: '401dc98670483cb67cc9b1b6a623c4fa7cb71348a2',\n cancelAllRunningArchitectureJobs: '0004b976add66997b6518bd2d25f04444b8df4e3b2',\n getMentionSuggestionsParallel: '7fe1156be29ed3824514220877818246e7649234fa',\n createCharacter: '401ceece486398904b9ba48daa7fc0ac951fb72168',\n updateCharacter: '6057ae8c4ae8868e3a4b045845814b0689ac61a1e0',\n deleteCharacter: '4071b6010bffdf242150e0322cd0966463268414d8',\n getCharacter: '40ce38eb438c78fa51ee09be911ba0c3b02d7cbcad',\n getCharacters: '40c74f795b040ec3d0841360b532eb938932fc4bc3',\n getCharactersPaginated: '709855baaecec89ad7b73ca44621fe93dfd93fcdee',\n publishCharacter: '40b489876c75c1cd836a108742da4753fb2f671565',\n unpublishCharacter: '40c785b54f5c25bd50cfaebc6817f9d0b9f5e6e145',\n uploadCharacterImage: '60ef3377c68f0cf34c60646d9356e622a9230a68e5',\n uploadReferenceImage: '60c497b22c1b65f8a4e78055c5d9e0c2bc49e2c7bd',\n createReference: '403a057e1bd8967b3bb728df1722019d14ca7c4e14',\n updateReference: '60819ffb5ec61122bc4dd52b2232fd486a155d23c6',\n deleteReference: '409098eedd49e49ac5f0275d8af9c70a0988e9859c',\n getReferences: '605e5d2876598666c4681f8f08f4ecbe7488d1762d',\n getReferencesPaginated: '702382e902dbe43b4343265b6a251c30b878eae08a',\n getCreationsPaginatedParallel: '7f5eb618ca5c4c243c51a04c5dea108aefe8aa37d2',\n getHistoryPaginated: '7817d35897de571dfa2c6c525ee7bff73ba6d590d6',\n clearUserHistory: '4038b8e21b2e6eac7c78c076ef04f1db91718cfd69',\n deleteHistory: '40f4de31887560f79274b13f8abd3a282f6c3321f7',\n deleteManyHistories: '4006a9773613e8ea05421e6f2c91fe6417fe33d892',\n deleteCreation: '40ceaf58a77a287e3146d5792b147dba9df5ec0257',\n deleteManyCreations: '4092a1e1531442421916268184300f37a4478900ed',\n saveCreation: '60860eb37a9862d41d7b92af9bbe572652e076bc43',\n saveManyCreations: '400f59bf4b0ce788050b25259aecc9bf7839f8ba11',\n generateCharacterVoice: '60b54e75a5c3de2b0e4df7ebec5cf6ef1aaeb2ed35',\n followCharacter: '403b46c309f4239df7579c00654881afd855fc1757',\n unfollowCharacter: '400dd84b2d0f2f582df6c72092ea5249678b68d4d5',\n getFilteredCharacterIds: '403b8603d61033bbe1c30c9d1c12133b9ed4e16348',\n getFilteredReferenceIds: '40a87aa0793c102e72b7858e1024c0c2f01c96a720',\n getConceptsParallel: '7f5cf8a4696938e3a148c3c293922fbcd0f8cdbd08',\n getConcept: '408caa15371b2240267a5521c4130fefcff4ba515d',\n getModel: '40f88ee2580ed9a6ae6ff3bf6ec5840b22946dbba3',\n getModels: '70fbe28eadea3cb6d563b1f5bf50c2ad179535e6e8',\n getArticlesParallel: '7f743849b6ddf8eeb21eefceb2b93c93b6d19f203f',\n searchUsersParallel: '7ff9c981309e38b9efb215d0943b34380401a93362',\n getEmbeddingParallel: '7fa14c0b84ee996caad1a598bc2b021bd9545a3383',\n getLatestPublishedArticleCached: '7f0e2eb3e1407b27b2cc338235134b3fbf25c88ddc',\n hasPurchasedGemsParallel: '7f223962cad80e4dbdd3df7dc2039f65a42c461d87',\n syncStripeSubscriptionParallel: '7f19bb611b725a3cb8d99dc5d72ab11e0595087f6e',\n getSubscriptionPlayUsage: '40c9d7d3d029eee45885df18797dbca20315ff4fca',\n saveContentSettings: '4095ebf4d1b43894777ef2e3e06b9a556275fafcf0',\n deleteUser: '40692c054de95018353e0c8512082f6f9103cac6d7',\n getMyUserMembership: '007ce34998f2bf4f19be3cf46e3cfcb387110ae5d5',\n getActiveUserBan: '60e4352df1676fbe169421c5709479f1534cccb371',\n getCreditBalance: '009364b01be29ea5b25711fff2c6284af88caa4e4c',\n getCreditBalanceBreakdown: '00ddc14328cf19e8fbec823474a7169214cfd30603',\n getActivePowerPack: '00a6404083c8958fcd47607a088c1d1a7a5dfd4514',\n getUnusedPowerPacks: '00b5d80d96598fc2db4641fff117cfa47b37f2482f',\n getPowerPackStatsById: '4027b533e8532d2f35cbbb7518160d7569b738cb20',\n getLastGemPurchaseType: '008f0fb3448464f9f0e5ac2b6b15fc5fb59d8ccce4',\n getCheckoutUrlWithStripeDirect: '7c0f0773c703de16b1abe5f869c2164108473c5820',\n getPortalUrlWithStripeDirect: '60655cb929f6eb281aef8c25311806cfaed5aeb8af',\n removeInactiveSubscriptions: '00b5b012ef33665bb3cdf3f8e931483a0d8dc96461',\n hasCreatedImageReference: '002876b36888ccf790e8e5b9413ae951d07594a4c3',\n createLink: '40ffeee6dd712d83ce286aa22d07446822adb5ec02',\n tempToPermanentFile: '40f30eb9909274b48fa7654e7648cdf188bf3e015d',\n uploadTempCreationImage: '60f0c8b2c98566eb131e69ec1e8ee95c78ad4c332f',\n uploadUserImage: '604d67807ffec2bcdaf936e03c27c7fcc8e49880f8',\n getUserAudioUploadUrl: '7019e155efbd5aa4eb2200a48d6f7265cf6aa686e9',\n getUserVideoUploadUrl: '70cab2e17fe2c04a964489850642235ada2cb0adf3',\n processVideoFromUrl: '70901405c8bff0dcb9ea40053f1176caeb1b99ae4c',\n processAudio: '60bd5fa2fd7c30e53ef2a22342408ed1aab0a766a7',\n segmentImage: '40d827c38726f2d2bbc559f94eafe0f1fc84b50e70',\n moderateMedia: '403006c99a6b3cd6e684c163e0df35f44e403f7ca7',\n checkSharedUsernameAvailable: '6000cca07091fb38d8a77fad195b95b2ea73634895',\n getCreationTagCountsParallel: '7f0f20d7a26711c076aefeb73e65273ac1572381d8',\n updateCreations: '4055ce23f7e1fac54bfceb33b816f9574b82d2127d',\n getCreationsPaginated: '780d8f5e01f24e1342e5e4a475321123eb156dcf2a',\n resolveMoodboardRuntimeSelection: '40080c3021ac4c02f675c25a7443b03ee96e57837a',\n saveProfileCollections: '4071958ca110ab37fe59be3b019bfc39b1fa0c9143',\n banUser: '70c46c18b6223613cee3a4f17ce076672f29a6bba5',\n undoTemporaryBanUser: '40199a810acd4149e53fc182ba1ff9e8a7dde19283',\n temporaryBanUser: '788b8a43fb42b87cd942e3d0229307bea6497ef8e9',\n getCharacterFollowStatus: '40d220eb13610f029b46bbcfc7c9117478b3b738f2',\n reportCharacter: '400525e8101daa2496bad7a7c7e91c5cca00d574c2',\n toggleFeatureCharacter: '40a640496a2e6bf7cb124405c74f8a928aeccbf964',\n getSiteAlertParallel: '7f382e755e1d8d7670272b36656280dd661aa9abce',\n getChatsParallel: '7f741bb8b517b0ba95f6b941ab1ce0efcb870341f6',\n getChatMessages: '40f8886c57d93aae7265d1805af5765589e2be7d15',\n markChatRead: '408c569fdaa0d2ab12e0b8019cf661a99c9d182f68',\n getPostMediaFeedParallel: '7f9ce48dd331eb4103e9d2d18b23b6008e3bf5c502',\n createAutoCreationCampaign: '404c84350ce7aba35a332ab3129334ed19cfb107fd',\n },\n};\n","/**\n * {@link MageSpaceClient} — the public facade that wires together action\n * discovery, authentication, generation, and history.\n */\nimport { ActionRegistry } from './actions.js';\nimport { AuthManager } from './auth.js';\nimport { CharactersService } from './characters.js';\nimport { GenerationService } from './generation.js';\nimport { HistoryService } from './history.js';\nimport { HttpClient } from './http.js';\nimport { ReferencesService } from './references.js';\nimport { SEED_SNAPSHOT } from './seed.js';\nimport type {\n ActionSnapshot,\n ConfirmOptions,\n CreationPage,\n FetchLike,\n GenerateOptions,\n GenerateVideoOptions,\n GenerationResult,\n HistoryItem,\n HistoryPage,\n ListCreationsOptions,\n ListHistoryOptions,\n MageSpaceClientOptions,\n WaitOptions,\n} from './types.js';\n\nconst DEFAULT_BASE_URL = 'https://www.mage.space';\n\nexport class MageSpaceClient {\n private readonly registry: ActionRegistry;\n private readonly auth: AuthManager;\n private readonly generationService: GenerationService;\n private readonly historyService: HistoryService;\n\n /** Character management (search, CRUD, pagination, uploads). */\n readonly characters: CharactersService;\n\n /** Reference asset management (upload, create, update, list, feed). */\n readonly references: ReferencesService;\n\n constructor(options: MageSpaceClientOptions) {\n if (!options.refreshToken) {\n throw new Error('MageSpaceClient requires a refreshToken');\n }\n const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;\n const fetchImpl: FetchLike = options.fetch ?? ((input, init) => fetch(input, init));\n\n this.registry = new ActionRegistry({\n fetch: fetchImpl,\n baseUrl,\n cache: options.cache,\n seed: options.seed ?? SEED_SNAPSHOT,\n });\n const http = new HttpClient(this.registry, fetchImpl, baseUrl, options.userAgent);\n this.auth = new AuthManager({\n refreshToken: options.refreshToken,\n http,\n fetch: fetchImpl,\n firebaseApiKey: options.firebaseApiKey,\n });\n this.generationService = new GenerationService(http, this.auth);\n this.historyService = new HistoryService(http, this.auth);\n this.characters = new CharactersService(http, this.auth);\n this.references = new ReferencesService(http, this.auth);\n }\n\n /** Submit a generation job; returns its `historyId`. */\n generate(options: GenerateOptions): Promise<{ historyId: string }> {\n return this.generationService.submit(options);\n }\n\n /** Submit a video generation job (Berry-2 family); returns its `historyId`. */\n generateVideo(options: GenerateVideoOptions): Promise<{ historyId: string }> {\n return this.generationService.submitVideo(options);\n }\n\n /** Fetch the current state of a generation by id. */\n getResult(historyId: string): Promise<HistoryItem> {\n return this.generationService.getHistory(historyId);\n }\n\n /** Poll until a generation finishes (or fails / times out). */\n waitForResult(historyId: string, options?: WaitOptions): Promise<HistoryItem> {\n return this.generationService.waitForResult(historyId, options);\n }\n\n /** Cancel a running generation job. */\n cancelJob(historyId: string): Promise<void> {\n return this.generationService.cancelJob(historyId);\n }\n\n /** List past generations for the authenticated user. */\n listHistory(options?: ListHistoryOptions): Promise<HistoryPage> {\n return this.historyService.list(options);\n }\n\n /** List the user's permanently saved creations. */\n listCreations(options?: ListCreationsOptions): Promise<CreationPage> {\n return this.historyService.listCreations(options);\n }\n\n /** Save a completed generation result as a permanent creation. */\n saveCreation(result: GenerationResult): Promise<void> {\n return this.historyService.saveCreation(result);\n }\n\n /** Permanently delete a history item. Irreversible — requires `{ confirm: true }`. */\n deleteHistory(historyId: string, options?: ConfirmOptions): Promise<void> {\n return this.historyService.deleteHistory(historyId, options);\n }\n\n /** Permanently delete many history items. Irreversible — requires `{ confirm: true }`. */\n deleteManyHistories(historyIds: string[], options?: ConfirmOptions): Promise<void> {\n return this.historyService.deleteManyHistories(historyIds, options);\n }\n\n /** Permanently delete a saved creation. Irreversible — requires `{ confirm: true }`. */\n deleteCreation(creationId: string, options?: ConfirmOptions): Promise<void> {\n return this.historyService.deleteCreation(creationId, options);\n }\n\n /** Permanently delete many creations. Irreversible — requires `{ confirm: true }`. */\n deleteManyCreations(creationIds: string[], options?: ConfirmOptions): Promise<void> {\n return this.historyService.deleteManyCreations(creationIds, options);\n }\n\n /** Force re-discovery of the Server Action hashes. */\n refreshActions(): Promise<ActionSnapshot> {\n return this.registry.refresh();\n }\n\n /** Return the authenticated user's Firebase uid. */\n getUid(): Promise<string> {\n return this.auth.getUserId();\n }\n}\n","/** Public entry point for `@zweer/mage-space-client`. */\nexport const VERSION = '0.0.0';\n\nexport { ActionRegistry, discoverActions, InMemoryActionCache } from './actions.js';\nexport { CharactersService } from './characters.js';\nexport { MageSpaceClient } from './client.js';\nexport {\n AuthError,\n DiscoveryError,\n GenerationError,\n MageSpaceError,\n RscParseError,\n StaleActionError,\n TimeoutError,\n} from './errors.js';\nexport { ReferencesService } from './references.js';\nexport {\n parseFlightRows,\n parseServerActionResponse,\n resolveFlightValue,\n unwrapResult,\n} from './rsc.js';\nexport { SEED_SNAPSHOT } from './seed.js';\nexport type * from './types.js';\n"],"mappings":";;;;AAGA,IAAa,iBAAb,cAAoC,MAAM;CACxC,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,YAAb,cAA+B,eAAe;CAC5C,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,iBAAb,cAAoC,eAAe;CACjD,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,mBAAb,cAAsC,eAAe;CAEjC;CADlB,YACE,QACA,SACA;EACA,MAAM,WAAW,OAAO,8BAA8B,OAAO;EAH7C,KAAA,SAAA;EAIhB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,kBAAb,cAAqC,eAAe;CAGhC;CAFlB,YACE,SACA,MACA,SACA;EACA,MAAM,SAAS,OAAO;EAHN,KAAA,OAAA;EAIhB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,gBAAb,cAAmC,eAAe;CAChD,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,eAAb,cAAkC,eAAe;CAC/C,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;;;;;AAOA,SAAgB,eAAe,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AAO,OAAO;CAC9C;;CAGA,cAAc,SAA+D;EAC3E,OAAO,KAAK,kBAAkB,YAAY,OAAO;CACnD;;CAGA,UAAU,WAAyC;EACjD,OAAO,KAAK,kBAAkB,WAAW,SAAS;CACpD;;CAGA,cAAc,WAAmB,SAA6C;EAC5E,OAAO,KAAK,kBAAkB,cAAc,WAAW,OAAO;CAChE;;CAGA,UAAU,WAAkC;EAC1C,OAAO,KAAK,kBAAkB,UAAU,SAAS;CACnD;;CAGA,YAAY,SAAoD;EAC9D,OAAO,KAAK,eAAe,KAAK,OAAO;CACzC;;CAGA,cAAc,SAAuD;EACnE,OAAO,KAAK,eAAe,cAAc,OAAO;CAClD;;CAGA,aAAa,QAAyC;EACpD,OAAO,KAAK,eAAe,aAAa,MAAM;CAChD;;CAGA,cAAc,WAAmB,SAAyC;EACxE,OAAO,KAAK,eAAe,cAAc,WAAW,OAAO;CAC7D;;CAGA,oBAAoB,YAAsB,SAAyC;EACjF,OAAO,KAAK,eAAe,oBAAoB,YAAY,OAAO;CACpE;;CAGA,eAAe,YAAoB,SAAyC;EAC1E,OAAO,KAAK,eAAe,eAAe,YAAY,OAAO;CAC/D;;CAGA,oBAAoB,aAAuB,SAAyC;EAClF,OAAO,KAAK,eAAe,oBAAoB,aAAa,OAAO;CACrE;;CAGA,iBAA0C;EACxC,OAAO,KAAK,SAAS,QAAQ;CAC/B;;CAGA,SAA0B;EACxB,OAAO,KAAK,KAAK,UAAU;CAC7B;AACF;;;;ACxIA,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zweer/mage-space-client",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "A TypeScript client for mage.space's internal API. Generate images programmatically.",
5
5
  "keywords": [
6
6
  "mage",