run402 4.87.0 → 4.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -249,7 +249,7 @@ import { db, adminDb, auth, email, ai } from "@run402/functions";
249
249
 
250
250
  ### Same-origin web routes
251
251
 
252
- `run402 deploy apply` accepts `site.public_paths` for clean static browser URLs and `routes.replace` for function ingress or exact method-aware static aliases. Release asset paths such as `events.html` are distinct from public paths such as `/events`: prefer `{ "site": { "replace": { "events.html": { "data": "<h1>Events</h1>" } }, "public_paths": { "mode": "explicit", "replace": { "/events": { "asset": "events.html" } } } } }` for ordinary clean static URLs. In explicit mode `/events.html` is not public unless separately declared; `mode: "implicit"` restores filename-derived reachability and can widen access. `routes.replace` is an array of route entries, not a path-keyed map. Use exact `/admin` plus final-wildcard `/admin/*` for a routed section root, narrow `/api/*` methods such as `["GET","POST","OPTIONS"]`, POST-only `/login` function routes, and exact static route targets like `{ "pattern": "/events", "methods": ["GET","HEAD"], "target": { "type": "static", "file": "events.html" } }` only for route-table alias behavior. Static route `file` is a release asset path, not a public path, URL, CAS hash, rewrite, or redirect. Recipe — static home page + SPA shell: a root alias `{ "pattern": "/", "target": { "type": "static", "file": "home.html" } }` (with `home.html` at the site root) serves real static bytes at `GET /` (`route_static_alias`) while unmatched app routes keep the `index.html` shell (`spa_fallback`); expect non-blocking `STATIC_ALIAS_SHADOWS_STATIC_PATH` (warn) / `STATIC_ALIAS_DUPLICATE_CANONICAL_URL` (info) plan lints and verify with `run402 deploy resolve --url https://<your-site>/ --method GET`. Routed functions use Node 22 Fetch Request -> Response; `req.url` is the full public URL on managed subdomains, deployment hosts, and verified custom domains. Direct `/functions/v1/:name` remains API-key protected. Known resolve literals include `host_missing`, `manifest_missing`, `active_release_missing`, `unsupported_manifest_version`, `path_error`, `none`, `static_exact`, `static_index`, `spa_fallback`, `spa_fallback_missing`, `route_function`, `route_static_alias`, and `route_method_miss`; known `authorization_result` values include `authorized`, `not_public`, `not_applicable`, `manifest_missing`, `target_missing`, `active_release_missing`, `unsupported_manifest_version`, `path_error`, `missing_cas_object`, `unfinalized_or_deleting_cas_object`, `size_mismatch`, and `unauthorized_cas_object`. Known `fallback_state` values include `active_release_missing`, `unsupported_manifest_version`, and `negative_cache_hit`; preserve unknown future strings. Release inventories may include `static_public_paths` with `public_path`, `asset_path`, `reachability_authority`, and `direct`; resolve may return the same reachability fields plus `authorization_result`, `cas_object`, `response_variant`, and route/static fields like `allow`, `route_pattern`, `target_type`, `target_name`, and `target_file`. Static route target warnings include `STATIC_ALIAS_SHADOWS_STATIC_PATH`, `STATIC_ALIAS_RELATIVE_ASSET_RISK`, `STATIC_ALIAS_DUPLICATE_CANONICAL_URL`, `STATIC_ALIAS_EXTENSIONLESS_NON_HTML`, and `STATIC_ALIAS_TABLE_NEAR_LIMIT`; inspect active routes, `static_public_paths`, and the backing `asset_path`. Runtime route failure codes to branch on: `ROUTE_MANIFEST_LOAD_FAILED`, `ROUTED_INVOKE_WORKER_SECRET_MISSING`, `ROUTED_INVOKE_AUTH_FAILED`, `ROUTED_ROUTE_STALE`, `ROUTE_METHOD_NOT_ALLOWED`, and `ROUTED_RESPONSE_TOO_LARGE`.
252
+ `run402 deploy apply` accepts `site.public_paths` for clean static browser URLs and `routes.replace` for function ingress or exact method-aware static aliases. Release asset paths such as `events.html` are distinct from public paths such as `/events`: prefer `{ "site": { "replace": { "events.html": { "data": "<h1>Events</h1>" } }, "public_paths": { "mode": "explicit", "replace": { "/events": { "asset": "events.html" } } } } }` for ordinary clean static URLs. In explicit mode `/events.html` is not public unless separately declared; `mode: "implicit"` restores filename-derived reachability and can widen access. `site.embedding.frame_ancestors` (catalog keys, e.g. `["localhost"]`, never raw origins) lets the named embedders put the site in an iframe: the gateway sends `Content-Security-Policy: frame-ancestors http://localhost:* http://127.0.0.1:*` and drops `X-Frame-Options` on every response of the host; omitted on a later apply carries the previous declaration forward, `null` returns to deny, unknown keys fail `INVALID_SPEC` naming the valid ones, and `/_run402/config.json` discloses the effective policy cross-origin so an embedder can check before framing. `routes.replace` is an array of route entries, not a path-keyed map. Use exact `/admin` plus final-wildcard `/admin/*` for a routed section root, narrow `/api/*` methods such as `["GET","POST","OPTIONS"]`, POST-only `/login` function routes, and exact static route targets like `{ "pattern": "/events", "methods": ["GET","HEAD"], "target": { "type": "static", "file": "events.html" } }` only for route-table alias behavior. Static route `file` is a release asset path, not a public path, URL, CAS hash, rewrite, or redirect. Recipe — static home page + SPA shell: a root alias `{ "pattern": "/", "target": { "type": "static", "file": "home.html" } }` (with `home.html` at the site root) serves real static bytes at `GET /` (`route_static_alias`) while unmatched app routes keep the `index.html` shell (`spa_fallback`); expect non-blocking `STATIC_ALIAS_SHADOWS_STATIC_PATH` (warn) / `STATIC_ALIAS_DUPLICATE_CANONICAL_URL` (info) plan lints and verify with `run402 deploy resolve --url https://<your-site>/ --method GET`. Routed functions use Node 22 Fetch Request -> Response; `req.url` is the full public URL on managed subdomains, deployment hosts, and verified custom domains. Direct `/functions/v1/:name` remains API-key protected. Known resolve literals include `host_missing`, `manifest_missing`, `active_release_missing`, `unsupported_manifest_version`, `path_error`, `none`, `static_exact`, `static_index`, `spa_fallback`, `spa_fallback_missing`, `route_function`, `route_static_alias`, and `route_method_miss`; known `authorization_result` values include `authorized`, `not_public`, `not_applicable`, `manifest_missing`, `target_missing`, `active_release_missing`, `unsupported_manifest_version`, `path_error`, `missing_cas_object`, `unfinalized_or_deleting_cas_object`, `size_mismatch`, and `unauthorized_cas_object`. Known `fallback_state` values include `active_release_missing`, `unsupported_manifest_version`, and `negative_cache_hit`; preserve unknown future strings. Release inventories may include `static_public_paths` with `public_path`, `asset_path`, `reachability_authority`, and `direct`; resolve may return the same reachability fields plus `authorization_result`, `cas_object`, `response_variant`, and route/static fields like `allow`, `route_pattern`, `target_type`, `target_name`, and `target_file`. Static route target warnings include `STATIC_ALIAS_SHADOWS_STATIC_PATH`, `STATIC_ALIAS_RELATIVE_ASSET_RISK`, `STATIC_ALIAS_DUPLICATE_CANONICAL_URL`, `STATIC_ALIAS_EXTENSIONLESS_NON_HTML`, and `STATIC_ALIAS_TABLE_NEAR_LIMIT`; inspect active routes, `static_public_paths`, and the backing `asset_path`. Runtime route failure codes to branch on: `ROUTE_MANIFEST_LOAD_FAILED`, `ROUTED_INVOKE_WORKER_SECRET_MISSING`, `ROUTED_INVOKE_AUTH_FAILED`, `ROUTED_ROUTE_STALE`, `ROUTE_METHOD_NOT_ALLOWED`, and `ROUTED_RESPONSE_TOO_LARGE`.
253
253
 
