@lunora/codegen 1.0.0-alpha.255 → 1.0.0-alpha.257

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 (60) hide show
  1. package/dist/index.d.mts +118 -66
  2. package/dist/index.d.ts +118 -66
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AGENTS_FILENAME-D8SgT3OR.mjs → AGENTS_FILENAME-D0fmyQlq.mjs} +1 -1
  5. package/dist/packem_shared/{CONTAINERS_FILENAME-C13yKxas.mjs → CONTAINERS_FILENAME-C2wrJ9hF.mjs} +1 -1
  6. package/dist/packem_shared/{DEFAULT_TARGET-Co7ZXJ21.mjs → DEFAULT_TARGET-D5J5j3CW.mjs} +1 -1
  7. package/dist/packem_shared/{FLAGS_FILENAME-W5XQz_Po.mjs → FLAGS_FILENAME-C1tAv68t.mjs} +1 -1
  8. package/dist/packem_shared/{MUTATORS_FILENAME-DqWOgC5Z.mjs → MUTATORS_FILENAME-CDYDr1iG.mjs} +1 -1
  9. package/dist/packem_shared/{NOTIFY_FILENAME-C1J_47et.mjs → NOTIFY_FILENAME-Dmylk3YO.mjs} +1 -1
  10. package/dist/packem_shared/{OPENRPC_VERSION-Cr7Zzp6s.mjs → OPENRPC_VERSION-LZowDAOS.mjs} +1 -1
  11. package/dist/packem_shared/QUEUES_FILENAME-CQXsARur.mjs +1 -0
  12. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-CYrLeST3.mjs +11 -0
  13. package/dist/packem_shared/{SHAPES_FILENAME-DRUFomCj.mjs → SHAPES_FILENAME-CNUAxXo3.mjs} +1 -1
  14. package/dist/packem_shared/WORKFLOWS_FILENAME-DrRu8060.mjs +1 -0
  15. package/dist/packem_shared/attribution-DpIyvmtn.mjs +1 -0
  16. package/dist/packem_shared/{buildOpenApiDocument-SxfElVzK.mjs → buildOpenApiDocument-DZMRzaEx.mjs} +1 -1
  17. package/dist/packem_shared/{capabilitiesUsedBy-DqrbgTKV.mjs → capabilitiesUsedBy-DLv5b8Ss.mjs} +1 -1
  18. package/dist/packem_shared/chain-Bah-gxpx.mjs +1 -0
  19. package/dist/packem_shared/{classify-procedure-call-CmcShAze.mjs → classify-procedure-call-DcsbRyEV.mjs} +1 -1
  20. package/dist/packem_shared/{context-property-calls-CWf9-6G5.mjs → context-property-calls-BClPebao.mjs} +1 -1
  21. package/dist/packem_shared/discoverAuthApiCalls-CEL1n0I0.mjs +1 -0
  22. package/dist/packem_shared/{discoverCrons-BEALHx1S.mjs → discoverCrons-BcrneOpi.mjs} +1 -1
  23. package/dist/packem_shared/{discoverFunctions-BcBzcG5x.mjs → discoverFunctions-TvTtRhvv.mjs} +1 -1
  24. package/dist/packem_shared/{discoverHttpRoutes-CJHS4llq.mjs → discoverHttpRoutes-BdaGy42T.mjs} +1 -1
  25. package/dist/packem_shared/discoverHyperdriveCalls-CDm53WpH.mjs +1 -0
  26. package/dist/packem_shared/discoverInserts-B2MLcH9M.mjs +1 -0
  27. package/dist/packem_shared/discoverMaskProcedures-Cj-dvv0H.mjs +1 -0
  28. package/dist/packem_shared/{discoverMigrations-Dt7ywfZv.mjs → discoverMigrations-jUmsOO70.mjs} +1 -1
  29. package/dist/packem_shared/{discoverNondeterministicCalls-CNJV2BiP.mjs → discoverNondeterministicCalls-BJzH9mEn.mjs} +1 -1
  30. package/dist/packem_shared/discoverQueries-B4enrT1h.mjs +1 -0
  31. package/dist/packem_shared/discoverR2sqlCalls-BgbXtbva.mjs +1 -0
  32. package/dist/packem_shared/{discoverRlsMetadata-mXBmPOGj.mjs → discoverRlsMetadata-DewerjgN.mjs} +1 -1
  33. package/dist/packem_shared/{discoverRlsProcedures-F4Cy-kSi.mjs → discoverRlsProcedures-DY5xYy7C.mjs} +1 -1
  34. package/dist/packem_shared/{discoverSandboxUsage-DC6q7rZy.mjs → discoverSandboxUsage-CJPFsjOS.mjs} +1 -1
  35. package/dist/packem_shared/{discoverSchema-D5R60b4F.mjs → discoverSchema-DPRQni-9.mjs} +1 -1
  36. package/dist/packem_shared/{discoverStorageRulesMetadata-D3Ot9g5f.mjs → discoverStorageRulesMetadata-DnVGPbZl.mjs} +1 -1
  37. package/dist/packem_shared/{emitShard-JmiNbWa4.mjs → emitShard-CLFR7-_j.mjs} +1 -1
  38. package/dist/packem_shared/{exported-procedure-chains-D48EXUVQ.mjs → exported-procedure-chains-BVawk4h7.mjs} +1 -1
  39. package/dist/packem_shared/{fingerprintSchemaSources-Cl1CJFeh.mjs → fingerprintSchemaSources-D5z-pfpY.mjs} +1 -1
  40. package/dist/packem_shared/handler-reference-DLDPO906.mjs +1 -0
  41. package/dist/packem_shared/{index-D7dKfGPh.mjs → index-CpnWNNMK.mjs} +1 -1
  42. package/dist/packem_shared/listLunoraSourceFiles-jTik1QWu.mjs +1 -0
  43. package/dist/packem_shared/{loadProjectConfig-nNIDOrlR.mjs → loadProjectConfig-D_pUUrhQ.mjs} +1 -1
  44. package/dist/packem_shared/{modules-DyCocr1e.mjs → modules-B7lb5-dN.mjs} +1 -1
  45. package/dist/packem_shared/{parse-validator-C6fHL7OS.mjs → parse-validator-0q0Uz-Cx.mjs} +1 -1
  46. package/dist/packem_shared/{readServiceBindings-CeQvSswr.mjs → readServiceBindings-B_M_ZvhO.mjs} +1 -1
  47. package/dist/packem_shared/{shard-Do57J5-c.mjs → shard-B2AqdAuz.mjs} +12 -9
  48. package/dist/packem_shared/{unwrap-handler-return-DVY_kFF7.mjs → unwrap-handler-return-DFT18rnR.mjs} +1 -1
  49. package/package.json +6 -6
  50. package/dist/packem_shared/QUEUES_FILENAME-RGwht3Xu.mjs +0 -1
  51. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-D0ZAEgkE.mjs +0 -11
  52. package/dist/packem_shared/WORKFLOWS_FILENAME-4-ib4HH-.mjs +0 -1
  53. package/dist/packem_shared/chain-mte5djRJ.mjs +0 -1
  54. package/dist/packem_shared/discoverAuthApiCalls-DoSN_yc3.mjs +0 -1
  55. package/dist/packem_shared/discoverHyperdriveCalls-Bkbh4tG7.mjs +0 -1
  56. package/dist/packem_shared/discoverInserts-DpuLYPPd.mjs +0 -1
  57. package/dist/packem_shared/discoverMaskProcedures-B0w8gM0S.mjs +0 -1
  58. package/dist/packem_shared/discoverQueries-BcdqjYky.mjs +0 -1
  59. package/dist/packem_shared/discoverR2sqlCalls-30Wtbc0P.mjs +0 -1
  60. package/dist/packem_shared/listLunoraSourceFiles-CSlcBYlo.mjs +0 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext, AdvisorProcedureProtection } from '@lunora/advisor';
