@lunora/codegen 1.0.0-alpha.241 → 1.0.0-alpha.242

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.
Files changed (24) hide show
  1. package/dist/index.d.mts +85 -49
  2. package/dist/index.d.ts +85 -49
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/AGENTS_FILENAME-Bb2jxbOa.mjs +1 -0
  5. package/dist/packem_shared/CONTAINERS_FILENAME-CGB4bqUr.mjs +1 -0
  6. package/dist/packem_shared/DEFAULT_TARGET-B1zgC6k6.mjs +1 -0
  7. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BHDnOBKJ.mjs +9 -0
  8. package/dist/packem_shared/WORKFLOWS_FILENAME-DNaUHGS8.mjs +1 -0
  9. package/dist/packem_shared/{discoverCrons-MfKw7IFf.mjs → discoverCrons-0lNudk0S.mjs} +1 -1
  10. package/dist/packem_shared/{emitAgents-CoNw0AKK.mjs → emitAgents-Ddcr_r3B.mjs} +1 -1
  11. package/dist/packem_shared/{emitApi-CJ9ziZnP.mjs → emitApi-DdW9RyGG.mjs} +22 -22
  12. package/dist/packem_shared/{emitApp-CgXCWBms.mjs → emitApp--W9G6MZd.mjs} +1 -1
  13. package/dist/packem_shared/{emitCrons-BP2xBXDJ.mjs → emitCrons-Bop1FTEz.mjs} +10 -10
  14. package/dist/packem_shared/{emitFunctions-BqAz1ssY.mjs → emitFunctions-BgNeOZt_.mjs} +1 -1
  15. package/dist/packem_shared/{emitServer-BEo_fCY8.mjs → emitServer-B8t7Hzb1.mjs} +38 -40
  16. package/dist/packem_shared/{emitShard-DFgzghbs.mjs → emitShard-RnNua5aR.mjs} +1 -1
  17. package/dist/packem_shared/{shard-BaHiawkc.mjs → shard-CCNl561P.mjs} +1 -1
  18. package/dist/packem_shared/{shard-runtime-B5SUfdZB.mjs → shard-runtime-B7xvdFPc.mjs} +29 -29
  19. package/package.json +10 -10
  20. package/dist/packem_shared/AGENTS_FILENAME-DoPI92Wu.mjs +0 -1
  21. package/dist/packem_shared/CONTAINERS_FILENAME-B6TFs82W.mjs +0 -1
  22. package/dist/packem_shared/DEFAULT_TARGET-DCpDuuUM.mjs +0 -1
  23. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-CtkD-vQu.mjs +0 -9
  24. package/dist/packem_shared/WORKFLOWS_FILENAME-B_ZJxRSx.mjs +0 -1
@@ -1,19 +1,17 @@
1
- import{LunoraError as Ie}from"@lunora/errors";import{S as $e}from"./capabilities-DJJWVEtk.mjs";import{a as c,G as Re,u as Be,d as Oe}from"./shared-DjUziztz.mjs";const De=(l,s=[])=>{const t=new Set;for(const a of l.tables)for(const n of Object.values(a.shape)){const i=Be(n);i.kind==="storage"&&typeof i.bucket=="string"&&i.bucket!==""&&t.add(i.bucket)}for(const a of s)a!==""&&a!=="default"&&t.add(a);return["default",...[...t].toSorted((a,n)=>a.localeCompare(n))]},Fe=({agents:l=[],containers:s=[],env:t,hasAccessFacade:a=!1,hasAi:n=!1,hasAnalytics:i=!1,hasBrowser:E=!1,hasVectors:P=!0,hasFlags:j=!1,hasHyperdrive:q=!1,hasImages:L=!1,hasKv:V=!1,hasNotify:G=!1,hasPayments:O=!1,hasPipelines:_=!1,hasR2sql:H=!1,hasX402:D=!1,identity:d,queues:m=[],schema:M,storageRuleBuckets:z=[],useUmbrella:U=!1,workflows:b=[]}={})=>{const r=Oe(U),K=De(M??{tables:[]},z).map(e=>JSON.stringify(e)).join(" | "),X=n?`import type { LunoraAi } from "@lunora/ai";
2
- `:"",J=n?`
3
- readonly ai: LunoraAi;`:"",Y=O?`import type { LunoraPayment } from "@lunora/payment";
4
- `:"",Z=O?`
5
- readonly payments: LunoraPayment;`:"",ee=D?`import type { X402Pay } from "@lunora/x402/pay";
6
- `:"",te=D?`
1
+ import{LunoraError as Ie}from"@lunora/errors";import{S as $e}from"./capabilities-DJJWVEtk.mjs";import{a as R,G as Re,u as Be,d as Oe}from"./shared-DjUziztz.mjs";const De=(l,s=[])=>{const t=new Set;for(const a of l.tables)for(const o of Object.values(a.shape)){const i=Be(o);i.kind==="storage"&&typeof i.bucket=="string"&&i.bucket!==""&&t.add(i.bucket)}for(const a of s)a!==""&&a!=="default"&&t.add(a);return["default",...[...t].toSorted((a,o)=>a.localeCompare(o))]},Fe=({agents:l=[],containers:s=[],env:t,hasAccessFacade:a=!1,hasAi:o=!1,hasAnalytics:i=!1,hasBrowser:E=!1,hasVectors:P=!0,hasFlags:j=!1,hasHyperdrive:q=!1,hasImages:L=!1,hasKv:V=!1,hasNotify:G=!1,hasPayments:B=!1,hasPipelines:_=!1,hasR2sql:H=!1,hasX402:O=!1,identity:d,queues:y=[],schema:D,storageRuleBuckets:z=[],useUmbrella:U=!1,workflows:M=[]}={})=>{const r=Oe(U),K=De(D??{tables:[]},z).map(e=>JSON.stringify(e)).join(" | "),X=o?`import type { LunoraAi } from "@lunora/ai";
2
+ `:"",J=o?`
3
+ readonly ai: LunoraAi;`:"",Y=B?`import type { LunoraPayment } from "@lunora/payment";
4
+ `:"",Z=B?`
5
+ readonly payments: LunoraPayment;`:"",ee=O?`import type { X402Pay } from "@lunora/x402/pay";
6
+ `:"",te=O?`
7
7
  readonly x402: X402Pay;`:"",ae=s.length>0?`import type { ContainerAccessor } from "@lunora/container";
8
8
  `:"",re=s.length>0?`
9
9
  readonly containers: {${s.map(e=>`
10
10
  readonly ${e.exportName}: ContainerAccessor;`).join("")}
11
- };`:"",N=[...n?[" /** Workers AI binding (the conventional `env.AI`), narrowing `ctx.ai`. */\n readonly AI?: unknown;"]:[],...s.map(e=>(c(e.bindingName,`container binding "${e.bindingName}"`),` /** Durable Object namespace for the \`${e.exportName}\` container. */
12
- readonly ${e.bindingName}?: unknown;`)),...b.map(e=>(c(e.bindingName,`workflow binding "${e.bindingName}"`),` /** Workflow binding for the \`${e.exportName}\` workflow. */
13
- readonly ${e.bindingName}?: unknown;`)),...m.map(e=>(c(e.bindingName,`queue binding "${e.bindingName}"`),` /** Queue producer binding for the \`${e.exportName}\` queue. */
14
- readonly ${e.bindingName}?: unknown;`)),...l.map(e=>(c(e.bindingName,`agent binding "${e.bindingName}"`),` /** Workflow binding for the \`${e.exportName}\` agent. */
11
+ };`:"",A=[...o?[" /** Workers AI binding (the conventional `env.AI`), narrowing `ctx.ai`. */\n readonly AI?: unknown;"]:[],...s.map(e=>(R(e.bindingName,`container binding "${e.bindingName}"`),` /** Durable Object namespace for the \`${e.exportName}\` container. */
12
+ readonly ${e.bindingName}?: unknown;`)),...y.map(e=>(R(e.bindingName,`queue binding "${e.bindingName}"`),` /** Queue producer binding for the \`${e.exportName}\` queue. */
15
13
  readonly ${e.bindingName}?: unknown;`))].join(`
16
- `),ne=`
14
+ `),oe=`
17
15
 
18
16
  /**
19
17
  * This project's Cloudflare bindings, as far as codegen can discover them from
@@ -26,26 +24,26 @@ import{LunoraError as Ie}from"@lunora/errors";import{S as $e}from"./capabilities
26
24
  * surface, so treat them as \`Fetcher\`/\`Service<unknown>\` and cast.
27
25
  */