254
254
  ### Secrets
255
255
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "surface_version": "4.87.0",
2
+ "surface_version": "4.88.0",
3
3
  "verbs": [
4
4
  "repos create",
5
5
  "repos list",
package/lib/image.mjs CHANGED
@@ -2,6 +2,8 @@ import { writeFileSync } from "fs";
2
2
  import { getSdk } from "./sdk.mjs";
3
3
  import { reportSdkError, fail } from "./sdk-errors.mjs";
4
4
  import { assertAllowedValue, assertKnownFlags, flagValue, normalizeArgv, positionalArgs, failUnknownSubcommand } from "./argparse.mjs";
5
+ import { resolveOrg } from "./org-context.mjs";
6
+ import { nextAction } from "./next-actions.mjs";
5
7
 
6
8
  const HELP = `run402 image — Generate AI images via x402 micropayments
7
9
 
@@ -13,7 +15,9 @@ Options:
13
15
  --output <file> Save image to file (e.g. output.png)
14
16
  If omitted, returns base64 JSON to stdout
15
17
  --org <org_id> The paying organization when the wallet belongs to more
16
- than one (Lightning rail); x402 ignores it
18
+ than one (Lightning rail); x402 ignores it. Omitted, it
19
+ is the current org (RUN402_ORG, the .run402.json binding,
20
+ run402 org use, or the active project's owning org)
17
21
  --help, -h Show this help message
18
22
 
19
23
  Examples:
@@ -47,7 +51,9 @@ Options:
47
51
  --output <file> Save image to file (e.g. output.png). If omitted,
48
52
  returns base64 JSON to stdout.
49
53
  --org <org_id> The paying organization when the wallet belongs to more
50
- than one (Lightning rail); x402 ignores it
54
+ than one (Lightning rail); x402 ignores it. Omitted, it
55
+ is the current org (RUN402_ORG, the .run402.json binding,
56
+ run402 org use, or the active project's owning org)
51
57
 
52
58
  Notes:
53
59
  - Requires a funded allowance (run402 allowance create && run402 allowance fund)
@@ -104,8 +110,17 @@ export async function run(sub, args) {
104
110
  }
105
111
  assertAllowedValue(opts.aspect, ["square", "landscape", "portrait"], "--aspect");
106
112
 
113
+ // The paying organization rides the ONE shared org chain (--org, then
114
+ // RUN402_ORG / RUN402_ROOM / RUN402_PROJECT_ID, then the .run402.json
115
+ // binding, then `org use` / the active project's owning org). Only the
116
+ // Lightning rail reads it — a multi-org principal is refused
117
+ // ORGANIZATION_SELECTION_REQUIRED without one — and x402 ignores it, so
118
+ // resolving it is never a reason to refuse an x402 purchase: `optional`
119
+ // answers null rather than ORG_REQUIRED when the chain is empty.
120
+ const org = await resolveOrg({ org: opts.org }, { cmd: "image", optional: true });
121
+
107
122
  try {
108
- const data = await getSdk().ai.generateImage({ prompt: opts.prompt, aspect: opts.aspect, ...(opts.org ? { orgId: opts.org } : {}) });
123
+ const data = await getSdk().ai.generateImage({ prompt: opts.prompt, aspect: opts.aspect, ...(org ? { orgId: org.orgId } : {}) });
109
124
  if (opts.output) {
110
125
  const buf = Buffer.from(data.image, "base64");
111
126
  writeFileSync(opts.output, buf);
@@ -114,6 +129,45 @@ export async function run(sub, args) {
114
129
  console.log(JSON.stringify({ aspect: data.aspect, content_type: data.content_type, image: data.image }));
115
130
  }
116
131
  } catch (err) {
132
+ reportOrgSelectionError(err, org);
117
133
  reportSdkError(err);
118
134
  }
119
135
  }
136
+
137
+ /**
138
+ * The Lightning rail's two org refusals, explained in the CLI's own words:
139
+ * `ORGANIZATION_SELECTION_REQUIRED` (no org named, and the SDK found no
140
+ * single local match among the gateway's candidates) and the 403 the
141
+ * gateway answers when the resolved org is one the principal cannot bill.
142
+ * Both name where the org came from and how to name another one.
143
+ */
144
+ function reportOrgSelectionError(err, org) {
145
+ const code = err?.code;
146
+ const details = err?.details && typeof err.details === "object" ? err.details : {};
147
+ if (code === "ORGANIZATION_SELECTION_REQUIRED") {
148
+ const ids = Array.isArray(details.organization_ids) ? details.organization_ids : [];
149
+ fail({
150
+ code,
151
+ message: err.message,
152
+ hint:
153
+ `Pass --org <org_id> (one of: ${ids.join(", ") || "run402 org list"}) or select a current organization with ` +
154
+ "run402 org use <org_id>. Only the Lightning rail needs it; x402 ignores it.",
155
+ details: { ...details, organization_ids: ids, org_source: org?.source ?? null, org_source_detail: org?.sourceDetail ?? null },
156
+ next_actions: err.nextActions ?? [
157
+ nextAction("edit_request", { command: 'run402 image generate "<prompt>" --org <org_id>', why: "Name the paying organization on this call." }),
158
+ nextAction("edit_request", { command: "run402 org use <org_id>", why: "Select a current organization for this profile." }),
159
+ ],
160
+ });
161
+ }
162
+ if (err?.status === 403 && org && details.org_id === org.orgId && org.source !== "flag") {
163
+ fail({
164
+ code: code ?? "FORBIDDEN",
165
+ message: err.message,
166
+ hint:
167
+ `The paying organization ${org.orgId} came from ${org.sourceDetail} (${org.source}) and this principal holds no billing role there. ` +
168
+ "Pass --org <org_id> for an organization you can bill, or run: run402 org use <org_id>",
169
+ details: { ...details, org_source: org.source, org_source_detail: org.sourceDetail },
170
+ next_actions: err.nextActions,
171
+ });
172
+ }
173
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "run402",
3
- "version": "4.87.0",
3
+ "version": "4.88.0",
4
4
  "description": "CLI for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -125,6 +125,14 @@ export interface CredentialsProvider {
125
125
  setActiveProject?(id: string): Promise<void>;
126
126
  /** Get the active/default project id from local state. Optional. */
127
127
  getActiveProject?(): Promise<string | null>;
128
+ /**
129
+ * Get the active/current organization id from local state (the CLI's
130
+ * `run402 org use`). Optional. Read by the SDK only to disambiguate a
131
+ * gateway `ORGANIZATION_SELECTION_REQUIRED` answer (the MPP Lightning
132
+ * rail's paying organization when the principal belongs to several); it
133
+ * is never sent unprompted and never an authorization input.
134
+ */
135
+ getActiveOrg?(): Promise<string | null>;
128
136
  /** Read the local allowance (wallet). Optional — sandbox providers may omit. */
129
137
  readAllowance?(): Promise<AllowanceData | null>;
130
138
  /** Persist the local allowance. Optional. */
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,WAAW,CAAC;IACpC,4HAA4H;IAC5H,SAAS,CAAC,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,EAAE,MAAM,CAAC;QACZ,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,WAAW,EAAE,M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AAM,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvE,oEAAoE;IACpE,aAAa,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C,kEAAkE;IAClE,gBAAgB,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7C,oEAAoE;IACpE,gBAAgB,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE5C;;;;;;OAMG;IACH,YAAY,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAExC,gFAAgF;IAChF,aAAa,CAAC,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAEhD,6CAA6C;IAC7C,aAAa,CAAC,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD,oHAAoH;IACpH,eAAe,CAAC,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAE3C,6FAA6F;IAC7F,gBAAgB,CAAC,IAAI,MAAM,CAAC;IAE5B,+EAA+E;IAC/E,6BAA6B,CAAC,IAAI,0BAA0B,CAAC;IAE7D;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CACtD"}
@@ -34,11 +34,23 @@ export interface GenerateImageOptions {
34
34
  aspect?: ImageAspect;
35
35
  /**
36
36
  * The paying organization. Needed only on the MPP Lightning rail when the
37
- * calling principal belongs to more than one organization (the gateway
38
- * answers `ORGANIZATION_SELECTION_REQUIRED` otherwise); x402 ignores it.
37
+ * calling principal belongs to more than one organization; x402 ignores it.
38
+ *
39
+ * When omitted and the gateway answers `ORGANIZATION_SELECTION_REQUIRED`,
40
+ * the SDK retries ONCE with the one candidate from
41
+ * `details.organization_ids` that matches a local context — the
42
+ * provider's active organization (`run402 org use`) or the active
43
+ * project's cached owning org, else any locally stored project's owning
44
+ * org. Zero or several matches surface the error with the candidate ids
45
+ * and a next action naming `--org` / `orgId`. Nothing is ever inferred
46
+ * from membership count alone.
39
47
  */
40
48
  orgId?: string;
41
49
  }
50
+ /** The gateway's answer when a multi-org principal names no paying org on the Lightning rail. */
51
+ export declare const ORGANIZATION_SELECTION_REQUIRED = "ORGANIZATION_SELECTION_REQUIRED";
52
+ /** `details.organization_ids` off an `ORGANIZATION_SELECTION_REQUIRED` error, else `[]`. */
53
+ export declare function organizationCandidatesFromError(err: unknown): string[];
42
54
  export interface GenerateImageResult {
43
55
  /** Base64-encoded bytes. */
44
56
  image: string;
@@ -65,8 +77,10 @@ export declare class Ai {
65
77
  /** Get AI translation usage for the current billing cycle. */
66
78
  usage(projectId: string): Promise<AiUsageResult>;
67
79
  /**
68
- * Generate an image from a text prompt. Costs $0.03 USDC via x402.
69
- * No project scope — payment flows through the allowance-based fetch.
80
+ * Generate an image from a text prompt. Costs $0.03 via x402, MPP on
81
+ * Tempo, or MPP Lightning. No project scope — payment flows through the
82
+ * allowance-based fetch. See {@link GenerateImageOptions.orgId} for how a
83
+ * multi-org principal's paying organization is chosen on Lightning.
70
84
  */
71
85
  generateImage(opts: GenerateImageOptions): Promise<GenerateImageResult>;
72
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/namespaces/ai.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAI9D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,C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+B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAOtE;AAED,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;;OAQG;IACH,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACnC;AAED,qBAAa,EAAE;IACD,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C,yEAAyE;IACnE,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAepF,mFAAmF;IAC7E,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAWxE,8DAA8D;IACxD,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAStD;;;;;OAKG;IACG,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAoB9E"}
@@ -2,9 +2,21 @@
2
2
  * `ai` namespace — project-scoped AI add-ons (translation, moderation) and
3
3
  * wallet-scoped image generation.
4
4
  */
5
- import { LocalError } from "../errors.js";
5
+ import { ApiError, LocalError, isRun402Error } from "../errors.js";
6
6
  import { requireProjectCredentials } from "../project-credentials.js";
7
7
  const IMAGE_ASPECTS = ["square", "landscape", "portrait"];
8
+ /** The gateway's answer when a multi-org principal names no paying org on the Lightning rail. */
9
+ export const ORGANIZATION_SELECTION_REQUIRED = "ORGANIZATION_SELECTION_REQUIRED";
10
+ /** `details.organization_ids` off an `ORGANIZATION_SELECTION_REQUIRED` error, else `[]`. */
11
+ export function organizationCandidatesFromError(err) {
12
+ if (!isRun402Error(err) || err.code !== ORGANIZATION_SELECTION_REQUIRED)
13
+ return [];
14
+ const details = err.details;
15
+ const ids = details && typeof details === "object" && !Array.isArray(details)
16
+ ? details.organization_ids
17
+ : undefined;
18
+ return Array.isArray(ids) ? ids.filter((id) => typeof id === "string" && id.length > 0) : [];
19
+ }
8
20
  export class Ai {
9
21
  client;
10
22
  constructor(client) {
@@ -44,20 +56,128 @@ export class Ai {
44
56
  });
45
57
  }
46
58
  /**
47
- * Generate an image from a text prompt. Costs $0.03 USDC via x402.
48
- * No project scope — payment flows through the allowance-based fetch.
59
+ * Generate an image from a text prompt. Costs $0.03 via x402, MPP on
60
+ * Tempo, or MPP Lightning. No project scope — payment flows through the
61
+ * allowance-based fetch. See {@link GenerateImageOptions.orgId} for how a
62
+ * multi-org principal's paying organization is chosen on Lightning.
49
63
  */
50
64
  async generateImage(opts) {
51
65
  const aspect = opts.aspect ?? "square";
52
66
  if (!IMAGE_ASPECTS.includes(aspect)) {
53
67
  throw new LocalError(`aspect must be one of: ${IMAGE_ASPECTS.join(", ")}`, "generating image");
54
68
  }
55
- // requestWithResponse, not request: the settlement receipt rides the
56
- // RESPONSE, and `request` discards everything but the body — which is
57
- // exactly how a caller could buy an image with no way to learn which
58
- // network the money moved on.
59
- const res = await this.client.requestWithResponse("/generate-image/v1", { method: "POST", body: { prompt: opts.prompt, aspect, ...(opts.orgId ? { org_id: opts.orgId } : {}) }, context: "generating image" });
60
- return { ...res.body, payment: res.settlement ?? null };
69
+ try {
70
+ return await postGenerateImage(this.client, opts.prompt, aspect, opts.orgId);
71
+ }
72
+ catch (err) {
73
+ // Only an UNNAMED org is disambiguated: a caller-named org that the
74
+ // gateway still refuses is the caller's answer to keep.
75
+ const candidates = opts.orgId ? [] : organizationCandidatesFromError(err);
76
+ if (candidates.length === 0)
77
+ throw err;
78
+ const matched = await matchKnownOrganization(this.client, candidates);
79
+ if (matched.chosen)
80
+ return postGenerateImage(this.client, opts.prompt, aspect, matched.chosen);
81
+ throw organizationSelectionError(err, candidates, matched.matches);
82
+ }
83
+ }
84
+ }
85
+ // Module-level, not class-private: `ScopedRun402`'s drift test enumerates
86
+ // every runtime method on a namespace, and a TypeScript `private` is public
87
+ // at runtime.
88
+ async function postGenerateImage(client, prompt, aspect, orgId) {
89
+ // requestWithResponse, not request: the settlement receipt rides the
90
+ // RESPONSE, and `request` discards everything but the body — which is
91
+ // exactly how a caller could buy an image with no way to learn which
92
+ // network the money moved on.
93
+ const res = await client.requestWithResponse("/generate-image/v1", { method: "POST", body: { prompt, aspect, ...(orgId ? { org_id: orgId } : {}) }, context: "generating image" });
94
+ return { ...res.body, payment: res.settlement ?? null };
95
+ }
96
+ /**
97
+ * Intersect the gateway's candidates with what this machine already knows,
98
+ * most deliberate context first: the SELECTED pair (active org, active
99
+ * project's cached owning org) decides when exactly one candidate matches
100
+ * it; only when it names nothing do the STORED projects' owning orgs get a
101
+ * say, again only when exactly one candidate matches. Every read is local
102
+ * and best-effort — a provider without the optional methods, or a read that
103
+ * throws, contributes nothing rather than failing the purchase.
104
+ */
105
+ async function matchKnownOrganization(client, candidates) {
106
+ const creds = client.credentials;
107
+ const selected = new Set();
108
+ const activeOrg = await optionalRead(() => creds.getActiveOrg?.call(creds));
109
+ if (activeOrg)
110
+ selected.add(activeOrg);
111
+ const activeProject = await optionalRead(() => creds.getActiveProject?.call(creds));
112
+ if (activeProject) {
113
+ const owning = orgIdOf(await optionalRead(() => client.getProjectCredentials(activeProject)));
114
+ if (owning)
115
+ selected.add(owning);
61
116
  }
117
+ const stored = new Set();
118
+ const listed = await optionalRead(() => creds.listProjectCredentials?.call(creds));
119
+ for (const entry of Object.values(listed ?? {})) {
120
+ const owning = orgIdOf(entry);
121
+ if (owning)
122
+ stored.add(owning);
123
+ }
124
+ const inSelected = candidates.filter((id) => selected.has(id));
125
+ if (inSelected.length === 1)
126
+ return { chosen: inSelected[0], matches: inSelected };
127
+ if (inSelected.length > 1)
128
+ return { chosen: null, matches: inSelected };
129
+ const inStored = candidates.filter((id) => stored.has(id));
130
+ return { chosen: inStored.length === 1 ? inStored[0] : null, matches: inStored };
131
+ }
132
+ async function optionalRead(read) {
133
+ try {
134
+ const value = await read();
135
+ return value === undefined ? null : value;
136
+ }
137
+ catch {
138
+ return null;
139
+ }
140
+ }
141
+ function orgIdOf(entry) {
142
+ const orgId = entry && typeof entry === "object" ? entry.org_id : undefined;
143
+ return typeof orgId === "string" && orgId.length > 0 ? orgId : null;
144
+ }
145
+ /**
146
+ * The gateway's `ORGANIZATION_SELECTION_REQUIRED` answer, re-thrown with the
147
+ * candidates named in the message and a next action that says how to name
148
+ * the paying organization. Status, code, and the raw envelope are kept.
149
+ */
150
+ function organizationSelectionError(err, candidates, matches) {
151
+ const envelope = err.body && typeof err.body === "object" && !Array.isArray(err.body)
152
+ ? err.body
153
+ : {};
154
+ const details = envelope.details && typeof envelope.details === "object" && !Array.isArray(envelope.details)
155
+ ? envelope.details
156
+ : {};
157
+ const reason = matches.length > 1
158
+ ? `${matches.length} of them (${matches.join(", ")}) match this machine's local context, so none was chosen`
159
+ : "none of them matches this machine's local context (run402 org use, the active project, or a stored project)";
160
+ const message = `The paying organization is required: this principal belongs to ${candidates.length} organizations ` +
161
+ `(${candidates.join(", ")}) and ${reason}; name one with orgId (CLI: --org <org_id>) while generating image (HTTP ${err.status ?? 400})`;
162
+ const nextActions = [
163
+ {
164
+ type: "edit_request",
165
+ command: "run402 image generate \"<prompt>\" --org <org_id>",
166
+ why: "Name the paying organization on this call (SDK: generateImage({ orgId })). Candidates are in details.organization_ids.",
167
+ },
168
+ {
169
+ type: "edit_request",
170
+ command: "run402 org use <org_id>",
171
+ why: "Select a current organization for this profile so every later call inherits it.",
172
+ },
173
+ ...(Array.isArray(envelope.next_actions) ? envelope.next_actions : []),
174
+ ];
175
+ return new ApiError(message, err.status, {
176
+ ...envelope,
177
+ message,
178
+ code: ORGANIZATION_SELECTION_REQUIRED,
179
+ details: { ...details, organization_ids: candidates, matched_organization_ids: matches },
180
+ next_actions: nextActions,
181
+ }, "generating image");
62
182
  }