1
+ import { AdvisorCallSiteScope, AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext, AdvisorProcedureProtection } from '@lunora/advisor';
2
2
  export type { Finding } from '@lunora/advisor';
3
3
  import { Project, SourceFile, Node } from 'ts-morph';
4
4
  import { LunoraError } from '@lunora/errors';
@@ -819,6 +819,14 @@ interface WorkflowIR {
819
819
  };
820
820
  /** The `lunora/workflows.ts` export name, e.g. `orderPipeline`. */
821
821
  exportName: string;
822
+ /**
823
+ * The file declaring the `handler:` when it is a function passed by reference
824
+ * and declared in another file — the file {@link WorkflowIR.steps}' lines are
825
+ * in. Lunora-relative inside `lunora/`, project-relative outside it.
826
+ */
827
+ handlerFile?: string;
828
+ /** See {@link HandlerSiteIR}. */
829
+ handlerSite?: HandlerSiteIR;
822
830
  /** Static `limits` literal → `exports.<Class>.limits`. */
823
831
  limits?: {
824
832
  steps?: number;
@@ -841,7 +849,8 @@ interface WorkflowIR {
841
849
  * call. Feeds the duplicate-step-name lint, which flags a name used twice
842
850
  * (Cloudflare memoizes by name, so the second call silently returns the
843
851
  * first's cached result). Calls with a non-literal name are omitted (not
844
- * statically comparable).
852
+ * statically comparable). A handler passed by reference is followed to its
853
+ * declaration; the lines are then in {@link WorkflowIR.handlerFile}.
845
854
  */
846
855
  steps: ReadonlyArray<WorkflowStepIR>;
847
856
  }
@@ -924,6 +933,8 @@ interface QueueIR {
924
933
  bindingName: string;
925
934
  /** The `lunora/queues.ts` export name, e.g. `emailQueue`. */
926
935
  exportName: string;
936
+ /** See {@link HandlerSiteIR}. */
937
+ handlerSite?: HandlerSiteIR;
927
938
  /** How the queue is consumed: `"push"` (a worker `queue()` handler) or `"pull"` (external HTTP). */
928
939
  mode: "pull" | "push";
929
940
  /**
@@ -981,6 +992,43 @@ interface ModuleIR {
981
992
  /** Tables the module declares it owns (`defineModule({ tables })`); empty when it declares none. */
982
993
  tables: ReadonlyArray<string>;
983
994
  }
995
+ /**
996
+ * Who a discovered call site runs on behalf of — the one attribution every
997
+ * per-call-site IR carries (see `discover/attribution`).
998
+ *
999
+ * `export`: lexically inside an exported top-level declaration. `name` is the
1000
+ * EXPORTED name — `export const send = …` → `send`, `export default …` →
1001
+ * `default`, `const run = …; export { run as start }` → `start`.
1002
+ *
1003
+ * `helper`: inside a top-level, non-exported `function` / `const` of the same
1004
+ * file. `callers` are the exports that reach it through same-file value
1005
+ * references (a call, or the helper passed on as a value), transitively and
1006
+ * sorted; a type-only reference (`typeof helper`) does not count. Empty for an
1007
+ * orphan helper no export reaches. `untracked` is set when code attribution
1008
+ * cannot follow — module scope, a class body, a destructured declaration — also
1009
+ * reaches the helper, so `callers` is incomplete.
1010
+ *
1011
+ * `module`: outside every top-level `function` / `const` — module scope, or a
1012
+ * class body.
1013
+ *
1014
+ * A site is recorded once; consumers fan out over its callers. The advisor's
1015
+ * `AdvisorCallSiteScope` is the same type, so feeder rows pass straight through.
1016
+ */
1017
+ type CallSiteScope = AdvisorCallSiteScope;
1018
+ /**
1019
+ * Where a queue or workflow `handler:` passed by reference is declared, when it is
1020
+ * exported from a lunora source file — `defineWorkflow({ handler: onboard })` with
1021
+ * `onboard` exported from `lunora/onboarding/flow.ts` gives
1022
+ * `{ exportName: "onboard", file: "onboarding/flow" }`. The architecture graph
1023
+ * attributes that export's own call sites to the queue or workflow node, so its
1024
+ * calls are not reported as "not a registered function". `exportName` is the
1025
+ * exported name (`export { run as start }` → `start`).
1026
+ */
1027
+ interface HandlerSiteIR {
1028
+ exportName: string;
1029
+ /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1030
+ file: string;
1031
+ }
984
1032
  /**
985
1033
  * A sibling Worker the app calls through a Cloudflare service binding, declared in
986
1034
  * `lunora.config.*` `services` (plan 457). Becomes a wrangler `services[]` entry,
@@ -1054,12 +1102,12 @@ interface FlagsIR {
1054
1102
  * unused-workflow heuristic rather than producing a false positive).
1055
1103
  */
1056
1104
  interface WorkflowCallIR {
1057
- /** Export binding name of the function performing the call, e.g. `create`. */
1058
- exportName: string;
1059
1105
  /** Source file relative to `<projectRoot>/lunora/`, without extension (the api namespace). */
1060
1106
  file: string;
1061
1107
  /** 1-based line of the `get(...)` call. */
1062
1108
  line: number;
1109
+ /** Who the call runs on behalf of. */
1110
+ scope: CallSiteScope;
1063
1111
  /** The referenced workflow export name, or `""` when the argument is not a string literal. */
1064
1112
  workflow: string;
1065
1113
  }
@@ -1071,8 +1119,6 @@ interface WorkflowCallIR {
1071
1119
  * dynamic table — not lintable).
1072
1120
  */