28
26
  export interface CloudflareBindings {
29
- readonly [binding: string]: unknown;${N?`
30
- ${N}`:""}
27
+ readonly [binding: string]: unknown;${A?`
28
+ ${A}`:""}
31
29
  }
32
30
 
33
31
  /** Alias for {@link CloudflareBindings} — the typed shape of \`env\`. */
34
- export type Env = CloudflareBindings;`,o=(e,we,Q)=>{const y=$e.get(e);if(y!==void 0&&y.tier!==Q)throw new Ie("INTERNAL",`@lunora/codegen: capability "${e}" declares tier "${y.tier}" in SERVER_CTX_FIELDS but is emitted onto the "${Q}" context — update whichever is wrong.`);return we?y?.field??"":""},h=o("kv",V,"every"),f=o("analytics",i,"every"),oe=o("hyperdrive",q,"action"),se=o("browser",E,"action"),ie=o("images",L,"action"),de=o("pipelines",_,"action"),le=o("r2sql",H,"action"),u=P&&(M?.vectorIndexes.length??0)>0,x=u?' | "vectors"':"",A=u?`
35
- readonly vectors: VectorSearch<VectorIndexName>;`:"",ce=u?`
36
- readonly vectors: VectorSearchReader<VectorIndexName>;`:"",ue=u?`import type { VectorSearch, VectorSearchReader } from "${r.server}";
32
+ export type Env = CloudflareBindings;`,n=(e,we,Q)=>{const p=$e.get(e);if(p!==void 0&&p.tier!==Q)throw new Ie("INTERNAL",`@lunora/codegen: capability "${e}" declares tier "${p.tier}" in SERVER_CTX_FIELDS but is emitted onto the "${Q}" context — update whichever is wrong.`);return we?p?.field??"":""},m=n("kv",V,"every"),b=n("analytics",i,"every"),ne=n("hyperdrive",q,"action"),se=n("browser",E,"action"),ie=n("images",L,"action"),de=n("pipelines",_,"action"),le=n("r2sql",H,"action"),c=P&&(D?.vectorIndexes.length??0)>0,h=c?' | "vectors"':"",C=c?`
33
+ readonly vectors: VectorSearch<VectorIndexName>;`:"",ce=c?`
34
+ readonly vectors: VectorSearchReader<VectorIndexName>;`:"",ue=c?`import type { VectorSearch, VectorSearchReader } from "${r.server}";
37
35
  import type { VectorIndexName } from "./dataModel.js";
38
- `:"",g=a?`
36
+ `:"",f=a?`
39
37
  /** Verified Cloudflare Access identity — a synchronous facade over the resolved claims (email / groups / hasGroup / claims). Anonymous when no Access token is present. */
40
- readonly access: import("@lunora/cloudflare-access/context").AccessFacade;`:"",T=j?`
38
+ readonly access: import("@lunora/cloudflare-access/context").AccessFacade;`:"",x=j?`
41
39
  /** Feature-flag evaluation (OpenFeature). Reads are memoized per request; evaluations never throw — a provider error resolves to the supplied default. */
42
- readonly flags: import("${r.flags}").LunoraFlags;`:"",v=G?`
40
+ readonly flags: import("${r.flags}").LunoraFlags;`:"",g=G?`
43
41
  /** Multi-channel notifications (@lunora/notify): send / chat / inApp / webhook plus the push device sub-facade. Sends are external I/O — confine them to action handlers. */
44
42
  readonly notify: import("@lunora/notify").LunoraNotify;
45
43
  /** Device push sub-facade — the same object as ctx.notify.push (register / send / broadcast). Sends belong in action handlers. */
46
- readonly push: import("@lunora/notify").LunoraPush;`:"",p=b.length>0,pe=p?`import type { WorkflowHandle } from "@lunora/workflow";
44
+ readonly push: import("@lunora/notify").LunoraPush;`:"",u=M.length>0,pe=u?`import type { WorkflowHandle } from "@lunora/workflow";
47
45
  import type * as lunoraWorkflowDefinitions from "../workflows.js";
48
- `:"",ye=p?`
46
+ `:"",ye=u?`
49
47
 
50
48
  /** Params type carried by a \`defineWorkflow\` definition (its phantom \`__params\`). */
51
49
  type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params }
@@ -56,29 +54,29 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
56
54
 
57
55
  /** This project's declared workflows, addressable from \`ctx.workflows\` by their \`lunora/workflows.ts\` export name. */