63
183
  //# sourceMappingURL=ai.js.map
@@ -1 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OAAO,CAAC,oBAAoB,CAAC;IAmBhC;;;;OAIG;IACG,aAAa,CACjB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,mBAAmB,CAAC;IAyB/B;;;;OAIG;IACG,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,uBAAuB,CAAC;IAoCnC;;;;OAIG;IACG,UAAU,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2B9E;;;;OAIG;IACG,gBAAgB,CACpB,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;IAqBlC;;;;OAIG;IACG,IAAI,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA+BnE;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAW1E;AAmkED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;iEAG6D;IAC7D,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;CACvC"}
@@ -1068,13 +1068,19 @@ function siteToCoreSpec(site) {
1068
1068
  ...(site.public_paths ? { public_paths: site.public_paths } : {}),
1069
1069
  };
1070
1070
  }
1071
- return { public_paths: site.public_paths };
1071
+ // tenant-site-embedding never reaches core: the catalog is gateway-owned and
1072
+ // core validates site keys against its own list.
1073
+ return site.public_paths ? { public_paths: site.public_paths } : {};
1072
1074
  }
1073
1075
  function siteToWire(site) {
1076
+ // tenant-site-embedding: `null` is a meaningful value on the wire (clear), so
1077
+ // it is carried whenever the key is present, unlike public_paths.
1078
+ const embedding = "embedding" in site && site.embedding !== undefined ? { embedding: site.embedding } : {};
1074
1079
  if ("replace" in site && site.replace) {
1075
1080
  return {
1076
1081
  replace: fileSetToWire(site.replace),
1077
1082
  ...(site.public_paths ? { public_paths: site.public_paths } : {}),
1083
+ ...embedding,
1078
1084
  };
1079
1085
  }
1080
1086
  if ("patch" in site && site.patch) {
@@ -1084,9 +1090,13 @@ function siteToWire(site) {
1084
1090
  ...(site.patch.delete ? { delete: site.patch.delete } : {}),
1085
1091
  },
1086
1092
  ...(site.public_paths ? { public_paths: site.public_paths } : {}),
1093
+ ...embedding,
1087
1094
  };
1088
1095
  }