1073
1121
  interface QueryReadIR {
1074
- /** Exported procedure the read sits in, or `""` at module scope. */
1075
- exportName: string;
1076
1122
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1077
1123
  file: string;
1078
1124
  /**
@@ -1088,6 +1134,8 @@ interface QueryReadIR {
1088
1134
  hasIndex: boolean;
1089
1135
  /** 1-based line of the `query(...)` call. */
1090
1136
  line: number;
1137
+ /** Who the read runs on behalf of. */
1138
+ scope: CallSiteScope;
1091
1139
  /** Queried table name, or `""` when the argument is not a string literal. */
1092
1140
  table: string;
1093
1141
  /**
@@ -1111,8 +1159,6 @@ interface QueryReadIR {
1111
1159
  * `AdvisorInsertWrite`.
1112
1160
  */
1113
1161
  interface AuthApiCallIR {
1114
- /** Export binding name of the function performing the call, e.g. "createOrg". */
1115
- exportName: string;
1116
1162
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1117
1163
  file: string;
1118
1164
  /** True when the call's argument object includes a `headers` property. */
@@ -1121,6 +1167,8 @@ interface AuthApiCallIR {
1121
1167
  line: number;
1122
1168
  /** The better-auth method invoked (e.g. `banUser`); empty when not statically known. */
1123
1169
  method: string;
1170
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1171
+ scope: CallSiteScope;
1124
1172
  }
1125
1173
  /**
1126
1174
  * A table write other than a plain `ctx.db.insert(...)` (see {@link InsertWriteIR}):
@@ -1129,15 +1177,18 @@ interface AuthApiCallIR {
1129
1177
  * edges and the `cross_module_table_write` lint.
1130
1178
  */
1131
1179
  interface TableWriteIR {
1132
- /** Export binding name of the function performing the write. */
1133
- exportName: string;
1134
1180
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1135
1181
  file: string;
1136
1182
  /** 1-based line of the call. */
1137
1183
  line: number;
1138
1184
  /** The writer method called, e.g. `patch`, `deleteMany`, `upsert`. */
1139
1185
  method: string;
1140
- /** Target table; `""` when it can't be read (an untyped id, a non-literal name). */
1186
+ /** Who the write runs on behalf of. */
1187
+ scope: CallSiteScope;
1188
+ /**
1189
+ * Target table; `""` when it can't be read (an untyped id, a non-literal
1190
+ * name). A union id (`Id<"a"> | Id<"b">`) gives one record per table.
1191
+ */
1141
1192
  table: string;
1142
1193
  }
1143
1194
  /**
@@ -1148,12 +1199,12 @@ interface TableWriteIR {
1148
1199
  * {@link InsertWriteIR.table} is `""` when the argument is not a string literal.
1149
1200
  */
1150
1201
  interface InsertWriteIR {
1151
- /** Export binding name of the function performing the insert, e.g. "send". */
1152
- exportName: string;
1153
1202
  /** Source file relative to `<projectRoot>/lunora/`, without extension (the api namespace). */
1154
1203
  file: string;
1155
1204
  /** 1-based line of the `insert(...)` call. */
1156
1205
  line: number;
1206
+ /** Who the insert runs on behalf of. */
1207
+ scope: CallSiteScope;
1157
1208
  /** Target table name, or `""` when the argument is not a string literal. */
1158
1209
  table: string;
1159
1210
  }
@@ -1552,12 +1603,12 @@ interface SecretLiteralIR {
1552
1603
  * identical to `AdvisorSqlInterpolation`.
1553
1604
  */
1554
1605
  interface SqlInterpolationIR {
1555
- /** Export binding name of the procedure performing the `ctx.sql` call. */
1556
- exportName: string;
1557
1606
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1558
1607
  file: string;
1559
1608
  /** 1-based line of the interpolation, or `0` when unknown. */
1560
1609
  line: number;
1610
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1611
+ scope: CallSiteScope;
1561
1612
  }
1562
1613
  /**
1563
1614
  * One `ctx.fetch(url, …)` call inside an action whose URL argument is derived
@@ -1569,12 +1620,12 @@ interface SqlInterpolationIR {
1569
1620
  * identical to `AdvisorArgumentDerivedFetch`.
1570
1621
  */
1571
1622
  interface ArgumentDerivedFetchIR {
1572
- /** Export binding name of the action performing the `ctx.fetch` call. */
1573
- exportName: string;
1574
1623
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1575
1624
  file: string;
1576
1625
  /** 1-based line of the `ctx.fetch` call, or `0` when unknown. */
1577
1626
  line: number;
1627
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1628
+ scope: CallSiteScope;
1578
1629
  }
1579
1630
  /**
1580
1631
  * One `ctx.kv.<method>(key, …)` call whose namespace key is derived from the
@@ -1587,14 +1638,14 @@ interface ArgumentDerivedFetchIR {
1587
1638
  * prefix, not a per-entry key). Structurally identical to `AdvisorKvKeyAccess`.
1588
1639
  */
1589
1640
  interface KvKeyAccessIR {
1590
- /** Export binding name of the procedure performing the `ctx.kv` access. */
1591
- exportName: string;
1592
1641
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1593
1642
  file: string;
1594
1643
  /** 1-based line of the `ctx.kv` call, or `0` when unknown. */
1595
1644
  line: number;
1596
1645
  /** The `ctx.kv` method invoked: `get` / `getRaw` / `getWithMetadata` / `put` / `delete`. */
1597
1646
  method: string;
1647
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1648
+ scope: CallSiteScope;
1598
1649
  /**
1599
1650
  * Visibility of the enclosing procedure. `internal` procedures have no
1600
1651
  * untrusted caller by construction — see `owner_field_from_args_not_auth`'s
@@ -1636,8 +1687,6 @@ interface UnrestrictedWhereBranchIR {
1636
1687
  owner: string;
1637
1688
  }
1638
1689
  interface OwnerFieldWriteIR {
1639
- /** Export binding name of the procedure performing the write. */
1640
- exportName: string;
1641
1690
  /** The identity column being written from `args` (e.g. `userId`). */
1642
1691
  field: string;
1643
1692
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
@@ -1663,6 +1712,8 @@ interface OwnerFieldWriteIR {
1663
1712
  * is a real IDOR and stays reportable.
1664
1713
  */
1665
1714
  ownerScoped?: true;
1715
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1716
+ scope: CallSiteScope;
1666
1717
  /**
1667
1718
  * Visibility of the enclosing procedure. `internal` procedures are not
1668
1719
  * reachable by a caller, so the lint's premise ("any caller can write rows
@@ -1683,14 +1734,14 @@ interface OwnerFieldWriteIR {
1683
1734
  * Structurally identical to `AdvisorStorageKeyAccess`.
1684
1735
  */
1685
1736
  interface StorageKeyAccessIR {
1686
- /** Export binding name of the procedure performing the storage call. */
1687
- exportName: string;
1688
1737
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1689
1738
  file: string;
1690
1739
  /** 1-based line of the storage call, or `0` when unknown. */
1691
1740
  line: number;
1692
1741
  /** The bucket method invoked with the arg-derived key, e.g. `get` / `put` / `delete` / `download`. */
1693
1742
  method: string;
1743
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1744
+ scope: CallSiteScope;
1694
1745
  /**
1695
1746
  * Visibility of the enclosing procedure. `internal` procedures have no
1696
1747
  * untrusted caller by construction — see `owner_field_from_args_not_auth`'s
@@ -1712,14 +1763,14 @@ interface StorageKeyAccessIR {
1712
1763
  * identical to `AdvisorContainerKeyAccess`.
1713
1764
  */
1714
1765
  interface ContainerKeyAccessIR {
1715
- /** Export binding name of the procedure performing the `ctx.containers` access. */
1716
- exportName: string;
1717
1766
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1718
1767
  file: string;
1719
1768
  /** 1-based line of the `ctx.containers.*.get` call, or `0` when unknown. */
1720
1769
  line: number;
1721
1770
  /** The container accessor method invoked — always `get`. */
1722
1771
  method: string;
1772
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1773
+ scope: CallSiteScope;
1723
1774
  }
1724
1775
  /**
1725
1776
  * One `ctx.ai.run(model, …)` call whose model-id argument is derived from the handler's
@@ -1732,12 +1783,12 @@ interface ContainerKeyAccessIR {
1732
1783
  * normal usage and is never inspected). Structurally identical to `AdvisorAiRawRun`.
1733
1784
  */
1734
1785
  interface AiRawRunIR {
1735
- /** Export binding name of the procedure performing the `ctx.ai.run` call. */
1736
- exportName: string;
1737
1786
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1738
1787
  file: string;
1739
1788
  /** 1-based line of the `ctx.ai.run` call, or `0` when unknown. */
1740
1789
  line: number;
1790
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1791
+ scope: CallSiteScope;
1741
1792
  }
1742
1793
  /**
1743
1794
  * One `ctx.vectors.<method>(indexName, input)` call whose `input.namespace` is derived
@@ -1750,14 +1801,14 @@ interface AiRawRunIR {
1750
1801
  * here. Structurally identical to `AdvisorVectorNamespaceAccess`.
1751
1802
  */
1752
1803
  interface VectorNamespaceAccessIR {
1753
- /** Export binding name of the procedure performing the `ctx.vectors` access. */
1754
- exportName: string;
1755
1804
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1756
1805
  file: string;
1757
1806
  /** 1-based line of the `ctx.vectors` call, or `0` when unknown. */
1758
1807
  line: number;
1759
1808
  /** The `ctx.vectors` method invoked: `query` / `upsert` / `upsertNow`. */
1760
1809
  method: string;
1810
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1811
+ scope: CallSiteScope;
1761
1812
  }
1762
1813
  /**
1763
1814
  * One `ctx.mail`/`ctx.email` `send`/`queue` call whose recipient field (`to`/`cc`/`bcc`)
@@ -1770,14 +1821,14 @@ interface VectorNamespaceAccessIR {
1770
1821
  * `AdvisorMailRecipientAccess`.
1771
1822
  */
1772
1823
  interface MailRecipientAccessIR {
1773
- /** Export binding name of the procedure performing the `ctx.mail`/`ctx.email` call. */
1774
- exportName: string;
1775
1824
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1776
1825
  file: string;
1777
1826
  /** 1-based line of the `ctx.mail`/`ctx.email` call, or `0` when unknown. */
1778
1827
  line: number;
1779
1828
  /** The mailer method invoked: `send` / `queue`. */
1780
1829
  method: string;
1830
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1831
+ scope: CallSiteScope;
1781
1832
  }
1782
1833
  /**
1783
1834
  * One `ctx.browser.<method>(url, …)` call whose navigation URL (`arguments[0]`)
@@ -1788,14 +1839,14 @@ interface MailRecipientAccessIR {
1788
1839
  * `resolveDns`. Structurally identical to `AdvisorBrowserUrlAccess`.
1789
1840
  */
1790
1841
  interface BrowserUrlAccessIR {
1791
- /** Export binding name of the procedure performing the `ctx.browser` call. */
1792
- exportName: string;
1793
1842
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1794
1843
  file: string;
1795
1844
  /** 1-based line of the `ctx.browser` call, or `0` when unknown. */
1796
1845
  line: number;
1797
1846
  /** The browser method invoked: `content` / `pdf` / `scrape` / `screenshot`. */
1798
1847
  method: string;
1848
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1849
+ scope: CallSiteScope;
1799
1850
  }
1800
1851
  /**
1801
1852
  * One runtime container-override call: a `<handle>.start({ enableInternet: true, … })`
@@ -1809,14 +1860,14 @@ interface BrowserUrlAccessIR {
1809
1860
  interface ContainerOverrideIR {
1810
1861
  /** e.g. the egress method name, or `"enableInternet: true"`. */
1811
1862
  detail: string;
1812
- /** Export binding name of the procedure performing the call. */
1813
- exportName: string;
1814
1863
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1815
1864
  file: string;
1816
1865
  /** Which override shape matched. */
1817
1866
  kind: "egress_relaxation" | "enable_internet";
1818
1867
  /** 1-based line of the call, or `0` when unknown. */
1819
1868
  line: number;
1869
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1870
+ scope: CallSiteScope;
1820
1871
  }
1821
1872
  /**
1822
1873
  * One `buildImageDeliveryUrl({ key, … })` call (`@lunora/bindings/images`) whose
@@ -1832,12 +1883,12 @@ interface ContainerOverrideIR {
1832
1883
  * identical to `AdvisorImageDeliveryUrlAccess`.
1833
1884
  */
1834
1885
  interface ImageDeliveryUrlAccessIR {
1835
- /** Export binding name of the procedure performing the `buildImageDeliveryUrl` call. */
1836
- exportName: string;
1837
1886
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1838
1887
  file: string;
1839
1888
  /** 1-based line of the `buildImageDeliveryUrl` call, or `0` when unknown. */
1840
1889
  line: number;
1890
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1891
+ scope: CallSiteScope;
1841
1892
  }
1842
1893
  /**
1843
1894
  * One `createAuth({...})` call's configuration snapshot — the shared input for
@@ -1858,8 +1909,6 @@ interface AuthConfigIR {
1858
1909
  disableCsrfCheck: boolean;
1859
1910
  /** `emailAndPassword.enabled === true`. */
1860
1911
  emailPasswordEnabled: boolean;
1861
- /** Export binding name enclosing the `createAuth(...)` call. */
1862
- exportName: string;
1863
1912
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1864
1913
  file: string;
1865
1914
  /** 1-based line of the `createAuth(...)` call, or `0` when unknown. */
@@ -1869,6 +1918,8 @@ interface AuthConfigIR {
1869
1918
  /** `trustedOrigins` array literal contains a `"*"` element. */
1870
1919
  /** `plugins` includes `scim(...)` while `database` is a non-transactional Lunora adapter — a combination that throws at runtime. */
1871
1920
  scimOnNonTransactionalAdapter: boolean;
1921
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1922
+ scope: CallSiteScope;
1872
1923
  /** `advanced.useSecureCookies === false`. */
1873
1924
  secureCookiesDisabled: boolean;
1874
1925
  /** `session.freshAge === 0` (explicit literal). */
@@ -1890,14 +1941,14 @@ interface AuthConfigIR {
1890
1941
  interface RatelimitKeySelectorIR {
1891
1942
  /** The `rateLimit`/`dbRateLimit` callee invoked. */
1892
1943
  callee: string;
1893
- /** Export binding name of the procedure whose `.use(...)` chain carries the call. */
1894
- exportName: string;
1895
1944
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1896
1945
  file: string;
1897
1946
  /** The rate limit's `name` argument (the second positional argument), or `""` when not a string literal. */
1898
1947
  limitName: string;
1899
1948
  /** 1-based line of the `rateLimit`/`dbRateLimit` call, or `0` when unknown. */
1900
1949
  line: number;
1950
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1951
+ scope: CallSiteScope;
1901
1952
  }
1902
1953
  /**
1903
1954
  * One payload-derived privileged dispatch — a `ctx.run`/`context.run` back into a
@@ -1915,10 +1966,10 @@ interface PrivilegedDispatchIR {
1915
1966
  dispatchKind: "queue" | "workflow";
1916
1967
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1917
1968
  file: string;
1918
- /** Export binding name of the handler performing the dispatch. */
1919
- handlerExport: string;
1920
1969
  /** 1-based line of the dispatch call, or `0` when unknown. */
1921
1970
  line: number;
1971
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1972
+ scope: CallSiteScope;
1922
1973
  /** Export name of the dispatched target (`send` in `api.messages.send`). */
1923
1974
  targetExport: string;
1924
1975
  /** File path of the dispatched target relative to `lunora/` (`messages` in `api.messages.send`). */
@@ -1959,8 +2010,6 @@ interface StorageUploadIR {
1959
2010
  analyzable: boolean;
1960
2011
  /** Numeric literal value of an `expiresInSeconds` option, when statically known (`getSignedUrl` / `getPresignedUrl` only). */
1961
2012
  expiresInSeconds?: number;
1962
- /** Export binding name of the procedure performing the call. */
1963
- exportName: string;
1964
2013
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1965
2014
  file: string;
1966
2015
  /** 1-based line of the call, or `0` when unknown. */
@@ -1969,6 +2018,8 @@ interface StorageUploadIR {
1969
2018
  method: "generateUploadUrl" | "getPresignedUrl" | "getSignedUrl" | "store" | "upload";
1970
2019
  /** Options-object keys present at the call site (empty when not `analyzable`, or when no options argument was passed). */
1971
2020
  presentKeys: string[];
2021
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2022
+ scope: CallSiteScope;
1972
2023
  }
1973
2024
  /**
1974
2025
  * One discovered `httpAction`/`httpRoute` handler in `lunora/` that performs a
@@ -1982,8 +2033,6 @@ interface StorageUploadIR {
1982
2033
  * `AdvisorHttpActionGuard`.
1983
2034
  */
1984
2035
  interface HttpActionGuardIR {
1985
- /** Export binding name of the handler (or `"<module>"` when mounted inline / not a named binding). */
1986
- exportName: string;
1987
2036
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1988
2037
  file: string;
1989
2038
  /** Which HTTP surface the handler is: a raw `httpAction` or a typed `httpRoute` route. */
@@ -1994,6 +2043,8 @@ interface HttpActionGuardIR {
1994
2043
  method?: string;
1995
2044
  /** `true` when the handler reads `ctx.auth` (a direct member access or a `const { auth } = ctx` destructure). */
1996
2045
  readsAuth: boolean;
2046
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2047
+ scope: CallSiteScope;
1997
2048
  /** The first side effect found, as a stable label: `runMutation`, `runAction`, or `db.<method>`. */
1998
2049
  sideEffect: string;
1999
2050
  }
@@ -2012,14 +2063,14 @@ interface HttpActionGuardIR {
2012
2063
  * identical to `AdvisorHttpHeaderWrite`.
2013
2064
  */
2014
2065
  interface HttpHeaderWriteIR {
2015
- /** Export binding name of the enclosing handler, or `"<module>"` when mounted inline. */
2016
- exportName: string;
2017
2066
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2018
2067
  file: string;
2019
2068
  /** The header name being written (`"location"`), or `""` when the key is not a string literal. */
2020
2069
  headerName: string;
2021
2070
  /** 1-based line of the request-tainted header value. */
2022
2071
  line: number;
2072
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2073
+ scope: CallSiteScope;
2023
2074
  /** How the header was written. */
2024
2075
  via: "headers-append" | "headers-ctor" | "headers-set" | "response-init";
2025
2076
  }
@@ -2037,8 +2088,6 @@ interface HttpHeaderWriteIR {
2037
2088
  interface FailOpenGuardIR {
2038
2089
  /** The middleware factory at the call site: `rateLimit` / `dbRateLimit` / `verifyTurnstileMiddleware`. */
2039
2090
  callee: string;
2040
- /** Export binding name of the procedure the guard is attached to, or `"<module>"` at file scope. */
2041
- exportName: string;
2042
2091
  /** `true` only when the options literal set `failOpen: true` as a boolean literal; a non-literal or absent option is treated as fail-closed. */
2043
2092
  failOpen: boolean;
2044
2093
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
@@ -2047,6 +2096,8 @@ interface FailOpenGuardIR {
2047
2096
  limitName: string;
2048
2097
  /** 1-based line of the middleware call, or `0` when unknown. */
2049
2098
  line: number;
2099
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2100
+ scope: CallSiteScope;
2050
2101
  }
2051
2102
  /**
2052
2103
  * One `ctx.flags.boolean("key", <boolean-literal>)` read in `lunora/` — the
@@ -2060,14 +2111,14 @@ interface FailOpenGuardIR {
2060
2111
  interface FlagSecurityDefaultIR {
2061
2112
  /** The boolean-literal default returned on a provider outage (fail-open value). */
2062
2113
  defaultValue: boolean;
2063
- /** Export binding name of the procedure performing the flag read, or `"<module>"` at file scope. */
2064
- exportName: string;
2065
2114
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2066
2115
  file: string;
2067
2116
  /** The flag key — the first string-literal argument of `ctx.flags.boolean`. */
2068
2117
  key: string;
2069
2118
  /** 1-based line of the `ctx.flags.boolean` call, or `0` when unknown. */
2070
2119
  line: number;
2120
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2121
+ scope: CallSiteScope;
2071
2122
  }
2072
2123
  /**
2073
2124
  * One `ctx.flags` read lexically inside a `query(...)` handler — the
@@ -2101,14 +2152,14 @@ interface FlagReadIR {
2101
2152
  * Structurally identical to `AdvisorAiToolSideEffect`.
2102
2153
  */
2103
2154
  interface AiToolSideEffectIR {
2104
- /** Export binding name of the procedure performing the call. */
2105
- exportName: string;
2106
2155
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2107
2156
  file: string;
2108
2157
  /** 1-based line of the generation call, or `0` when unknown. */
2109
2158
  line: number;
2110
2159
  /** The generation entrypoint invoked. */
2111
2160
  method: "generateText" | "streamText";
2161
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2162
+ scope: CallSiteScope;
2112
2163
  /** The privileged side-effect sink a model-callable tool reaches (`ctx.db.insert`, `ctx.run`, `ctx.fetch`, …). */
2113
2164
  sideEffect: string;
2114
2165
  /** `true` when a model-input option is derived from the handler's `args` (a bare `args.x`, or a name destructured from `args`). */
@@ -2125,14 +2176,14 @@ interface AiToolSideEffectIR {
2125
2176
  interface IdentityClaimReadIR {
2126
2177
  /** `true` when `key` is a declared claim (in the `defineIdentity` contract, or the always-present `userId`). */
2127
2178
  declared: boolean;
2128
- /** Export binding name of the enclosing declaration (`<module>` at file scope). */
2129
- exportName: string;
2130
2179
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2131
2180
  file: string;
2132
2181
  /** The claim key read off the identity bag. */
2133
2182
  key: string;
2134
2183
  /** 1-based line of the read, or `0` when unknown. */
2135
2184
  line: number;
2185
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2186
+ scope: CallSiteScope;
2136
2187
  }
2137
2188
  /**
2138
2189
  * One payment webhook-adapter construction in `lunora/` (`createStripeAdapter` /
@@ -2145,12 +2196,12 @@ interface IdentityClaimReadIR {
2145
2196
  interface PaymentWebhookIR {
2146
2197
  /** The adapter factory invoked. */
2147
2198
  callee: "createAutumnAdapter" | "createDodoPaymentsAdapter" | "createPolarAdapter" | "createStripeAdapter";
2148
- /** Export binding name of the enclosing declaration (`<module>` at file scope). */
2149
- exportName: string;
2150
2199
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2151
2200
  file: string;
2152
2201
  /** 1-based line of the construction, or `0` when unknown. */
2153
2202
  line: number;
2203
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2204
+ scope: CallSiteScope;
2154
2205
  /** Statically-known `webhookToleranceSeconds` literal, when present and a plain numeric literal. */
2155
2206
  toleranceSeconds?: number;
2156
2207
  }
@@ -3184,8 +3235,7 @@ declare const discoverAgents: (project: Project, lunoraDirectory: string) => Age
3184
3235
  declare const listLunoraSourceFiles: (directory: string) => string[];
3185
3236
  /**
3186
3237
  * Discover `ctx.authApi.<method>(...)` (and bare `authApi.<method>(...)`) calls
3187
- * under the lunora source directory and attribute each to the exported function
3188
- * (and file) performing it. Calls outside an exported declaration are dropped.
3238
+ * under the lunora source directory, each with its `CallSiteScope`.
3189
3239
  */
3190
3240
  declare const discoverAuthApiCalls: (project: Project, lunoraDirectory: string) => AuthApiCallIR[];
3191
3241
  /** The only file containers may be declared in — mirrors `lunora/crons.ts`. */
@@ -3244,10 +3294,11 @@ declare const discoverHttpRoutes: (project: Project, lunoraDirectory: string) =>
3244
3294
  */
3245
3295
  declare const discoverHyperdriveCalls: (project: Project, lunoraDirectory: string) => ContextPropertyCallIR[];
3246
3296
  /**
3247
- * Discover `ctx.db.insert("table", …)` writes under the lunora source directory
3248
- * and attribute each to the exported function (and file) performing it. Calls
3249
- * with a non-literal table argument, or outside an exported declaration, are
3250
- * dropped (`table === ""` / no enclosing export).
3297
+ * Discover `ctx.db.insert("table", …)` writes under the lunora source directory,
3298
+ * one record per call site with its `CallSiteScope` — so an insert inside a
3299
+ * same-file helper carries the exports calling the helper, and one in a helper
3300
+ * no export calls is kept rather than lost. A non-literal table argument is kept
3301
+ * with `table: ""`.
3251
3302
  */
3252
3303
  declare const discoverInserts: (project: Project, lunoraDirectory: string) => InsertWriteIR[];
3253
3304
  /**
@@ -3330,7 +3381,8 @@ declare const discoverNotifyConfig: (project: Project, lunoraDirectory: string)
3330
3381
  declare const readPackageDependencies: (projectRoot: string) => Set<string> | undefined;
3331
3382
  /**
3332
3383
  * Discover every `ctx.db.query("table")…` read under the lunora source directory
3333
- * and reduce each to a {@link QueryReadIR}.
3384
+ * and reduce each to a {@link QueryReadIR}, one per read site with its
3385
+ * `CallSiteScope`.
3334
3386
  *
3335
3387
  * Reads without a `.filter()` are kept too. They are never
3336
3388
  * `filter_without_index` candidates (that lint gates on `hasFilter`), but an
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as s}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as l,errorAdvisoryNames as n,errorPlatformDiagnosticNames as c,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-DFsutD7g.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-D8SgT3OR.mjs";import{listLunoraSourceFiles as R}from"./packem_shared/listLunoraSourceFiles-CSlcBYlo.mjs";import{default as _}from"./packem_shared/discoverAuthApiCalls-DoSN_yc3.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-C13yKxas.mjs";import{default as F}from"./packem_shared/discoverCrons-BEALHx1S.mjs";import{capabilitiesUsedBy as D,foldCapabilitySignals as b,mayReadCapabilityContext as U,sourceCapabilitySignals as y}from"./packem_shared/capabilitiesUsedBy-DqrbgTKV.mjs";import{FLAGS_FILENAME as H,discoverFlags as j}from"./packem_shared/FLAGS_FILENAME-W5XQz_Po.mjs";import{default as k}from"./packem_shared/discoverFunctions-BcBzcG5x.mjs";import{default as K}from"./packem_shared/discoverHttpRoutes-CJHS4llq.mjs";import{default as z}from"./packem_shared/discoverHyperdriveCalls-Bkbh4tG7.mjs";import{default as q}from"./packem_shared/discoverInserts-DpuLYPPd.mjs";import{d as J}from"./packem_shared/index-D7dKfGPh.mjs";import{default as X}from"./packem_shared/discoverMigrations-Dt7ywfZv.mjs";import{MUTATORS_FILENAME as $,discoverMutators as ee}from"./packem_shared/MUTATORS_FILENAME-DqWOgC5Z.mjs";import{default as oe}from"./packem_shared/discoverNondeterministicCalls-CNJV2BiP.mjs";import{NOTIFY_FILENAME as ae,discoverNotifyCalls as se,discoverNotifyConfig as ie}from"./packem_shared/NOTIFY_FILENAME-C1J_47et.mjs";import{default as fe}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{default as pe}from"./packem_shared/discoverQueries-BcdqjYky.mjs";import{QUEUES_FILENAME as ne,discoverQueues as ce}from"./packem_shared/QUEUES_FILENAME-RGwht3Xu.mjs";import{default as Se}from"./packem_shared/discoverR2sqlCalls-30Wtbc0P.mjs";import{default as ue}from"./packem_shared/discoverRlsProcedures-F4Cy-kSi.mjs";import{default as ve}from"./packem_shared/discoverRlsMetadata-mXBmPOGj.mjs";import{discoverSandboxUsage as Ce}from"./packem_shared/discoverSandboxUsage-DC6q7rZy.mjs";import{default as Oe}from"./packem_shared/discoverSchema-D5R60b4F.mjs";import{readServiceBindings as Te,resolveServiceBindings as _e}from"./packem_shared/readServiceBindings-CeQvSswr.mjs";import{SHAPES_FILENAME as Le,discoverShapes as Me}from"./packem_shared/SHAPES_FILENAME-DRUFomCj.mjs";import{default as Fe}from"./packem_shared/discoverStorageRulesMetadata-D3Ot9g5f.mjs";import{WORKFLOWS_FILENAME as De,discoverWorkflows as be}from"./packem_shared/WORKFLOWS_FILENAME-4-ib4HH-.mjs";import{emitApp as ye}from"./packem_shared/emitApp-0rC4g46B.mjs";import{isD1GlobalTable as He,isHyperdriveGlobalTable as je}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as ke,emitOpenApi as We,emitOpenApiModule as Ke}from"./packem_shared/buildOpenApiDocument-SxfElVzK.mjs";import{OPENRPC_VERSION as ze,buildOpenRpcDocument as Qe,emitOpenRpc as qe,emitOpenRpcModule as we}from"./packem_shared/OPENRPC_VERSION-Cr7Zzp6s.mjs";import{DEFAULT_TARGET as Ye,platformMatrixIds as Xe,readProjectTarget as Ze,resolveCodegenTarget as $e}from"./packem_shared/DEFAULT_TARGET-Co7ZXJ21.mjs";import{loadProjectConfig as rr,readProjectConfigLiterals as or}from"./packem_shared/loadProjectConfig-nNIDOrlR.mjs";import{SCHEMA_SNAPSHOT_FILENAME as ar,createCodegenProject as sr,findTsconfig as ir,refreshCodegenProject as mr,runCodegen as fr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-D0ZAEgkE.mjs";import{SchemaSnapshotParseError as pr,buildSchemaSnapshot as lr,evaluateSchemaDrift as nr,parseSchemaSnapshot as cr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as Sr}from"./packem_shared/fingerprintSchemaSources-Cl1CJFeh.mjs";import{schemaFromIr as ur}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as vr,validatorIrToJsonSchema as gr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Nr,SDK_TARGETS as Or,generateSdk as Rr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as _r,secretKindOf as Ir}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Mr}from"./packem_shared/emitDrizzleSchema-Cv0HtLR3.mjs";import{default as Fr}from"./packem_shared/emitFunctions-BgNeOZt_.mjs";import{default as Dr}from"./packem_shared/emitServer-mdlKhXYb.mjs";import{e as Ur}from"./packem_shared/shard-Do57J5-c.mjs";import{G as Gr}from"./packem_shared/shared-DjUziztz.mjs";import{MESSAGE_SOLUTIONS as jr,findSolutionByMessage as Br}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Wr,findProjectConfigFile as Kr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{s as zr,t as Qr,u as qr}from"./packem_shared/shard-runtime-B8rucwkF.mjs";import{emitApi as Jr,emitCollections as Yr}from"./packem_shared/emitApi-DdW9RyGG.mjs";import{emitCrons as Zr,emitScheduler as $r,emitVectors as eo,emitWranglerCronTriggers as ro}from"./packem_shared/emitCrons-BRKXFGFu.mjs";import{emitDataModel as to}from"./packem_shared/emitDataModel-D3WuEZ4b.mjs";import{isTypedSchema as so}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,Ye as DEFAULT_TARGET,H as FLAGS_FILENAME,Gr as GENERATED_HEADER,vr as LUNORA_ERROR_CODES,jr as LUNORA_SOLUTION_RULES,$ as MUTATORS_FILENAME,ae as NOTIFY_FILENAME,ze as OPENRPC_VERSION,Wr as PROJECT_CONFIG_FILENAMES,ne as QUEUES_FILENAME,ar as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Nr as SDK_LANGUAGES,Or as SDK_TARGETS,Le as SHAPES_FILENAME,pr as SchemaSnapshotParseError,e as VERSION,De as WORKFLOWS_FILENAME,ke as buildOpenApiDocument,Qe as buildOpenRpcDocument,lr as buildSchemaSnapshot,D as capabilitiesUsedBy,sr as createCodegenProject,l as describeErrorLevelFindings,v as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,_ as discoverAuthApiCalls,M as discoverContainers,F as discoverCrons,j as discoverFlags,k as discoverFunctions,K as discoverHttpRoutes,z as discoverHyperdriveCalls,q as discoverInserts,J as discoverMaskProcedures,X as discoverMigrations,ee as discoverMutators,oe as discoverNondeterministicCalls,se as discoverNotifyCalls,ie as discoverNotifyConfig,pe as discoverQueries,ce as discoverQueues,Se as discoverR2sqlCalls,ve as discoverRlsMetadata,ue as discoverRlsProcedures,Ce as discoverSandboxUsage,Oe as discoverSchema,Me as discoverShapes,Fe as discoverStorageRulesMetadata,be as discoverWorkflows,zr as emitAgents,Jr as emitApi,ye as emitApp,Yr as emitCollections,Qr as emitContainers,Zr as emitCrons,to as emitDataModel,Mr as emitDrizzleSchema,Fr as emitFunctions,We as emitOpenApi,Ke as emitOpenApiModule,qe as emitOpenRpc,we as emitOpenRpcModule,$r as emitScheduler,Dr as emitServer,Ur as emitShard,eo as emitVectors,qr as emitWorkflows,ro as emitWranglerCronTriggers,n as errorAdvisoryNames,c as errorPlatformDiagnosticNames,nr as evaluateSchemaDrift,Br as findLunoraSolution,Kr as findProjectConfigFile,ir as findTsconfig,Sr as fingerprintSchemaSources,b as foldCapabilitySignals,m as formatAdvisories,Rr as generateSdk,He as isD1GlobalTable,je as isHyperdriveGlobalTable,so as isTypedSchema,f as lintSchema,R as listLunoraSourceFiles,rr as loadProjectConfig,U as mayReadCapabilityContext,cr as parseSchemaSnapshot,Xe as platformMatrixIds,fe as readPackageDependencies,or as readProjectConfigLiterals,Ze as readProjectTarget,Te as readServiceBindings,_r as redact,mr as refreshCodegenProject,$e as resolveCodegenTarget,_e as resolveServiceBindings,fr as runCodegen,ur as schemaFromIr,Ir as secretKindOf,s as serializeSchemaSnapshot,x as sortedUniqueNames,y as sourceCapabilitySignals,d as toAdvisorContext,gr as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as s}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as l,errorAdvisoryNames as n,errorPlatformDiagnosticNames as c,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-DFsutD7g.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-D0fmyQlq.mjs";import{listLunoraSourceFiles as R}from"./packem_shared/listLunoraSourceFiles-jTik1QWu.mjs";import{default as _}from"./packem_shared/discoverAuthApiCalls-CEL1n0I0.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-C2wrJ9hF.mjs";import{default as F}from"./packem_shared/discoverCrons-BcrneOpi.mjs";import{capabilitiesUsedBy as D,foldCapabilitySignals as b,mayReadCapabilityContext as U,sourceCapabilitySignals as y}from"./packem_shared/capabilitiesUsedBy-DLv5b8Ss.mjs";import{FLAGS_FILENAME as H,discoverFlags as j}from"./packem_shared/FLAGS_FILENAME-C1tAv68t.mjs";import{default as k}from"./packem_shared/discoverFunctions-TvTtRhvv.mjs";import{default as K}from"./packem_shared/discoverHttpRoutes-BdaGy42T.mjs";import{default as z}from"./packem_shared/discoverHyperdriveCalls-CDm53WpH.mjs";import{default as q}from"./packem_shared/discoverInserts-B2MLcH9M.mjs";import{d as J}from"./packem_shared/index-CpnWNNMK.mjs";import{default as X}from"./packem_shared/discoverMigrations-jUmsOO70.mjs";import{MUTATORS_FILENAME as $,discoverMutators as ee}from"./packem_shared/MUTATORS_FILENAME-CDYDr1iG.mjs";import{default as oe}from"./packem_shared/discoverNondeterministicCalls-BJzH9mEn.mjs";import{NOTIFY_FILENAME as ae,discoverNotifyCalls as se,discoverNotifyConfig as ie}from"./packem_shared/NOTIFY_FILENAME-Dmylk3YO.mjs";import{default as fe}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{default as pe}from"./packem_shared/discoverQueries-B4enrT1h.mjs";import{QUEUES_FILENAME as ne,discoverQueues as ce}from"./packem_shared/QUEUES_FILENAME-CQXsARur.mjs";import{default as Se}from"./packem_shared/discoverR2sqlCalls-BgbXtbva.mjs";import{default as ue}from"./packem_shared/discoverRlsProcedures-DY5xYy7C.mjs";import{default as ve}from"./packem_shared/discoverRlsMetadata-DewerjgN.mjs";import{discoverSandboxUsage as Ce}from"./packem_shared/discoverSandboxUsage-CJPFsjOS.mjs";import{default as Oe}from"./packem_shared/discoverSchema-DPRQni-9.mjs";import{readServiceBindings as Te,resolveServiceBindings as _e}from"./packem_shared/readServiceBindings-B_M_ZvhO.mjs";import{SHAPES_FILENAME as Le,discoverShapes as Me}from"./packem_shared/SHAPES_FILENAME-CNUAxXo3.mjs";import{default as Fe}from"./packem_shared/discoverStorageRulesMetadata-DnVGPbZl.mjs";import{WORKFLOWS_FILENAME as De,discoverWorkflows as be}from"./packem_shared/WORKFLOWS_FILENAME-DrRu8060.mjs";import{emitApp as ye}from"./packem_shared/emitApp-0rC4g46B.mjs";import{isD1GlobalTable as He,isHyperdriveGlobalTable as je}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as ke,emitOpenApi as We,emitOpenApiModule as Ke}from"./packem_shared/buildOpenApiDocument-DZMRzaEx.mjs";import{OPENRPC_VERSION as ze,buildOpenRpcDocument as Qe,emitOpenRpc as qe,emitOpenRpcModule as we}from"./packem_shared/OPENRPC_VERSION-LZowDAOS.mjs";import{DEFAULT_TARGET as Ye,platformMatrixIds as Xe,readProjectTarget as Ze,resolveCodegenTarget as $e}from"./packem_shared/DEFAULT_TARGET-D5J5j3CW.mjs";import{loadProjectConfig as rr,readProjectConfigLiterals as or}from"./packem_shared/loadProjectConfig-D_pUUrhQ.mjs";import{SCHEMA_SNAPSHOT_FILENAME as ar,createCodegenProject as sr,findTsconfig as ir,refreshCodegenProject as mr,runCodegen as fr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-CYrLeST3.mjs";import{SchemaSnapshotParseError as pr,buildSchemaSnapshot as lr,evaluateSchemaDrift as nr,parseSchemaSnapshot as cr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as Sr}from"./packem_shared/fingerprintSchemaSources-D5z-pfpY.mjs";import{schemaFromIr as ur}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as vr,validatorIrToJsonSchema as gr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Nr,SDK_TARGETS as Or,generateSdk as Rr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as _r,secretKindOf as Ir}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Mr}from"./packem_shared/emitDrizzleSchema-Cv0HtLR3.mjs";import{default as Fr}from"./packem_shared/emitFunctions-BgNeOZt_.mjs";import{default as Dr}from"./packem_shared/emitServer-mdlKhXYb.mjs";import{e as Ur}from"./packem_shared/shard-B2AqdAuz.mjs";import{G as Gr}from"./packem_shared/shared-DjUziztz.mjs";import{MESSAGE_SOLUTIONS as jr,findSolutionByMessage as Br}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Wr,findProjectConfigFile as Kr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{s as zr,t as Qr,u as qr}from"./packem_shared/shard-runtime-B8rucwkF.mjs";import{emitApi as Jr,emitCollections as Yr}from"./packem_shared/emitApi-DdW9RyGG.mjs";import{emitCrons as Zr,emitScheduler as $r,emitVectors as eo,emitWranglerCronTriggers as ro}from"./packem_shared/emitCrons-BRKXFGFu.mjs";import{emitDataModel as to}from"./packem_shared/emitDataModel-D3WuEZ4b.mjs";import{isTypedSchema as so}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,Ye as DEFAULT_TARGET,H as FLAGS_FILENAME,Gr as GENERATED_HEADER,vr as LUNORA_ERROR_CODES,jr as LUNORA_SOLUTION_RULES,$ as MUTATORS_FILENAME,ae as NOTIFY_FILENAME,ze as OPENRPC_VERSION,Wr as PROJECT_CONFIG_FILENAMES,ne as QUEUES_FILENAME,ar as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Nr as SDK_LANGUAGES,Or as SDK_TARGETS,Le as SHAPES_FILENAME,pr as SchemaSnapshotParseError,e as VERSION,De as WORKFLOWS_FILENAME,ke as buildOpenApiDocument,Qe as buildOpenRpcDocument,lr as buildSchemaSnapshot,D as capabilitiesUsedBy,sr as createCodegenProject,l as describeErrorLevelFindings,v as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,_ as discoverAuthApiCalls,M as discoverContainers,F as discoverCrons,j as discoverFlags,k as discoverFunctions,K as discoverHttpRoutes,z as discoverHyperdriveCalls,q as discoverInserts,J as discoverMaskProcedures,X as discoverMigrations,ee as discoverMutators,oe as discoverNondeterministicCalls,se as discoverNotifyCalls,ie as discoverNotifyConfig,pe as discoverQueries,ce as discoverQueues,Se as discoverR2sqlCalls,ve as discoverRlsMetadata,ue as discoverRlsProcedures,Ce as discoverSandboxUsage,Oe as discoverSchema,Me as discoverShapes,Fe as discoverStorageRulesMetadata,be as discoverWorkflows,zr as emitAgents,Jr as emitApi,ye as emitApp,Yr as emitCollections,Qr as emitContainers,Zr as emitCrons,to as emitDataModel,Mr as emitDrizzleSchema,Fr as emitFunctions,We as emitOpenApi,Ke as emitOpenApiModule,qe as emitOpenRpc,we as emitOpenRpcModule,$r as emitScheduler,Dr as emitServer,Ur as emitShard,eo as emitVectors,qr as emitWorkflows,ro as emitWranglerCronTriggers,n as errorAdvisoryNames,c as errorPlatformDiagnosticNames,nr as evaluateSchemaDrift,Br as findLunoraSolution,Kr as findProjectConfigFile,ir as findTsconfig,Sr as fingerprintSchemaSources,b as foldCapabilitySignals,m as formatAdvisories,Rr as generateSdk,He as isD1GlobalTable,je as isHyperdriveGlobalTable,so as isTypedSchema,f as lintSchema,R as listLunoraSourceFiles,rr as loadProjectConfig,U as mayReadCapabilityContext,cr as parseSchemaSnapshot,Xe as platformMatrixIds,fe as readPackageDependencies,or as readProjectConfigLiterals,Ze as readProjectTarget,Te as readServiceBindings,_r as redact,mr as refreshCodegenProject,$e as resolveCodegenTarget,_e as resolveServiceBindings,fr as runCodegen,ur as schemaFromIr,Ir as secretKindOf,s as serializeSchemaSnapshot,x as sortedUniqueNames,y as sourceCapabilitySignals,d as toAdvisorContext,gr as validatorIrToJsonSchema};
@@ -1 +1 @@
1
- import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as m}from"@lunora/errors";import{Node as s,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as w}from"./listLunoraSourceFiles-CSlcBYlo.mjs";const h="agents.ts",E=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const t of n.getDeclarations())if(s.isImportSpecifier(t))return t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:t.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),v=(o,n,t)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${t}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},T=(o,n)=>{const t=o.getArguments()[0];if(!t||!s.isObjectLiteralExpression(t))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const e={className:b(n),exportName:n,name:d(n)},i=c(t,"name");i&&s.isPropertyAssignment(i)&&(e.name=P(i.getInitializerOrThrow(),n,"name"));const r=c(t,"publicRun");r&&s.isPropertyAssignment(r)&&v(r.getInitializerOrThrow(),n,"publicRun")&&(e.publicRun=!0);const a=c(t,"voice");if(a&&s.isPropertyAssignment(a)){const g=a.getInitializerOrThrow();if(!s.isObjectLiteralExpression(g))throw l(g,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);e.voice=!0,e.voiceBindingName=N(n),e.voiceClassName=y(n)}return c(t,"onEmail")&&(e.onEmail=!0),e},I=o=>{const n=[];for(const t of o.getVariableDeclarations()){if(!t.isExported())continue;const e=A(t.getInitializer());if(!e)continue;const i=e.getExpression();if(!s.isIdentifier(i)||!E(i))continue;const r=t.getNameNode();if(!s.isIdentifier(r))throw l(r,"defineAgent exports must be plain named exports (no destructuring)");n.push(T(e,r.getText()))}return n},x=o=>{const n=new Map,t=new Map;for(const e of o){const i=n.get(e.name);if(i!==void 0)throw new m("DUPLICATE_AGENT_NAME",`Duplicate agent name "${e.name}": produced by both "${i}" and "${e.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(e.name,e.exportName);const r=t.get(e.className);if(r!==void 0)throw new m("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${e.className}": produced by both "${r}" and "${e.exportName}". Agent export names must yield unique generated class names.`,{status:500});t.set(e.className,e.exportName)}},O=(o,n)=>{const t=f(n,h);if(!p(t))return[];const e=o.getSourceFile(t)??o.addSourceFileAtPath(t),i=I(e);return i.sort((r,a)=>r.exportName.localeCompare(a.exportName)),x(i),i};export{h as AGENTS_FILENAME,O as discoverAgents};
1
+ import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as m}from"@lunora/errors";import{Node as s,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as w}from"./listLunoraSourceFiles-jTik1QWu.mjs";const h="agents.ts",E=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const t of n.getDeclarations())if(s.isImportSpecifier(t))return t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:t.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),v=(o,n,t)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${t}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},T=(o,n)=>{const t=o.getArguments()[0];if(!t||!s.isObjectLiteralExpression(t))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const e={className:b(n),exportName:n,name:d(n)},i=c(t,"name");i&&s.isPropertyAssignment(i)&&(e.name=P(i.getInitializerOrThrow(),n,"name"));const r=c(t,"publicRun");r&&s.isPropertyAssignment(r)&&v(r.getInitializerOrThrow(),n,"publicRun")&&(e.publicRun=!0);const a=c(t,"voice");if(a&&s.isPropertyAssignment(a)){const g=a.getInitializerOrThrow();if(!s.isObjectLiteralExpression(g))throw l(g,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);e.voice=!0,e.voiceBindingName=N(n),e.voiceClassName=y(n)}return c(t,"onEmail")&&(e.onEmail=!0),e},I=o=>{const n=[];for(const t of o.getVariableDeclarations()){if(!t.isExported())continue;const e=A(t.getInitializer());if(!e)continue;const i=e.getExpression();if(!s.isIdentifier(i)||!E(i))continue;const r=t.getNameNode();if(!s.isIdentifier(r))throw l(r,"defineAgent exports must be plain named exports (no destructuring)");n.push(T(e,r.getText()))}return n},x=o=>{const n=new Map,t=new Map;for(const e of o){const i=n.get(e.name);if(i!==void 0)throw new m("DUPLICATE_AGENT_NAME",`Duplicate agent name "${e.name}": produced by both "${i}" and "${e.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(e.name,e.exportName);const r=t.get(e.className);if(r!==void 0)throw new m("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${e.className}": produced by both "${r}" and "${e.exportName}". Agent export names must yield unique generated class names.`,{status:500});t.set(e.className,e.exportName)}},O=(o,n)=>{const t=f(n,h);if(!p(t))return[];const e=o.getSourceFile(t)??o.addSourceFileAtPath(t),i=I(e);return i.sort((r,a)=>r.exportName.localeCompare(a.exportName)),x(i),i};export{h as AGENTS_FILENAME,O as discoverAgents};