58
56
  export interface LunoraWorkflows {
59
- ${b.map(e=>` get(name: ${JSON.stringify(e.exportName)}): WorkflowHandle<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${e.exportName}>>;`).join(`
57
+ ${M.map(e=>` get(name: ${JSON.stringify(e.exportName)}): WorkflowHandle<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${e.exportName}>>;`).join(`
60
58
  `)}
61
- }`:"",C=p?' | "workflows"':"",F=p?`
62
- readonly workflows: LunoraWorkflows;`:"",k=m.length>0,me=k?`import type { QueueProducer } from "@lunora/queue";
59
+ }`:"",N=u?' | "workflows"':"",F=u?`
60
+ readonly workflows: LunoraWorkflows;`:"",T=y.length>0,me=T?`import type { QueueProducer } from "@lunora/queue";
63
61
  import type * as lunoraQueueDefinitions from "../queues.js";
64
- `:"",be=k?`
62
+ `:"",be=T?`
65
63
 
66
64
  /** Message body type carried by a \`defineQueue\` definition (its phantom \`__lunoraBody\`). */
67
65
  type QueueBodyOf<Definition> = Definition extends { __lunoraBody?: infer Body } ? (unknown extends Body ? unknown : NonNullable<Body>) : unknown;
68
66
 
69
67
  /** This project's declared queues, addressable from \`ctx.queues\` by their \`lunora/queues.ts\` export name. */
70
68
  export interface LunoraQueues {
71
- ${m.map(e=>` readonly ${e.exportName}: QueueProducer<QueueBodyOf<typeof lunoraQueueDefinitions.${e.exportName}>>;`).join(`
69
+ ${y.map(e=>` readonly ${e.exportName}: QueueProducer<QueueBodyOf<typeof lunoraQueueDefinitions.${e.exportName}>>;`).join(`
72
70
  `)}
73
- }`:"",S=k?`
74
- readonly queues: LunoraQueues;`:"",w=l.length>0,he=w?`import type { AgentHandle } from "@lunora/agent";
75
- `:"",fe=w?`
71
+ }`:"",S=T?`
72
+ readonly queues: LunoraQueues;`:"",v=l.length>0,he=v?`import type { AgentHandle } from "@lunora/agent";
73
+ `:"",fe=v?`
76
74
 
77
75
  /** This project's declared agents, addressable from \`ctx.agents\` by their \`lunora/agents.ts\` export name. */
78
76
  export interface LunoraAgents {
79
- ${l.map(e=>(c(e.exportName,`agent export "${e.exportName}"`),` readonly ${e.exportName}: AgentHandle;`)).join(`
77
+ ${l.map(e=>(R(e.exportName,`agent export "${e.exportName}"`),` readonly ${e.exportName}: AgentHandle;`)).join(`
80
78
  `)}
81
- }`:"",W=w?`
79
+ }`:"",W=v?`
82
80
  readonly agents: LunoraAgents;`:"",xe=d?`import type { InferIdentity } from "${r.server}";
83
81
  import type * as lunoraIdentityContract from "../identity.js";
84
82
  `:"",ge=d?`
@@ -87,12 +85,12 @@ import type * as lunoraIdentityContract from "../identity.js";
87
85
  export type Identity = InferIdentity<typeof lunoraIdentityContract.${d.exportName}>;
88
86
 
89
87
  /** \`ctx.auth\` narrowed so \`getIdentity()\` resolves the declared {@link Identity} contract instead of the untyped claim bag. */
90
- type NarrowedAuth = Omit<QueryCtxBase["auth"], "getIdentity"> & { getIdentity: () => Promise<Identity | null> };`:"",I=d?' | "auth"':"",$=d?`
88
+ type NarrowedAuth = Omit<QueryCtxBase["auth"], "getIdentity"> & { getIdentity: () => Promise<Identity | null> };`:"",k=d?' | "auth"':"",w=d?`
91
89
  readonly auth: NarrowedAuth;`:"",Te=d?", Identity":"",ve=t?`import type * as lunoraEnvContract from "../env.js";
92
90
  `:"",ke=t?`
93
91
 
94
92
  /** This app's declared env contract (\`defineEnv\` in \`lunora/env.ts\`) — the validated, coercion-aware shape of \`ctx.env\`. */
95
- export type LunoraEnv = ReturnType<typeof lunoraEnvContract.${t.exportName}>;`:"",R=t?' | "env"':"",B=t?"\n /** Validated, typed environment declared by `defineEnv` in `lunora/env.ts` — parsed & coercion-aware config values (`ctx.env.STRIPE_KEY`); a missing or invalid value throws at read time. */\n readonly env: LunoraEnv;":"";return`${Re}import { createPolicyDsl, defineMutator as defineMutatorBase, initLunora, v as vBase } from "${r.server}";
93
+ export type LunoraEnv = ReturnType<typeof lunoraEnvContract.${t.exportName}>;`:"",I=t?' | "env"':"",$=t?"\n /** Validated, typed environment declared by `defineEnv` in `lunora/env.ts` — parsed & coercion-aware config values (`ctx.env.STRIPE_KEY`); a missing or invalid value throws at read time. */\n readonly env: LunoraEnv;":"";return`${Re}import { createPolicyDsl, defineMutator as defineMutatorBase, initLunora, v as vBase } from "${r.server}";
96
94
  import type {
97
95
  ActionBuilder,
98
96
  ActionCtx as ActionCtxBase,
@@ -209,7 +207,7 @@ export interface OrmWriter extends OrmReader {
209
207
  }
210
208
 
211
209
  /** Storage buckets this schema declares (\`v.storage("name")\`), narrowing \`ctx.storage.bucket(name)\`. */
212
- export type StorageBucketName = ${K};${ne}${ye}${be}${fe}${ge}${ke}
210
+ export type StorageBucketName = ${K};${oe}${ye}${be}${fe}${ge}${ke}
213
211
 
214
212
  /**
215
213
  * Project-typed contexts. The base contexts from \`@lunora/server\` are
@@ -272,22 +270,22 @@ type AsIdTable<T extends string> = T extends TableName ? T : string extends T ?
272
270
  */
273
271
  type TypedAsId = <T extends string>(tableName: AsIdTable<T>, id: string) => IdOfTable<T & TableName>;
274
272
 
275
- export interface QueryCtx extends Omit<QueryCtxBase, "db" | "storage"${x}${I}${R}> {
273
+ export interface QueryCtx extends Omit<QueryCtxBase, "db" | "storage"${h}${k}${I}> {
276
274
  readonly db: Omit<DatabaseReader, "asId" | "query" | "get"> & DatabaseReaderFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
277
275
  readonly orm: OrmReader;
278
- readonly storage: ReadOnlyStorage<StorageBucketName>;${ce}${g}${h}${T}${v}${f}${B}${$}
276
+ readonly storage: ReadOnlyStorage<StorageBucketName>;${ce}${f}${m}${x}${g}${b}${$}${w}
279
277
  }
280
278
 
281
- export interface MutationCtx extends Omit<MutationCtxBase, "db" | "storage"${x}${C}${I}${R}> {
279
+ export interface MutationCtx extends Omit<MutationCtxBase, "db" | "storage"${h}${N}${k}${I}> {
282
280
  readonly db: Omit<DatabaseWriter, "asId" | "query" | "get"> & DatabaseWriterFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
283
281
  readonly orm: OrmWriter;
284
- readonly storage: MutationStorage<StorageBucketName>;${A}${g}${h}${T}${v}${f}${B}${F}${S}${W}${$}
282
+ readonly storage: MutationStorage<StorageBucketName>;${C}${f}${m}${x}${g}${b}${$}${F}${S}${W}${w}
285
283
  }
286
284
 
287
- export interface ActionCtx extends Omit<ActionCtxBase, "db" | "storage"${x}${C}${I}${R}> {
285
+ export interface ActionCtx extends Omit<ActionCtxBase, "db" | "storage"${h}${N}${k}${I}> {
288
286
  readonly db: Omit<DatabaseWriter, "asId" | "query" | "get"> & DatabaseWriterFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
289
287
  readonly orm: OrmWriter;
290
- readonly storage: StorageBase<StorageBucketName>;${A}${g}${J}${Z}${te}${re}${h}${T}${v}${oe}${se}${ie}${f}${de}${le}${B}${F}${S}${W}${$}
288
+ readonly storage: StorageBase<StorageBucketName>;${C}${f}${J}${Z}${te}${re}${m}${x}${g}${ne}${se}${ie}${b}${de}${le}${$}${F}${S}${W}${w}
291
289
  }
292
290
 
293
291
  /**
@@ -1 +1 @@
1
- import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./ir-BgM8A3XV.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as f}from"./shard-BaHiawkc.mjs";import"./shard-runtime-B5SUfdZB.mjs";import"./shared-DjUziztz.mjs";export{f as default};
1
+ import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./ir-BgM8A3XV.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as f}from"./shard-CCNl561P.mjs";import"./shard-runtime-B7xvdFPc.mjs";import"./shared-DjUziztz.mjs";export{f as default};
@@ -1,4 +1,4 @@
1
- import{LunoraError as Pt}from"@lunora/errors";import{serializeSchemaSnapshot as qt,hashSchemaSnapshot as Ft}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{isHyperdriveGlobalTable as Nt,isD1GlobalTable as Ut}from"./isD1GlobalTable-udvHAAzD.mjs";import{i as Bt}from"./ir-BgM8A3XV.mjs";import{r as l}from"./json-data-Chfs2Cz5.mjs";import{r as q,e as Wt,a as jt,b as Ht,c as Vt,d as Kt,f as Gt,g as Qt,h as zt,i as Xt,j as Jt,k as Yt,l as Zt,m as er,n as tr,o as rr,p as ar,q as nr,s as sr,t as or,u as ir,v as dr,w as cr,x as lr,y as hr}from"./shard-runtime-B5SUfdZB.mjs";import{u as Z,i as ur,G as pr,d as mr}from"./shared-DjUziztz.mjs";const gr=` /**
1
+ import{LunoraError as Pt}from"@lunora/errors";import{serializeSchemaSnapshot as qt,hashSchemaSnapshot as Ft}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{isHyperdriveGlobalTable as Nt,isD1GlobalTable as Ut}from"./isD1GlobalTable-udvHAAzD.mjs";import{i as Bt}from"./ir-BgM8A3XV.mjs";import{r as l}from"./json-data-Chfs2Cz5.mjs";import{r as q,e as Wt,a as jt,b as Ht,c as Vt,d as Kt,f as Gt,g as Qt,h as zt,i as Xt,j as Jt,k as Yt,l as Zt,m as er,n as tr,o as rr,p as ar,q as nr,s as sr,t as or,u as ir,v as dr,w as cr,x as lr,y as hr}from"./shard-runtime-B7xvdFPc.mjs";import{u as Z,i as ur,G as pr,d as mr}from"./shared-DjUziztz.mjs";const gr=` /**
2
2
  * The bare writer every admin/maintenance entry point writes through.
3
3
  *
4
4
  * Admin and maintenance writes go through the SAME reactive-cache hooks as a
@@ -1,4 +1,4 @@
1
- import{r as p}from"./json-data-Chfs2Cz5.mjs";import{a,G as d}from"./shared-DjUziztz.mjs";const k=e=>e?{importFragment:"serveRelationFanout, ",override:`
1
+ import{r as p}from"./json-data-Chfs2Cz5.mjs";import{a,G as d}from"./shared-DjUziztz.mjs";const x=e=>e?{importFragment:"serveRelationFanout, ",override:`
2
2
  protected override async runRelationFanoutRead(functionPath: string, args: Record<string, unknown>): Promise<unknown> {
3
3
  this.ensureMigrated();
4
4
 
@@ -6,7 +6,7 @@ import{r as p}from"./json-data-Chfs2Cz5.mjs";import{a,G as d}from"./shared-DjUzi
6
6
 
7
7
  return serveRelationFanout(schema as unknown as SchemaLike, db, functionPath, args);
8
8
  }
9
- `}:{importFragment:"",override:""},x=e=>e?{build:`
9
+ `}:{importFragment:"",override:""},k=e=>e?{build:`
10
10
  const aiBinding = config.ai?.(env) ?? (env as Record<string, unknown>).AI;
11
11
  // Correlate AI-Gateway-routed calls with the Lunora trace: thread the
12
12
  // function path + trace id into createAi, which folds them into the
@@ -23,12 +23,12 @@ import{r as p}from"./json-data-Chfs2Cz5.mjs";import{a,G as d}from"./shared-DjUzi
23
23
  telemetry: { metrics, trace },
24
24
  });
25
25
  `,configField:`
26
- ai?: (env: Record<string, unknown>) => AiBindingLike;`}:{build:"",configField:""},l=(e,t,n,{cast:r="",sync:o=[]}={})=>{const s=n.map(u=>` ${u}: ${o.includes(u)?"":"async "}() => {
26
+ ai?: (env: Record<string, unknown>) => AiBindingLike;`}:{build:"",configField:""},l=(e,t,n,{cast:r="",sync:o=[]}={})=>{const i=n.map(u=>` ${u}: ${o.includes(u)?"":"async "}() => {
27
27
  ${t}
28
28
  },`).join(`
29
29
  `);return`
30
30
  const ${e} = {
31
- ${s}
31
+ ${i}
32
32
  }${r};
33
33
  `},c={build:"",configField:"",contextField:"",importLines:[],stub:""},w=e=>e.size===0?{configField:"",constant:"",override:""}:{configField:"\n /** The `ShardRegistryDO` namespace (typically `env.SHARD_REGISTRY`). This shard registers its key for each `.shardBy()` table it writes, so cross-shard export, sync and migrations reach it. */\n shardRegistry?: (env: Record<string, unknown>) => unknown;",constant:`
34
34
  /** The \`.shardBy()\` tables this shard registers with the shard registry when it writes them. */
@@ -70,15 +70,15 @@ const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(t=>JSON.string
70
70
  env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:c,A=e=>e?{build:`
71
71
  const access = accessFacade(identity, userId);
72
72
  `,configField:"",contextField:`
73
- access,`,importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}:c,F=(e,t,n)=>{if(!t)return{constant:"",evaluateOverride:"",subscriptionOverride:""};const r=i=>`
73
+ access,`,importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}:c,F=(e,t,n)=>{if(!t)return{constant:"",evaluateOverride:"",subscriptionOverride:""};const r=s=>`
74
74
  const env = (this.env ?? {}) as Record<string, unknown>;
75
75
  const flags: import("${n}").LunoraFlags = createFlags(flagsConfig, env, {
76
76
  provider: () => config.flags?.(env),
77
- targetingKey: ${i},
77
+ targetingKey: ${s},
78
78
  });`,o=`
79
79
  /** Statically-discovered feature flags (\`ctx.flags.<type>("key")\` reads) served via \`__lunora_admin__:listFlags\` + the reactive \`__lunora_flags__:\` channel. */
80
80
  const LUNORA_FLAG_KEYS = ${p(e,'ReadonlyArray<{ key: string; type: "boolean" | "number" | "object" | "string" }>')};
81
- `,s=`
81
+ `,i=`
82
82
  protected override async evaluateFlags(context?: Record<string, unknown>): Promise<FlagsResult> {${r("undefined")}
83
83
  const evalContext = context as import("${n}").EvaluationContext | undefined;
84
84
  const evaluations: FlagsResult["flags"] = [];
@@ -132,7 +132,7 @@ const LUNORA_FLAG_KEYS = ${p(e,'ReadonlyArray<{ key: string; type: "boolean" | "
132
132
 
133
133
  return flags.boolean(key, typeof args.default === "boolean" ? args.default : false, context);
134
134
  }
135
- `;return{constant:o,evaluateOverride:s,subscriptionOverride:u}},$=e=>e?{build:`
135
+ `;return{constant:o,evaluateOverride:i,subscriptionOverride:u}},$=e=>e?{build:`
136
136
  const analyticsBinding = config.analytics?.(env) ?? (env as Record<string, unknown>).ANALYTICS;
137
137
  const analytics: AnalyticsClient = analyticsBinding ? createAnalytics(analyticsBinding as AnalyticsEngineDatasetLike) : analyticsStub;
138
138
  `,configField:`
@@ -150,7 +150,7 @@ const LUNORA_FLAG_KEYS = ${p(e,'ReadonlyArray<{ key: string; type: "boolean" | "
150
150
  const browser: Browser = config.browser ? config.browser(env) : browserStub;
151
151
  `,configField:`
152
152
  browser?: (env: Record<string, unknown>) => Browser;`,contextField:`
153
- browser,`,importLines:['import type { Browser } from "@lunora/browser";'],stub:l("browserStub: Browser","throw new Error(\"ctx.browser: provide a \\`browser\\` config thunk, e.g. \\`browser: (env) => createBrowser({ binding: env.BROWSER, launch })\\` with \\`import { launch } from '@cloudflare/playwright'\\`. Session reuse (connect/sessions) additionally needs those two exports passed the same way.\");",["connect","content","launch","pdf","scrape","screenshot","sessions"])}:c,O=e=>e?{build:`
153
+ browser,`,importLines:['import type { Browser } from "@lunora/browser";'],stub:l("browserStub: Browser","throw new Error(\"ctx.browser: provide a \\`browser\\` config thunk, e.g. \\`browser: (env) => createBrowser({ binding: env.BROWSER, launch })\\` with \\`import { launch } from '@cloudflare/playwright'\\`. Session reuse (connect/sessions) additionally needs those two exports passed the same way.\");",["cancelCrawl","connect","content","crawl","crawlResult","launch","pdf","quickAction","scrape","screenshot","sessions"])}:c,O=e=>e?{build:`
154
154
  const r2sqlEnv = env as Record<string, unknown>;
155
155
  const r2sqlAccountId = (r2sqlEnv.R2_SQL_ACCOUNT_ID ?? r2sqlEnv.CLOUDFLARE_ACCOUNT_ID) as string | undefined;
156
156
  const r2sqlToken = r2sqlEnv.R2_SQL_TOKEN as string | undefined;
@@ -165,14 +165,14 @@ const LUNORA_FLAG_KEYS = ${p(e,'ReadonlyArray<{ key: string; type: "boolean" | "
165
165
  const pipelinesBinding = config.pipelines?.(env) ?? (env as Record<string, unknown>).PIPELINES;
166
166
  const pipelines: PipelineClient = pipelinesBinding ? createPipelines({ binding: pipelinesBinding as PipelineBindingLike }) : pipelinesStub;
167
167
  `,configField:`
168
- pipelines?: (env: Record<string, unknown>) => PipelineBindingLike;`,contextField:"",importLines:['import type { PipelineBindingLike, PipelineClient } from "@lunora/bindings/pipelines";','import { createPipelines } from "@lunora/bindings/pipelines";'],stub:l("pipelinesStub: PipelineClient",'throw new Error("ctx.pipelines: no Pipelines binding found. Add a \\`pipelines\\` binding (env.PIPELINES) to wrangler.jsonc, or pass \\`pipelines\\` to createShardDO().");',["send"])}:c,q=(e,t)=>{if(e.length===0)return"";const n=t?`, ${JSON.stringify(t)}`:"",r=e.map(s=>(a(s.exportName,`container export "${s.exportName}"`),a(s.className,`container class "${s.className}"`),`/** Container DO for the \`${s.exportName}\` definition (binding \`${s.bindingName}\`). */
169
- export class ${s.className} extends LunoraContainer {
168
+ pipelines?: (env: Record<string, unknown>) => PipelineBindingLike;`,contextField:"",importLines:['import type { PipelineBindingLike, PipelineClient } from "@lunora/bindings/pipelines";','import { createPipelines } from "@lunora/bindings/pipelines";'],stub:l("pipelinesStub: PipelineClient",'throw new Error("ctx.pipelines: no Pipelines binding found. Add a \\`pipelines\\` binding (env.PIPELINES) to wrangler.jsonc, or pass \\`pipelines\\` to createShardDO().");',["send"])}:c,q=(e,t)=>{if(e.length===0)return"";const n=t?`, ${JSON.stringify(t)}`:"",r=e.map(i=>(a(i.exportName,`container export "${i.exportName}"`),a(i.className,`container class "${i.className}"`),`/** Container DO for the \`${i.exportName}\` definition (binding \`${i.bindingName}\`). */
169
+ export class ${i.className} extends LunoraContainer {
170
170
  public constructor(ctx: ConstructorParameters<typeof LunoraContainer>[0], env: Record<string, unknown>) {
171
- super(ctx, env, ${s.exportName}, "${s.exportName}"${n});
171
+ super(ctx, env, ${i.exportName}, "${i.exportName}"${n});
172
172
  }
173
173
  }
174
174
  `)).join(`
175
- `),o=e.map(s=>s.exportName).join(", ");return`${d}/**
175
+ `),o=e.map(i=>i.exportName).join(", ");return`${d}/**
176
176
  * Container-enabled Durable Object classes for the containers declared in
177
177
  * \`lunora/containers.ts\`. Re-export them from your worker entry — wrangler
178
178
  * requires each \`containers[].class_name\` to be exported by the worker:
@@ -190,7 +190,7 @@ import { ${o} } from "../containers.js";
190
190
 
191
191
  export { ContainerProxy } from "@lunora/container/do";
192
192
 
193
- ${r}`},I=(e,t)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const r of e)a(r.exportName,`container export "${r.exportName}"`),a(r.bindingName,`container binding "${r.bindingName}"`);const n=e.map(r=>{const o=r.maxInstances===void 0?"":`, maxInstances: ${String(r.maxInstances)}`;return` { binding: "${r.bindingName}", exportName: "${r.exportName}"${o} },`}).join(`
193
+ ${r}`},I=(e,t)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const r of e)a(r.exportName,`container export "${r.exportName}"`),a(r.bindingName,`container binding "${r.bindingName}"`);const n=e.map(r=>{const o=r.schedulingPolicy!==void 0||r.maxInstances===void 0?"":`, maxInstances: ${String(r.maxInstances)}`;return` { binding: "${r.bindingName}", exportName: "${r.exportName}"${o} },`}).join(`
194
194
  `);return{build:`
195
195
  const containers = createContainerContext(env, LUNORA_CONTAINERS, ${t?JSON.stringify(t):"undefined"}, this.getCurrentTraceparent(), this.getCurrentSampleErrors());
196
196
  `,contextField:`
@@ -199,7 +199,7 @@ ${r}`},I=(e,t)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],
199
199
  const LUNORA_CONTAINERS: ReadonlyArray<ContainerBindingSpec> = [
200
200
  ${n}
201
201
  ];
202
- `}},B=e=>{if(e.length===0)return"";const t=e.map(r=>(a(r.exportName,`workflow export "${r.exportName}"`),a(r.className,`workflow class "${r.className}"`),`/** WorkflowEntrypoint for the \`${r.exportName}\` definition (binding \`${r.bindingName}\`). */
202
+ `}},B=e=>{if(e.length===0)return"";const t=e.map(r=>(a(r.exportName,`workflow export "${r.exportName}"`),a(r.className,`workflow class "${r.className}"`),`/** WorkflowEntrypoint for the \`${r.exportName}\` definition, reached as \`ctx.exports.${r.className}\`. */
203
203
  export class ${r.className} extends LunoraWorkflow<WorkflowParamsOf<typeof ${r.exportName}>, WorkflowOutputOf<typeof ${r.exportName}>> {
204
204
  public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
205
205
  super(ctx, env, ${r.exportName}, "${r.exportName}");
@@ -227,21 +227,21 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
227
227
  /** Output type carried by a \`defineWorkflow\` definition (its phantom \`__output\`), so each entrypoint keeps the authored return type. */
228
228
  type WorkflowOutputOf<Definition> = Definition extends { __output?: infer Output } ? Output : unknown;
229
229
 
230
- ${t}`},W=e=>{if(e.length===0)return"";const n=e.filter(i=>i.voice).length>0,r=e.map(i=>{a(i.exportName,`agent export "${i.exportName}"`),a(i.className,`agent class "${i.className}"`);const g=`/** WorkflowEntrypoint for the \`${i.exportName}\` agent (binding \`${i.bindingName}\`). */
231
- export class ${i.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult> {
230
+ ${t}`},W=e=>{if(e.length===0)return"";const n=e.filter(s=>s.voice).length>0,r=e.map(s=>{a(s.exportName,`agent export "${s.exportName}"`),a(s.className,`agent class "${s.className}"`);const g=`/** WorkflowEntrypoint for the \`${s.exportName}\` agent, reached as \`ctx.exports.${s.className}\`. */
231
+ export class ${s.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult> {
232
232
  public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
233
- super(ctx, env, compileAgentWorkflow(${i.exportName}, "${i.exportName}"), "${i.exportName}");
233
+ super(ctx, env, compileAgentWorkflow(${s.exportName}, "${s.exportName}"), "${s.exportName}");
234
234
  }
235
235
  }
236
- `;if(!i.voice)return g;const m=i.voiceClassName??"",y=i.voiceBindingName??"";a(m,`agent voice class "${m}"`);const b=`
237
- /** Voice-session Durable Object for the \`${i.exportName}\` agent (binding \`${y}\`). */
236
+ `;if(!s.voice)return g;const m=s.voiceClassName??"",y=s.voiceBindingName??"";a(m,`agent voice class "${m}"`);const h=`
237
+ /** Voice-session Durable Object for the \`${s.exportName}\` agent (binding \`${y}\`). */
238
238
  export class ${m} extends VoiceSessionDO {
239
239
  public constructor(ctx: ConstructorParameters<typeof VoiceSessionDO>[0], env: Record<string, unknown>) {
240
- super(ctx, env, ${i.exportName}, "${i.exportName}");
240
+ super(ctx, env, ${s.exportName}, "${s.exportName}");
241
241
  }
242
242
  }
243
- `;return`${g}${b}`}).join(`
244
- `),o=e.map(i=>i.exportName).join(", ");return`${d}/**
243
+ `;return`${g}${h}`}).join(`
244
+ `),o=e.map(s=>s.exportName).join(", ");return`${d}/**
245
245
  * WorkflowEntrypoint classes for the agents declared in \`lunora/agents.ts\`.
246
246
  * Each \`defineAgent\` compiles a replay-safe tool-loop onto a Cloudflare
247
247
  * Workflow. Re-export them from your worker entry — wrangler requires each
@@ -270,9 +270,9 @@ import { ${n} } from "../queues.js";
270
270
  export const LUNORA_QUEUE_REGISTRY: QueueRegistry = {
271
271
  ${r}
272
272
  };
273
- `},T=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)a(n.exportName,`workflow export "${n.exportName}"`),a(n.bindingName,`workflow binding "${n.bindingName}"`);const t=e.map(n=>` { binding: "${n.bindingName}", exportName: "${n.exportName}" },`).join(`
273
+ `},T=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)a(n.exportName,`workflow export "${n.exportName}"`),a(n.className,`workflow class "${n.className}"`);const t=e.map(n=>` { className: "${n.className}", exportName: "${n.exportName}" },`).join(`
274
274
  `);return{build:`
275
- const workflows = createWorkflowContext(env, LUNORA_WORKFLOWS);
275
+ const workflows = createWorkflowContext(env, LUNORA_WORKFLOWS, this.state.exports);
276
276
  `,contextField:`
277
277
  workflows,`,importLines:['import type { WorkflowBindingSpec } from "@lunora/workflow";','import { createWorkflowContext } from "@lunora/workflow";'],specs:`
278
278
  /** Wiring specs for \`ctx.workflows\` (codegen-derived from \`lunora/workflows.ts\`). */
@@ -288,9 +288,9 @@ ${t}
288
288
  const LUNORA_QUEUES: ReadonlyArray<QueueBindingSpec> = [
289
289
  ${t}
290
290
  ];
291
- `}},U=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)a(n.exportName,`agent export "${n.exportName}"`),a(n.bindingName,`agent binding "${n.bindingName}"`);const t=e.map(n=>` { binding: "${n.bindingName}", exportName: "${n.exportName}"${n.publicRun===!0?", publicRun: true":""} },`).join(`
291
+ `}},U=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)a(n.exportName,`agent export "${n.exportName}"`),a(n.className,`agent class "${n.className}"`);const t=e.map(n=>` { className: "${n.className}", exportName: "${n.exportName}"${n.publicRun===!0?", publicRun: true":""} },`).join(`
292
292
  `);return{build:`
293
- const agents = createAgentContext(env, LUNORA_AGENTS);
293
+ const agents = createAgentContext(env, LUNORA_AGENTS, { exports: this.state.exports });
294
294
  `,contextField:`
295
295
  agents,`,importLines:['import { createAgentContext } from "@lunora/agent";','import type { AgentBindingSpec } from "@lunora/agent";'],specs:`
296
296
  /** Wiring specs for \`ctx.agents\` (codegen-derived from \`lunora/agents.ts\`). */
@@ -304,7 +304,7 @@ const ${e} = ${p(r,t)};
304
304
  protected override ${n}(): ${t} {
305
305
  return ${e};
306
306
  }
307
- `}),M=e=>{if(e.length===0)return{constant:"",override:""};const t={workflows:e.map(n=>({binding:n.bindingName,className:n.className,exportName:n.exportName,name:n.name}))};return f("LUNORA_WORKFLOWS_INFO","WorkflowsResult","workflowsMetadata",t,"/** Read-only declared-workflow metadata (discovered from `lunora/workflows.ts`) served via `__lunora_admin__:listWorkflows` for the studio's workflows view. */")},Q=e=>{if(e.length===0)return{constant:"",override:""};const t={queues:e.map(n=>({binding:n.bindingName,...n.tuning.deadLetterQueue===void 0?{}:{deadLetterQueue:n.tuning.deadLetterQueue},exportName:n.exportName,mode:n.mode,name:n.name}))};return f("LUNORA_QUEUES_INFO","QueuesResult","queuesMetadata",t,"/** Read-only declared-queue metadata (discovered from `lunora/queues.ts`) served via `__lunora_admin__:listQueues` for the studio's queues view. */")},K=e=>e?{imports:['import type { LunoraDatabaseLike as LunoraPaymentDbLike, LunoraPayment, PaymentsFromContextOptions } from "@lunora/payment";','import { paymentsFromContext } from "@lunora/payment";'],build:`
307
+ `}),M=e=>{if(e.length===0)return{constant:"",override:""};const t={workflows:e.map(n=>({className:n.className,exportName:n.exportName,name:n.name}))};return f("LUNORA_WORKFLOWS_INFO","WorkflowsResult","workflowsMetadata",t,"/** Read-only declared-workflow metadata (discovered from `lunora/workflows.ts`) served via `__lunora_admin__:listWorkflows` for the studio's workflows view. */")},Q=e=>{if(e.length===0)return{constant:"",override:""};const t={queues:e.map(n=>({binding:n.bindingName,...n.tuning.deadLetterQueue===void 0?{}:{deadLetterQueue:n.tuning.deadLetterQueue},exportName:n.exportName,mode:n.mode,name:n.name}))};return f("LUNORA_QUEUES_INFO","QueuesResult","queuesMetadata",t,"/** Read-only declared-queue metadata (discovered from `lunora/queues.ts`) served via `__lunora_admin__:listQueues` for the studio's queues view. */")},K=e=>e?{imports:['import type { LunoraDatabaseLike as LunoraPaymentDbLike, LunoraPayment, PaymentsFromContextOptions } from "@lunora/payment";','import { paymentsFromContext } from "@lunora/payment";'],build:`
308
308
  const payments: LunoraPayment = config.payment
309
309
  ? paymentsFromContext({ auth: { userId: userId ?? null }, db: db as unknown as LunoraPaymentDbLike }, config.payment(env))
310
310
  : paymentStub;
@@ -315,4 +315,4 @@ const ${e} = ${p(r,t)};
315
315
  ? lazyX402Pay(config.x402(env), { getSecret: (name: string) => secrets.get(name) })
316
316
  : x402Stub;
317
317
  `,configField:`
318
- x402?: (env: Record<string, unknown>) => X402PayConfig;`,stub:l("x402Stub: X402Pay",'throw new Error("ctx.x402: no pay rail configured. Pass \\`x402\\` to createShardDO().");',["fetch"],{cast:" as unknown as X402Pay",sync:["fetch"]})}:{build:"",configField:"",imports:[],stub:""},H=(e,t,n,r,o)=>["AdvisorProcedure","AdvisoryFinding","DatabaseWriterLike","DataMigrationLike","DispatchBookmark","ExportRow",...r?["FlagsResult"]:[],"ImportShardResult","KeyRange","MaskPoliciesResult","MigrationRunResult","QueryReadScope",...n?["QueuesResult"]:[],"RelatedPage","RunShardApplyCdcArgs","RunShardExportArgs","RunShardFindRelatedArgs","RunShardImportArgs","RunShardMigrationArgs","RlsPoliciesResult","RunShardRankBeforeArgs","RunShardRankPageArgs","RunShardWriteArgs","RunShardWriteResult","SchedulerLike",...o?["SearchBackfillProgress"]:[],"TransactionHeadroomTracker","SchemaLike","ShardDOState","ShardRankPageResult","SqlExec","StorageRulesResult","StudioFeaturesResult","SubscriptionIdentity","SystemReaderStorageLike","TelemetrySink",...e?["VectorBackfillProgress"]:[],...t?["WorkflowsResult"]:[],...e?["WriteHook"]:[]];export{q as A,B,D as C,R as a,N as b,F as c,L as d,x as e,$ as f,C as g,_ as h,E as i,O as j,P as k,j as l,I as m,T as n,U as o,K as p,V as q,l as r,M as s,Q as t,w as u,H as v,k as w,A as x,S as y,W as z};
318
+ x402?: (env: Record<string, unknown>) => X402PayConfig;`,stub:l("x402Stub: X402Pay",'throw new Error("ctx.x402: no pay rail configured. Pass \\`x402\\` to createShardDO().");',["fetch"],{cast:" as unknown as X402Pay",sync:["fetch"]})}:{build:"",configField:"",imports:[],stub:""},H=(e,t,n,r,o)=>["AdvisorProcedure","AdvisoryFinding","DatabaseWriterLike","DataMigrationLike","DispatchBookmark","ExportRow",...r?["FlagsResult"]:[],"ImportShardResult","KeyRange","MaskPoliciesResult","MigrationRunResult","QueryReadScope",...n?["QueuesResult"]:[],"RelatedPage","RunShardApplyCdcArgs","RunShardExportArgs","RunShardFindRelatedArgs","RunShardImportArgs","RunShardMigrationArgs","RlsPoliciesResult","RunShardRankBeforeArgs","RunShardRankPageArgs","RunShardWriteArgs","RunShardWriteResult","SchedulerLike",...o?["SearchBackfillProgress"]:[],"TransactionHeadroomTracker","SchemaLike","ShardDOState","ShardRankPageResult","SqlExec","StorageRulesResult","StudioFeaturesResult","SubscriptionIdentity","SystemReaderStorageLike","TelemetrySink",...e?["VectorBackfillProgress"]:[],...t?["WorkflowsResult"]:[],...e?["WriteHook"]:[]];export{q as A,B,D as C,R as a,N as b,F as c,L as d,k as e,$ as f,C as g,_ as h,E as i,O as j,P as k,j as l,I as m,T as n,U as o,K as p,V as q,l as r,M as s,Q as t,w as u,H as v,x as w,A as x,S as y,W as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/codegen",
3
- "version": "1.0.0-alpha.241",
3
+ "version": "1.0.0-alpha.242",
4
4
  "description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -46,15 +46,15 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@lunora/advisor": "1.0.0-alpha.173",
50
- "@lunora/agent": "1.0.0-alpha.155",
51
- "@lunora/container": "1.0.0-alpha.63",
52
- "@lunora/errors": "1.0.0-alpha.47",
53
- "@lunora/platform": "1.0.0-alpha.45",
54
- "@lunora/queue": "1.0.0-alpha.80",
55
- "@lunora/scheduler": "1.0.0-alpha.99",
56
- "@lunora/values": "1.0.0-alpha.57",
57
- "@lunora/workflow": "1.0.0-alpha.68",
49
+ "@lunora/advisor": "1.0.0-alpha.174",
50
+ "@lunora/agent": "1.0.0-alpha.156",
51
+ "@lunora/container": "1.0.0-alpha.64",
52
+ "@lunora/errors": "1.0.0-alpha.48",
53
+ "@lunora/platform": "1.0.0-alpha.46",
54
+ "@lunora/queue": "1.0.0-alpha.81",
55
+ "@lunora/scheduler": "1.0.0-alpha.100",
56
+ "@lunora/values": "1.0.0-alpha.58",
57
+ "@lunora/workflow": "1.0.0-alpha.69",
58
58
  "jiti": "^2.7.0",
59
59
  "quicktype-core": "^26.0.0",
60
60
  "ts-morph": "^28.0.0"
@@ -1 +0,0 @@
1
- import{existsSync as d}from"node:fs";import{join as p}from"node:path";import{agentDefaultName as f,agentClassName as b,agentBindingName as N,voiceBindingName as A,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as m}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as w,findObjectProperty as g,stringPropertyFor as h}from"./listLunoraSourceFiles-DP-5e-RE.mjs";const E="agents.ts",I=i=>{const t=i.getSymbol();if(!t)return i.getText()==="defineAgent";for(const n of t.getDeclarations())if(a.isImportSpecifier(n))return n.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:n.getNameNode().getText()==="defineAgent";return!1},P=h("agent"),T=(i,t,n)=>{if(i.getKind()===u.TrueKeyword)return!0;if(i.getKind()===u.FalseKeyword)return!1;throw l(i,`agent "${t}": \`${n}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},v=(i,t)=>{const n=i.getArguments()[0];if(!n||!a.isObjectLiteralExpression(n))throw l(i,`agent "${t}": defineAgent must be passed an inline object literal`);const o={bindingName:N(t),className:b(t),exportName:t,name:f(t)},e=g(n,"name");e&&a.isPropertyAssignment(e)&&(o.name=P(e.getInitializerOrThrow(),t,"name"));const r=g(n,"publicRun");r&&a.isPropertyAssignment(r)&&T(r.getInitializerOrThrow(),t,"publicRun")&&(o.publicRun=!0);const s=g(n,"voice");if(s&&a.isPropertyAssignment(s)){const c=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(c))throw l(c,`agent "${t}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);o.voice=!0,o.voiceBindingName=A(t),o.voiceClassName=y(t)}return g(n,"onEmail")&&(o.onEmail=!0),o},D=i=>{const t=[];for(const n of i.getVariableDeclarations()){if(!n.isExported())continue;const o=w(n.getInitializer());if(!o)continue;const e=o.getExpression();if(!a.isIdentifier(e)||!I(e))continue;const r=n.getNameNode();if(!a.isIdentifier(r))throw l(r,"defineAgent exports must be plain named exports (no destructuring)");t.push(v(o,r.getText()))}return t},x=i=>{const t=new Map,n=new Map,o=new Map;for(const e of i){const r=t.get(e.name);if(r!==void 0)throw new m("DUPLICATE_AGENT_NAME",`Duplicate agent name "${e.name}": produced by both "${r}" and "${e.exportName}". Deployed agent names must be unique across the project.`,{status:500});t.set(e.name,e.exportName);const s=n.get(e.bindingName);if(s!==void 0)throw new m("DUPLICATE_AGENT_BINDING",`Duplicate agent binding "${e.bindingName}": produced by both "${s}" and "${e.exportName}". Agent export names must yield unique binding names.`,{status:500});n.set(e.bindingName,e.exportName);const c=o.get(e.className);if(c!==void 0)throw new m("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${e.className}": produced by both "${c}" and "${e.exportName}". Agent export names must yield unique generated class names.`,{status:500});o.set(e.className,e.exportName)}},_=(i,t)=>{const n=p(t,E);if(!d(n))return[];const o=i.getSourceFile(n)??i.addSourceFileAtPath(n),e=D(o);return e.sort((r,s)=>r.exportName.localeCompare(s.exportName)),x(e),e};export{E as AGENTS_FILENAME,_ as discoverAgents};
@@ -1 +0,0 @@
1
- import{existsSync as T}from"node:fs";import{join as A}from"node:path";import{containerClassName as L,containerBindingName as k,normalizeContainerImage as d}from"@lunora/container";import{SyntaxKind as g,Node as s}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{propertyKeyName as b,stringPropertyFor as v,findObjectProperty as h,symbolConstInitializer as P}from"./listLunoraSourceFiles-DP-5e-RE.mjs";const $="containers.ts",O=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineContainer";for(const n of t.getDeclarations())if(s.isImportSpecifier(n))return n.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:n.getNameNode().getText()==="defineContainer";return!1},f=v("container"),p=(e,t,n)=>{if(s.isNumericLiteral(e))return e.getLiteralValue();throw c(e,`container "${t}": \`${n}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I=(e,t)=>{if(s.isStringLiteral(e)||s.isNoSubstitutionTemplateLiteral(e))return d(e.getLiteralValue());if(s.isObjectLiteralExpression(e)){const n=h(e,"registry");if(n&&s.isPropertyAssignment(n)){const i=n.getInitializerOrThrow();return d({registry:f(i,t,"image.registry")})}const r=h(e,"build");if(r&&s.isPropertyAssignment(r)){const i=r.getInitializerOrThrow();return d({build:f(i,t,"image.build")})}}throw c(e,`container "${t}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},j=new Set(["buildArgs","image","instanceType","maxInstances","name","rollout"]),C=new Set(["gracePeriodSeconds","stepPercentage"]),w=e=>{let t=e;for(;s.isAsExpression(t)||s.isSatisfiesExpression(t)||s.isTypeAssertion(t)||s.isParenthesizedExpression(t);)t=t.getExpression();return t},z=(e,t)=>{const n=i=>{let o=i;for(;s.isPropertyAccessExpression(o)||s.isElementAccessExpression(o)||s.isParenthesizedExpression(o);)o=o.getExpression();return o===i?void 0:o},r=i=>i!==void 0&&s.isIdentifier(i)&&i.getSymbol()===e;return t.getDescendants().some(i=>{if(s.isBinaryExpression(i)){const o=i.getOperatorToken().getKind();return o>=g.FirstAssignment&&o<=g.LastAssignment&&r(n(i.getLeft()))}if(s.isPrefixUnaryExpression(i)||s.isPostfixUnaryExpression(i)){const o=i.getOperatorToken();return(o===g.PlusPlusToken||o===g.MinusMinusToken)&&r(n(i.getOperand()))}return s.isDeleteExpression(i)?r(n(i.getExpression())):s.isCallExpression(i)&&i.getExpression().getText()==="Object.assign"&&r(i.getArguments()[0])})},M=16,E=(e,t,n,r)=>{let i={name:n,symbol:e},o;for(let a=0;a<M;a+=1){const l=P(i.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=w(l),s.isObjectLiteralExpression(o)&&i.symbol!==void 0&&z(i.symbol,t.getSourceFile()))throw c(t,`${r}: \`${i.name}\` is a const object that is written to elsewhere in this file, so its initializer is not the value the container runs with. Declare the settings where they are final.`);if(!s.isIdentifier(o))return o;i={name:o.getText(),symbol:o.getSymbol()}}return o},S=(e,t)=>{const n=w(e);return s.isIdentifier(n)?E(n.getSymbol(),n,n.getText(),t)??n:n},x=e=>{const t=e.getNonNullableType();return(t.isUnion()?t.getUnionTypes():[t]).flatMap(r=>r.getApparentType().getProperties().map(i=>i.getName()))},N=(e,t,n)=>{const r=e.getExpression().getType(),i=t==="every"||r.isAny()||r.isUnknown()?["its keys"]:[...new Set(x(r))].filter(o=>t.has(o)).map(o=>`\`${o}\``);if(i.length>0)throw c(e,`${n}: this spread can set ${i.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},F=(e,t,n)=>{const r=b(e),i=s.isShorthandPropertyAssignment(e)?E(e.getValueSymbol(),e,r,n):void 0;if(i!==void 0)return[r,i];if(t==="every"||t.has(r))throw c(e,`${n}: \`${r}\` is deploy configuration codegen writes into wrangler.jsonc, so it must be a static literal — inline it, or name a module-scope \`const\` initialized with one.`)},m=(e,t,n,r=new Set)=>{const i=[],o=new Set(r).add(e);for(const a of e.getProperties())if(s.isPropertyAssignment(a))i.push([b(a),S(a.getInitializerOrThrow(),n)]);else if(s.isSpreadAssignment(a))i.push(...D(a,t,n,o));else{const l=F(a,t,n);l!==void 0&&i.push(l)}return i},D=(e,t,n,r)=>{const i=S(e.getExpression(),n);if(!s.isObjectLiteralExpression(i))return N(e,t,n),[];if(r.has(i))throw c(e,`${n}: this spread refers back to an object it is part of, so it has no static value.`);return m(i,t,n,r)},V=(e,t)=>{if(!s.isObjectLiteralExpression(e))throw c(e,`container "${t}": \`buildArgs\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const n={};for(const[r,i]of m(e,"every",`container "${t}" buildArgs`))n[r]=f(i,t,`buildArgs.${r}`);return Object.keys(n).length>0?n:void 0},B=(e,t)=>{if(!s.isObjectLiteralExpression(e))throw c(e,`container "${t}": \`rollout\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const n={};for(const[r,i]of m(e,C,`container "${t}" rollout`))(r==="gracePeriodSeconds"||r==="stepPercentage")&&(n[r]=p(i,t,`rollout.${r}`));return n.gracePeriodSeconds===void 0&&n.stepPercentage===void 0?void 0:n},K=e=>{if(s.isTrueLiteral(e))return!0;if(s.isFalseLiteral(e))return!1},U=e=>{if(s.isStringLiteral(e)||s.isNoSubstitutionTemplateLiteral(e)||s.isNumericLiteral(e))return e.getLiteralValue()},R=(e,t)=>{if(s.isStringLiteral(e))return e.getLiteralValue();if(s.isObjectLiteralExpression(e)){const n={};for(const r of e.getProperties()){if(!s.isPropertyAssignment(r))throw c(r,`container "${t}": \`instanceType\` must be an object of static number literals`);const i=b(r);if(i!=="diskMb"&&i!=="memoryMib"&&i!=="vcpu")throw c(r,`container "${t}": unknown \`instanceType\` field "${i}" — expected vcpu, memoryMib, or diskMb`);n[i]=p(r.getInitializerOrThrow(),t,`instanceType.${i}`)}return n}throw c(e,`container "${t}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},_=(e,t)=>{const n=e.getArguments()[0];if(!n||!s.isObjectLiteralExpression(n))throw c(e,`container "${t}": defineContainer must be passed an inline object literal`);const r={bindingName:k(t),className:L(t),exportName:t,image:{buildContext:".",dockerfilePath:"./Dockerfile",kind:"dockerfile"}};let i=!1;for(const[o,a]of m(n,j,`container "${t}"`))switch(o){case"buildArgs":{r.buildArgs=V(a,t);break}case"enableInternet":{r.enableInternet=K(a);break}case"image":{r.image=I(a,t),i=!0;break}case"instanceType":{r.instanceType=R(a,t);break}case"maxInstances":{r.maxInstances=p(a,t,"maxInstances");break}case"name":{r.name=f(a,t,"name");break}case"rollout":{r.rollout=B(a,t);break}case"sleepAfter":{r.sleepAfter=U(a);break}}if(!i)throw c(n,`container "${t}": defineContainer requires a static \`image\` property`);return r},q=e=>{const t=[],n=new Map;for(const r of e.getVariableDeclarations()){if(!r.isExported())continue;const i=r.getInitializer();if(i?.getKind()!==g.CallExpression)continue;const o=i,a=o.getExpression();if(!s.isIdentifier(a)||!O(a))continue;const l=r.getNameNode();if(!s.isIdentifier(l))throw c(l,"defineContainer exports must be plain named exports (no destructuring)");const u=_(o,l.getText()),y=n.get(u.bindingName);if(y!==void 0)throw c(l,`containers "${y}" and "${u.exportName}" both map to the binding ${u.bindingName} — rename one so each container gets its own Durable Object binding`);n.set(u.bindingName,u.exportName),t.push(u)}return t},Q=(e,t)=>{const n=A(t,$);if(!T(n))return[];const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),i=q(r);return i.sort((o,a)=>o.exportName.localeCompare(a.exportName)),i};export{$ as CONTAINERS_FILENAME,Q as discoverContainers};
@@ -1 +0,0 @@
1
- import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h,CELLD_CAPABILITIES as v}from"@lunora/platform";import{readProjectConfigLiterals as m}from"./loadProjectConfig-CKsFNgn3.mjs";const c="cloudflare",b=t=>{const{target:e}=m(t);return e!==void 0&&e.length>0?e:void 0},L=(t,e)=>e??b(t)??c,x=(t,e)=>{if(e!==void 0)return[];const{target:a,unreadable:r}=m(t);return r!==!0||a!==void 0?[]:[{level:"warn",message:`lunora.config declares a \`target\` that codegen cannot read without evaluating it, so the "${c}" surface was emitted. \`runCodegen\` resolves the target synchronously, which means it reads literals only.`,name:"platform_unreadable_target",remediation:`Write \`target\` as a string literal on the config's default export (\`export default { target: "${c}" }\`), or pass \`--target\`.`,target:c}]},u={celld:v,cloudflare:h,node:f},C=()=>Object.keys(u).toSorted((t,e)=>t.localeCompare(e)),y={access:null,ai:"ai",analytics:"analytics",browser:"browser",container:"containers",flags:null,hyperdrive:"hyperdrive",images:"images",kv:"keyValueStore",mail:"mail",notify:null,payments:null,pipelines:"pipelines",r2sql:null,scheduler:"scheduler",storage:"objectStorage",vectors:"vectorStore",workflows:"workflows",x402:null},w=["agents","commitOrderedTables","containerEgressPolicy","cronTriggers","crossShardFanout","durableStreams","globalTables","queues","relationGraph","secrets","vectorStore","workerLoaders","workflowRollback"],g={agents:"durable agents (`defineAgent`)",commitOrderedTables:"commit-ordered tables (`.commitOrdered()`)",containerEgressPolicy:"container egress policies (`defineContainer({ allowedHosts | deniedHosts | interceptHttps })`)",cronTriggers:"declared cron triggers (`cronJobs()`)",crossShardFanout:"cross-shard fan-out queries (a `.shardBy(...)` schema)",durableStreams:"durable streams (`.stream(handler, { durable: true })`)",globalTables:"global tables (`.global()`)",queues:"queues (`defineQueue`)",relationGraph:"relation-graph traversal (`ctx.db.related`, derived from `v.id(...)` columns)",secrets:"the secrets store (`ctx.secrets`)",vectorStore:"vector indexes (`.vectorize()`)",workerLoaders:"sandboxed agent scripts (`jsCodeTool`, on Worker Loaders)",workflowRollback:"workflow step rollback (`defineStep({ rollback })`)"},S=(t,e,a)=>({level:"error",message:`${e.name} does not support ${g[t]}, which this app declares.`,name:"platform_unsupported_feature",remediation:`Remove the declaration, or deploy to a target whose capability matrix marks "${t}" as native or emulated.`,target:a}),T=(t,e,a)=>({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${g[t]}, which this app declares. Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${t}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than letting the app deploy onto a primitive the host may not provide.`,target:a}),_=t=>{const{diagnostics:e,gatedSignals:a,matrix:r,reported:n,signals:d,target:l}=t;for(const s of w){if(d[s]!==!0)continue;const o=r.features[s]?.level;o!=="unsupported"&&o!==void 0||(a[s]=!1,!n.has(s)&&e.push(o==="unsupported"?S(s,r,l):T(s,r,l)))}},$=(t,e,a,r={})=>{const n={...t},d={...r},l=[],s=new Set;for(const[o,i]of Object.entries(y)){if(i===null||!t[o])continue;const p=e.features[i]?.level;p==="unsupported"?(n[o]=!1,s.add(i),l.push({feature:o,level:"error",message:`${e.name} does not support "${o}" (ctx.${o}).`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${o} usage, or deploy to a target whose capability matrix marks "${i}" as native or emulated.`,target:a})):p===void 0&&(n[o]=!1,s.add(i),l.push({feature:o,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${o}" (ctx.${o}). Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${i}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than shipping a surface the host may not provide.`,target:a}))}return _({diagnostics:l,gatedSignals:d,matrix:e,reported:s,signals:r,target:a}),{diagnostics:l,signals:d,usage:n}},E=(t,e,a={})=>{const r=u[e];return r===void 0?{diagnostics:[{level:"error",message:`Unknown deploy target "${e}" — no capability matrix is registered for it. Codegen emitted the full Cloudflare surface un-gated.`,name:"platform_unknown_target",remediation:`Use a registered target (${Object.keys(u).join(", ")}) or install the target's @lunora/platform-${e} package.`,target:e}],signals:{...a},usage:{...t}}:$(t,r,e,a)},I=t=>{const e=u[t];if(e===void 0)return;const a=Object.entries(e.features).filter(([,r])=>r.level==="unsupported").map(([r])=>r).toSorted((r,n)=>r.localeCompare(n));return{id:e.id,name:e.name,unsupported:a}};export{y as CAPABILITY_TO_FEATURE,c as DEFAULT_TARGET,$ as gateAgainstMatrix,E as gatePlatformFeatures,C as platformMatrixIds,b as readProjectTarget,x as readTargetDiagnostics,L as resolveCodegenTarget,I as studioPlatformFor};