1089
- return { public_paths: site.public_paths };
1096
+ return {
1097
+ ...(site.public_paths ? { public_paths: site.public_paths } : {}),
1098
+ ...embedding,
1099
+ };
1090
1100
  }
1091
1101
  function i18nToWire(i18n) {
1092
1102
  return {
@@ -2231,7 +2241,7 @@ const FUNCTION_SPEC_FIELDS = new Set([
2231
2241
  const FUNCTION_CONFIG_FIELDS = new Set(["timeoutSeconds", "memoryMb"]);
2232
2242
  const FUNCTION_TRIGGER_FIELDS = new Set(["id", "type", "cron", "timezone", "misfire_policy", "overlap_policy", "mailbox", "events", "run"]);
2233
2243
  const FUNCTION_TRIGGER_RUN_FIELDS = new Set(["event_type", "payload", "retry", "expires_after_seconds"]);
2234
- const SITE_SPEC_FIELDS = new Set(["replace", "patch", "public_paths"]);
2244
+ const SITE_SPEC_FIELDS = new Set(["replace", "patch", "public_paths", "embedding"]);
2235
2245
  const SITE_PATCH_FIELDS = new Set(["put", "delete"]);
2236
2246
  const SITE_PUBLIC_PATHS_FIELDS = new Set(["mode", "replace"]);
2237
2247
  const PUBLIC_STATIC_PATH_FIELDS = new Set(["asset", "cache_class"]);
@@ -2565,6 +2575,22 @@ function validateSiteSpec(site) {
2565
2575
  if (obj.public_paths !== undefined) {
2566
2576
  validateSitePublicPathsSpec(obj.public_paths, "site.public_paths");
2567
2577
  }
2578
+ if (obj.embedding !== undefined) {
2579
+ validateSiteEmbeddingSpec(obj.embedding, "site.embedding");
2580
+ }
2581
+ }
2582
+ /** tenant-site-embedding. Structural check only: the catalog is the gateway's
2583
+ * (it names the valid keys in INVALID_SPEC), so a new key never needs an SDK
2584
+ * release. `null` clears; omitted carries forward. */
2585
+ function validateSiteEmbeddingSpec(value, resource) {
2586
+ if (value === null)
2587
+ return;
2588
+ const obj = requireObject(value, resource);
2589
+ validateKnownFields(obj, resource, new Set(["frame_ancestors"]));
2590
+ if (!Array.isArray(obj.frame_ancestors) || obj.frame_ancestors.length === 0) {
2591
+ throw invalidSpec(`ReleaseSpec.${resource}.frame_ancestors must be a non-empty array of embedding catalog keys (e.g. ["localhost"]); omit ${resource} to carry the previous declaration forward or send null to deny`, `${resource}.frame_ancestors`);
2592
+ }
2593
+ validateStringArray(obj.frame_ancestors, `${resource}.frame_ancestors`);
2568
2594
  }
2569
2595
  function validateSitePublicPathsSpec(value, resource) {
2570
2596
  const obj = requireObject(value, resource);
@@ -2917,6 +2943,11 @@ function hasDatabaseContent(database) {
2917
2943
  return hasArrayEntries(database.migrations) || hasRecordEntries(database.expose);
2918
2944
  }
2919
2945
  function hasSiteContent(site) {
2946
+ // tenant-site-embedding: a declaration (or an explicit null that clears one)
2947
+ // is deploy content on its own, like a public_paths-only site.
2948
+ if (site && typeof site === "object" && "embedding" in site && site.embedding !== undefined) {
2949
+ return true;
2950
+ }
2920
2951
  if (!isRecord(site))
2921
2952
  return false;
2922
2953
  if (hasRecordEntries(site.replace))
@@ -3366,6 +3397,10 @@ async function normalizeReleaseSpec(client, spec, opts = {}) {
3366
3397
  }
3367
3398
  if (spec.site) {
3368
3399
  const publicPaths = "public_paths" in spec.site ? spec.site.public_paths : undefined;
3400
+ // tenant-site-embedding: present (object or null) travels as-is.
3401
+ const embedding = "embedding" in spec.site && spec.site.embedding !== undefined
3402
+ ? { embedding: spec.site.embedding }
3403
+ : {};
3369
3404
  if ("replace" in spec.site && spec.site.replace) {
3370
3405
  const map = await normalizeFileSet(spec.site.replace, rememberRelease);
3371
3406
  // Re-check post-expansion so `dir("dist")` (a LocalDirRef whose keys are
@@ -3374,6 +3409,7 @@ async function normalizeReleaseSpec(client, spec, opts = {}) {
3374
3409
  normalized.site = {
3375
3410
  replace: map,
3376
3411
  ...(publicPaths ? { public_paths: publicPaths } : {}),
3412
+ ...embedding,
3377
3413
  };
3378
3414
  }
3379
3415
  else if ("patch" in spec.site && spec.site.patch) {
@@ -3387,10 +3423,14 @@ async function normalizeReleaseSpec(client, spec, opts = {}) {
3387
3423
  normalized.site = {
3388
3424
  patch,
3389
3425
  ...(publicPaths ? { public_paths: publicPaths } : {}),
3426
+ ...embedding,
3390
3427
  };
3391
3428
  }
3392
- else if (publicPaths) {
3393
- normalized.site = { public_paths: publicPaths };
3429
+ else if (publicPaths || "embedding" in embedding) {
3430
+ normalized.site = {
3431
+ ...(publicPaths ? { public_paths: publicPaths } : {}),
3432
+ ...embedding,
3433
+ };
3394
3434
  }
3395
3435
  }
3396
3436
  // v1.48 unified-apply: asset slice normalization. Mirrors the site