@lunora/codegen 1.0.0-alpha.253 → 1.0.0-alpha.254

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext, AdvisorProcedureProtection } from '@lunora/advisor';
2
2
  export type { Finding } from '@lunora/advisor';
3
- import { SourceFile, Project, Node } from 'ts-morph';
3
+ import { Project, SourceFile, Node } from 'ts-morph';
4
4
  import { LunoraError } from '@lunora/errors';
5
5
  export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
6
6
  import { Schema } from '@lunora/server';
@@ -2644,6 +2644,8 @@ declare const CAPABILITY_ROWS: readonly [{
2644
2644
  readonly key: "payments";
2645
2645
  readonly moduleSpecifier: "@lunora/payment";
2646
2646
  readonly requiredPackage: "@lunora/payment";
2647
+ readonly serverCtxField: "\n readonly payments: import(\"@lunora/payment\").LunoraPayment;";
2648
+ readonly tier: "action";
2647
2649
  }, {
2648
2650
  readonly appMethod: {
2649
2651
  readonly configKey: "x402";
@@ -2709,31 +2711,88 @@ declare const CAPABILITY_ROWS: readonly [{
2709
2711
  }];
2710
2712
  /** The literal union of every capability id — the single source of truth for `FeatureUsage`'s keys (so they cannot drift). */
2711
2713
  type CapabilityKey = (typeof CAPABILITY_ROWS)[number]["key"];
2712
- /**
2713
- * The usage-probe facets of every row, read-only — the view a consumer outside
2714
- * codegen keys its own capability detection off (`@lunora/config`'s binding
2715
- * inference), so the two cannot disagree on which import or `ctx.<property>`
2716
- * read marks a capability used.
2717
- */
2718
- declare const CAPABILITY_PROBES: ReadonlyArray<{
2714
+ /** The usage-probe facets of one row: the package whose value import, and the `ctx.<property>` whose read, marks it used. */
2715
+ interface CapabilityProbe {
2716
+ /** `undefined` for a capability with no ctx helper (`mail`). */
2719
2717
  readonly contextProperty: string | undefined;
2720
- readonly key: CapabilityKey;
2721
2718
  readonly moduleSpecifier: string;
2722
- }>;
2723
- /** The two per-file signals the capability probe reads. */
2719
+ }
2720
+ /**
2721
+ * The usage-probe facets of every row, keyed by capability — the view a consumer
2722
+ * outside codegen reads (`@lunora/config` names a package and words a hint off
2723
+ * it), so a lookup needs no existence check. Which signals mark a capability used
2724
+ * is decided by `capabilitiesUsedBy` alone, never re-derived from these.
2725
+ */
2726
+ declare const CAPABILITY_PROBES: Readonly<Record<CapabilityKey, CapabilityProbe>>;
2727
+ /**
2728
+ * Which sandbox tools a project imports from `@lunora/agent` (main entry or the
2729
+ * `/sandbox` subpath), detected by NAMED value import. Drives two things:
2730
+ * registering the `sandbox:invoke` dispatcher (ANY of the three tools — an agent
2731
+ * whose only sandbox tool was `fsTool` used to be missed here, so every
2732
+ * `ls`/`read`/`write`/`rm`/`stat` died on FUNCTION_NOT_FOUND) and provisioning
2733
+ * the `BROWSER` wrangler binding (`browserTool` only — the browser op runs on
2734
+ * `ctx.browser` inside the dispatcher, while `fsTool` reads a hand-declared R2
2735
+ * bucket). `jsCodeTool` is the exception: it calls the `LOADER` binding off the
2736
+ * tool's own env, so it needs no dispatcher — only the `workerLoaders` gate.
2737
+ */
2738
+ interface SandboxUsage {
2739
+ /** `import { browserTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2740
+ usesSandboxBrowser: boolean;
2741
+ /** `import { containerTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2742
+ usesSandboxContainer: boolean;
2743
+ /** `import { fsTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2744
+ usesSandboxFs: boolean;
2745
+ /** `import { jsCodeTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2746
+ usesSandboxLoader: boolean;
2747
+ }
2748
+ /**
2749
+ * Scan the `lunora/` source set for named imports of the sandbox tools
2750
+ * ({@link TOOL_FLAGS}) from `@lunora/agent` (main entry or the `/sandbox`
2751
+ * subpath). Type-only imports (the input/option types) do not count — only a
2752
+ * value import wires a tool into an agent. A project that imports none yields
2753
+ * all-`false` and codegen emits byte-identical output.
2754
+ */
2755
+ declare const discoverSandboxUsage: (project: Project, lunoraDirectory: string) => SandboxUsage;
2756
+ /** The per-file (or folded, per-project) signals the capability probe reads. */
2724
2757
  interface SourceCapabilitySignals {
2725
2758
  /** The `ctx` helper names the file reads — see {@link contextPropertiesRead}. */
2726
2759
  contextReads: ReadonlySet<string>;
2727
- /** Module specifiers of the file's static imports that survive compilation (type-only ones dropped — see {@link isTypeOnlyImport}). */
2760
+ /**
2761
+ * Literal specifiers of the file's dynamic `import("…")` calls. Codegen's own
2762
+ * probe ignores them (it wires a helper off a static import); `@lunora/config`
2763
+ * counts them, since a lazily loaded package needs its binding just the same.
2764
+ */
2765
+ dynamicImports: ReadonlySet<string>;
2766
+ /** The `@lunora/agent` sandbox tools the file value-imports — the same reading as `discoverSandboxUsage`. */
2767
+ sandboxTools: Readonly<SandboxUsage>;
2768
+ /** Module specifiers of the file's static imports and re-exports (`export … from "…"`) that survive compilation — see {@link compilesAway}. */
2728
2769
  valueImports: ReadonlySet<string>;
2729
2770
  }
2730
2771
  /**
2731
- * The capability signals of one source file: its value-import specifiers and its
2772
+ * The capability signals of one source file: its value-import and re-export
2773
+ * specifiers, its dynamic-import specifiers, its sandbox-tool imports and its
2732
2774
  * `ctx.<property>` reads. The single reading behind codegen's usage probe —
2733
- * exported so `@lunora/config`'s binding inference marks a capability used on
2734
- * exactly the same imports and reads (matched against `CAPABILITY_PROBES`).
2775
+ * exported so `@lunora/config`'s binding inference reads the same signals and
2776
+ * judges them with the same {@link capabilitiesUsedBy}.
2735
2777
  */
2736
2778
  declare const sourceCapabilitySignals: (sourceFile: SourceFile) => SourceCapabilitySignals;
2779
+ /** Union per-file signals into one — a capability is used when ANY file in the set uses it. */
2780
+ declare const foldCapabilitySignals: (signals: Iterable<SourceCapabilitySignals>) => SourceCapabilitySignals;
2781
+ /**
2782
+ * The capabilities a set of signals marks as used: a value import (or re-export)
2783
+ * of the row's `moduleSpecifier`, or a read of its `ctx.<contextProperty>`. The
2784
+ * ONE matcher — codegen's usage probe and `@lunora/config`'s binding inference
2785
+ * both call it, so they cannot disagree on what "used" means. Dynamic imports
2786
+ * are not consulted; a caller that counts them merges them into `valueImports`.
2787
+ */
2788
+ declare const capabilitiesUsedBy: (signals: Pick<SourceCapabilitySignals, "contextReads" | "valueImports">) => ReadonlySet<CapabilityKey>;
2789
+ /**
2790
+ * Cheap text prefilter: whether `code` could read a capability's `ctx` helper at
2791
+ * all. Every form {@link contextPropertiesRead} recognises (an access, a
2792
+ * destructure, a renamed context) names the `ctx` property somewhere and names
2793
+ * the helper too, so a file failing this needs no parse for its `ctx` reads.
2794
+ */
2795
+ declare const mayReadCapabilityContext: (code: string) => boolean;
2737
2796
  /** The default codegen target — today's behavior, byte-identical goldens. */
2738
2797
  declare const DEFAULT_TARGET = "cloudflare";
2739
2798
  /**
@@ -3304,35 +3363,6 @@ declare const discoverRlsProcedures: (project: Project, lunoraDirectory: string)
3304
3363
  * several procedures lists once.
3305
3364
  */
3306
3365
  declare const discoverRlsMetadata: (project: Project, lunoraDirectory: string) => RlsMetadataIR;
3307
- /**
3308
- * Which sandbox tools a project imports from `@lunora/agent` (main entry or the
3309
- * `/sandbox` subpath), detected by NAMED value import. Drives two things:
3310
- * registering the `sandbox:invoke` dispatcher (ANY of the three tools — an agent
3311
- * whose only sandbox tool was `fsTool` used to be missed here, so every
3312
- * `ls`/`read`/`write`/`rm`/`stat` died on FUNCTION_NOT_FOUND) and provisioning
3313
- * the `BROWSER` wrangler binding (`browserTool` only — the browser op runs on
3314
- * `ctx.browser` inside the dispatcher, while `fsTool` reads a hand-declared R2
3315
- * bucket). `jsCodeTool` is the exception: it calls the `LOADER` binding off the
3316
- * tool's own env, so it needs no dispatcher — only the `workerLoaders` gate.
3317
- */
3318
- interface SandboxUsage {
3319
- /** `import { browserTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
3320
- usesSandboxBrowser: boolean;
3321
- /** `import { containerTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
3322
- usesSandboxContainer: boolean;
3323
- /** `import { fsTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
3324
- usesSandboxFs: boolean;
3325
- /** `import { jsCodeTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
3326
- usesSandboxLoader: boolean;
3327
- }
3328
- /**
3329
- * Scan the `lunora/` source set for named imports of the sandbox tools
3330
- * ({@link TOOL_FLAGS}) from `@lunora/agent` (main entry or the `/sandbox`
3331
- * subpath). Type-only imports (the input/option types) do not count — only a
3332
- * value import wires a tool into an agent. A project that imports none yields
3333
- * all-`false` and codegen emits byte-identical output.
3334
- */
3335
- declare const discoverSandboxUsage: (project: Project, lunoraDirectory: string) => SandboxUsage;
3336
3366
  /**
3337
3367
  * Load `<projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
3338
3368
  * return a structural IR. Throws if the file or call cannot be found.
@@ -3532,8 +3562,8 @@ interface EmitServerOptions {
3532
3562
  /**
3533
3563
  * The package-backed capabilities the app uses (post platform gate). Each
3534
3564
  * used row of the `CAPABILITIES` table with a `serverCtxField` lands on the
3535
- * ctx interfaces its `tier` names; `payments` gates its bespoke ActionCtx
3536
- * field, and `ai` the `env.AI` binding field, off the same set.
3565
+ * ctx interfaces its `tier` names; `ai` also gates the `env.AI` binding
3566
+ * field off the same set.
3537
3567
  */
3538
3568
  capabilities?: ReadonlySet<CapabilityKey>;
3539
3569
  containers?: ReadonlyArray<ContainerIR>;
@@ -4436,4 +4466,4 @@ declare const secretKindOf: (value: string) => string | undefined;
4436
4466
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
4437
4467
  declare const redact: (value: string) => string;
4438
4468
  declare const VERSION = "0.0.0";
4439
- export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, validatorIrToJsonSchema };
4469
+ export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, validatorIrToJsonSchema };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext, AdvisorProcedureProtection } from '@lunora/advisor';
2
2
  export type { Finding } from '@lunora/advisor';
3
- import { SourceFile, Project, Node } from 'ts-morph';
3
+ import { Project, SourceFile, Node } from 'ts-morph';
4
4
  import { LunoraError } from '@lunora/errors';
5
5
  export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
6
6
  import { Schema } from '@lunora/server';
@@ -2644,6 +2644,8 @@ declare const CAPABILITY_ROWS: readonly [{
2644
2644
  readonly key: "payments";
2645
2645
  readonly moduleSpecifier: "@lunora/payment";
2646
2646
  readonly requiredPackage: "@lunora/payment";
2647
+ readonly serverCtxField: "\n readonly payments: import(\"@lunora/payment\").LunoraPayment;";
2648
+ readonly tier: "action";
2647
2649
  }, {
2648
2650
  readonly appMethod: {
2649
2651
  readonly configKey: "x402";
@@ -2709,31 +2711,88 @@ declare const CAPABILITY_ROWS: readonly [{
2709
2711
  }];
2710
2712
  /** The literal union of every capability id — the single source of truth for `FeatureUsage`'s keys (so they cannot drift). */
2711
2713
  type CapabilityKey = (typeof CAPABILITY_ROWS)[number]["key"];
2712
- /**
2713
- * The usage-probe facets of every row, read-only — the view a consumer outside
2714
- * codegen keys its own capability detection off (`@lunora/config`'s binding
2715
- * inference), so the two cannot disagree on which import or `ctx.<property>`
2716
- * read marks a capability used.
2717
- */
2718
- declare const CAPABILITY_PROBES: ReadonlyArray<{
2714
+ /** The usage-probe facets of one row: the package whose value import, and the `ctx.<property>` whose read, marks it used. */
2715
+ interface CapabilityProbe {
2716
+ /** `undefined` for a capability with no ctx helper (`mail`). */
2719
2717
  readonly contextProperty: string | undefined;
2720
- readonly key: CapabilityKey;
2721
2718
  readonly moduleSpecifier: string;
2722
- }>;
2723
- /** The two per-file signals the capability probe reads. */
2719
+ }
2720
+ /**
2721
+ * The usage-probe facets of every row, keyed by capability — the view a consumer
2722
+ * outside codegen reads (`@lunora/config` names a package and words a hint off
2723
+ * it), so a lookup needs no existence check. Which signals mark a capability used
2724
+ * is decided by `capabilitiesUsedBy` alone, never re-derived from these.
2725
+ */
2726
+ declare const CAPABILITY_PROBES: Readonly<Record<CapabilityKey, CapabilityProbe>>;
2727
+ /**
2728
+ * Which sandbox tools a project imports from `@lunora/agent` (main entry or the
2729
+ * `/sandbox` subpath), detected by NAMED value import. Drives two things:
2730
+ * registering the `sandbox:invoke` dispatcher (ANY of the three tools — an agent
2731
+ * whose only sandbox tool was `fsTool` used to be missed here, so every
2732
+ * `ls`/`read`/`write`/`rm`/`stat` died on FUNCTION_NOT_FOUND) and provisioning
2733
+ * the `BROWSER` wrangler binding (`browserTool` only — the browser op runs on
2734
+ * `ctx.browser` inside the dispatcher, while `fsTool` reads a hand-declared R2
2735
+ * bucket). `jsCodeTool` is the exception: it calls the `LOADER` binding off the
2736
+ * tool's own env, so it needs no dispatcher — only the `workerLoaders` gate.
2737
+ */
2738
+ interface SandboxUsage {
2739
+ /** `import { browserTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2740
+ usesSandboxBrowser: boolean;
2741
+ /** `import { containerTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2742
+ usesSandboxContainer: boolean;
2743
+ /** `import { fsTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2744
+ usesSandboxFs: boolean;
2745
+ /** `import { jsCodeTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2746
+ usesSandboxLoader: boolean;
2747
+ }
2748
+ /**
2749
+ * Scan the `lunora/` source set for named imports of the sandbox tools
2750
+ * ({@link TOOL_FLAGS}) from `@lunora/agent` (main entry or the `/sandbox`
2751
+ * subpath). Type-only imports (the input/option types) do not count — only a
2752
+ * value import wires a tool into an agent. A project that imports none yields
2753
+ * all-`false` and codegen emits byte-identical output.
2754
+ */
2755
+ declare const discoverSandboxUsage: (project: Project, lunoraDirectory: string) => SandboxUsage;
2756
+ /** The per-file (or folded, per-project) signals the capability probe reads. */
2724
2757
  interface SourceCapabilitySignals {
2725
2758
  /** The `ctx` helper names the file reads — see {@link contextPropertiesRead}. */
2726
2759
  contextReads: ReadonlySet<string>;
2727
- /** Module specifiers of the file's static imports that survive compilation (type-only ones dropped — see {@link isTypeOnlyImport}). */
2760
+ /**
2761
+ * Literal specifiers of the file's dynamic `import("…")` calls. Codegen's own
2762
+ * probe ignores them (it wires a helper off a static import); `@lunora/config`
2763
+ * counts them, since a lazily loaded package needs its binding just the same.
2764
+ */
2765
+ dynamicImports: ReadonlySet<string>;
2766
+ /** The `@lunora/agent` sandbox tools the file value-imports — the same reading as `discoverSandboxUsage`. */
2767
+ sandboxTools: Readonly<SandboxUsage>;
2768
+ /** Module specifiers of the file's static imports and re-exports (`export … from "…"`) that survive compilation — see {@link compilesAway}. */
2728
2769
  valueImports: ReadonlySet<string>;
2729
2770
  }
2730
2771
  /**
2731
- * The capability signals of one source file: its value-import specifiers and its
2772
+ * The capability signals of one source file: its value-import and re-export
2773
+ * specifiers, its dynamic-import specifiers, its sandbox-tool imports and its
2732
2774
  * `ctx.<property>` reads. The single reading behind codegen's usage probe —
2733
- * exported so `@lunora/config`'s binding inference marks a capability used on
2734
- * exactly the same imports and reads (matched against `CAPABILITY_PROBES`).
2775
+ * exported so `@lunora/config`'s binding inference reads the same signals and
2776
+ * judges them with the same {@link capabilitiesUsedBy}.
2735
2777
  */
2736
2778
  declare const sourceCapabilitySignals: (sourceFile: SourceFile) => SourceCapabilitySignals;
2779
+ /** Union per-file signals into one — a capability is used when ANY file in the set uses it. */
2780
+ declare const foldCapabilitySignals: (signals: Iterable<SourceCapabilitySignals>) => SourceCapabilitySignals;
2781
+ /**
2782
+ * The capabilities a set of signals marks as used: a value import (or re-export)
2783
+ * of the row's `moduleSpecifier`, or a read of its `ctx.<contextProperty>`. The
2784
+ * ONE matcher — codegen's usage probe and `@lunora/config`'s binding inference
2785
+ * both call it, so they cannot disagree on what "used" means. Dynamic imports
2786
+ * are not consulted; a caller that counts them merges them into `valueImports`.
2787
+ */
2788
+ declare const capabilitiesUsedBy: (signals: Pick<SourceCapabilitySignals, "contextReads" | "valueImports">) => ReadonlySet<CapabilityKey>;
2789
+ /**
2790
+ * Cheap text prefilter: whether `code` could read a capability's `ctx` helper at
2791
+ * all. Every form {@link contextPropertiesRead} recognises (an access, a
2792
+ * destructure, a renamed context) names the `ctx` property somewhere and names
2793
+ * the helper too, so a file failing this needs no parse for its `ctx` reads.
2794
+ */
2795
+ declare const mayReadCapabilityContext: (code: string) => boolean;
2737
2796
  /** The default codegen target — today's behavior, byte-identical goldens. */
2738
2797
  declare const DEFAULT_TARGET = "cloudflare";
2739
2798
  /**
@@ -3304,35 +3363,6 @@ declare const discoverRlsProcedures: (project: Project, lunoraDirectory: string)
3304
3363
  * several procedures lists once.
3305
3364
  */
3306
3365
  declare const discoverRlsMetadata: (project: Project, lunoraDirectory: string) => RlsMetadataIR;
3307
- /**
3308
- * Which sandbox tools a project imports from `@lunora/agent` (main entry or the
3309
- * `/sandbox` subpath), detected by NAMED value import. Drives two things:
3310
- * registering the `sandbox:invoke` dispatcher (ANY of the three tools — an agent
3311
- * whose only sandbox tool was `fsTool` used to be missed here, so every
3312
- * `ls`/`read`/`write`/`rm`/`stat` died on FUNCTION_NOT_FOUND) and provisioning
3313
- * the `BROWSER` wrangler binding (`browserTool` only — the browser op runs on
3314
- * `ctx.browser` inside the dispatcher, while `fsTool` reads a hand-declared R2
3315
- * bucket). `jsCodeTool` is the exception: it calls the `LOADER` binding off the
3316
- * tool's own env, so it needs no dispatcher — only the `workerLoaders` gate.
3317
- */
3318
- interface SandboxUsage {
3319
- /** `import { browserTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
3320
- usesSandboxBrowser: boolean;
3321
- /** `import { containerTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
3322
- usesSandboxContainer: boolean;
3323
- /** `import { fsTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
3324
- usesSandboxFs: boolean;
3325
- /** `import { jsCodeTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
3326
- usesSandboxLoader: boolean;
3327
- }
3328
- /**
3329
- * Scan the `lunora/` source set for named imports of the sandbox tools
3330
- * ({@link TOOL_FLAGS}) from `@lunora/agent` (main entry or the `/sandbox`
3331
- * subpath). Type-only imports (the input/option types) do not count — only a
3332
- * value import wires a tool into an agent. A project that imports none yields
3333
- * all-`false` and codegen emits byte-identical output.
3334
- */
3335
- declare const discoverSandboxUsage: (project: Project, lunoraDirectory: string) => SandboxUsage;
3336
3366
  /**
3337
3367
  * Load `<projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
3338
3368
  * return a structural IR. Throws if the file or call cannot be found.
@@ -3532,8 +3562,8 @@ interface EmitServerOptions {
3532
3562
  /**
3533
3563
  * The package-backed capabilities the app uses (post platform gate). Each
3534
3564
  * used row of the `CAPABILITIES` table with a `serverCtxField` lands on the
3535
- * ctx interfaces its `tier` names; `payments` gates its bespoke ActionCtx
3536
- * field, and `ai` the `env.AI` binding field, off the same set.
3565
+ * ctx interfaces its `tier` names; `ai` also gates the `env.AI` binding
3566
+ * field off the same set.
3537
3567
  */
3538
3568
  capabilities?: ReadonlySet<CapabilityKey>;
3539
3569
  containers?: ReadonlyArray<ContainerIR>;
@@ -4436,4 +4466,4 @@ declare const secretKindOf: (value: string) => string | undefined;
4436
4466
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
4437
4467
  declare const redact: (value: string) => string;
4438
4468
  declare const VERSION = "0.0.0";
4439
- export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, validatorIrToJsonSchema };
4469
+ export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, validatorIrToJsonSchema };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}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 c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-BPeV994T.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as g,discoverAgents as C}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{sourceCapabilitySignals as D}from"./packem_shared/sourceCapabilitySignals-NsxX0VDV.mjs";import{FLAGS_FILENAME as U,discoverFlags as b}from"./packem_shared/FLAGS_FILENAME-W5XQz_Po.mjs";import{default as y}from"./packem_shared/discoverFunctions-BcBzcG5x.mjs";import{default as k}from"./packem_shared/discoverHttpRoutes-CJHS4llq.mjs";import{default as W}from"./packem_shared/discoverHyperdriveCalls-Bkbh4tG7.mjs";import{default as V}from"./packem_shared/discoverInserts-DpuLYPPd.mjs";import{d as Q}from"./packem_shared/index-D7dKfGPh.mjs";import{default as w}from"./packem_shared/discoverMigrations-Dt7ywfZv.mjs";import{MUTATORS_FILENAME as Y,discoverMutators as X}from"./packem_shared/MUTATORS_FILENAME-DqWOgC5Z.mjs";import{default as $}from"./packem_shared/discoverNondeterministicCalls-CNJV2BiP.mjs";import{NOTIFY_FILENAME as re,discoverNotifyCalls as oe,discoverNotifyConfig as te}from"./packem_shared/NOTIFY_FILENAME-C1J_47et.mjs";import{default as ae}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{default as me}from"./packem_shared/discoverQueries-BcdqjYky.mjs";import{QUEUES_FILENAME as de,discoverQueues as pe}from"./packem_shared/QUEUES_FILENAME-RGwht3Xu.mjs";import{default as ne}from"./packem_shared/discoverR2sqlCalls-30Wtbc0P.mjs";import{default as xe}from"./packem_shared/discoverRlsProcedures-F4Cy-kSi.mjs";import{default as Ee}from"./packem_shared/discoverRlsMetadata-mXBmPOGj.mjs";import{discoverSandboxUsage as Ae}from"./packem_shared/discoverSandboxUsage-BnsPld5I.mjs";import{default as Ne}from"./packem_shared/discoverSchema-D5R60b4F.mjs";import{readServiceBindings as Ce,resolveServiceBindings as Oe}from"./packem_shared/readServiceBindings-CeQvSswr.mjs";import{SHAPES_FILENAME as Te,discoverShapes as _e}from"./packem_shared/SHAPES_FILENAME-DRUFomCj.mjs";import{default as Le}from"./packem_shared/discoverStorageRulesMetadata-D3Ot9g5f.mjs";import{WORKFLOWS_FILENAME as he,discoverWorkflows as Fe}from"./packem_shared/WORKFLOWS_FILENAME-4-ib4HH-.mjs";import{emitApp as De}from"./packem_shared/emitApp-CokyctXT.mjs";import{isD1GlobalTable as Ue,isHyperdriveGlobalTable as be}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as ye,emitOpenApi as je,emitOpenApiModule as ke}from"./packem_shared/buildOpenApiDocument-SxfElVzK.mjs";import{OPENRPC_VERSION as We,buildOpenRpcDocument as Ke,emitOpenRpc as Ve,emitOpenRpcModule as ze}from"./packem_shared/OPENRPC_VERSION-Cr7Zzp6s.mjs";import{DEFAULT_TARGET as qe,platformMatrixIds as we,readProjectTarget as Je,resolveCodegenTarget as Ye}from"./packem_shared/DEFAULT_TARGET-Co7ZXJ21.mjs";import{loadProjectConfig as Ze,readProjectConfigLiterals as $e}from"./packem_shared/loadProjectConfig-nNIDOrlR.mjs";import{SCHEMA_SNAPSHOT_FILENAME as rr,createCodegenProject as or,findTsconfig as tr,refreshCodegenProject as sr,runCodegen as ar}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-CVtSBGXP.mjs";import{SchemaSnapshotParseError as mr,buildSchemaSnapshot as fr,evaluateSchemaDrift as dr,parseSchemaSnapshot as pr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as nr}from"./packem_shared/fingerprintSchemaSources-Cl1CJFeh.mjs";import{schemaFromIr as xr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as Er,validatorIrToJsonSchema as ur}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as vr,SDK_TARGETS as Nr,generateSdk as gr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as Or,secretKindOf as Rr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as _r}from"./packem_shared/emitDrizzleSchema-Cv0HtLR3.mjs";import{default as Lr}from"./packem_shared/emitFunctions-BgNeOZt_.mjs";import{default as hr}from"./packem_shared/emitServer-DThb0DLe.mjs";import{e as Pr}from"./packem_shared/shard-CBwweXGB.mjs";import{G as Gr}from"./packem_shared/shared-DjUziztz.mjs";import{MESSAGE_SOLUTIONS as br,findSolutionByMessage as Hr}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as jr,findProjectConfigFile as kr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{s as Wr,t as Kr,u as Vr}from"./packem_shared/shard-runtime-DTSpJxxd.mjs";import{emitApi as Qr,emitCollections as qr}from"./packem_shared/emitApi-DdW9RyGG.mjs";import{emitCrons as Jr,emitScheduler as Yr,emitVectors as Xr,emitWranglerCronTriggers as Zr}from"./packem_shared/emitCrons-BRKXFGFu.mjs";import{emitDataModel as eo}from"./packem_shared/emitDataModel-D3WuEZ4b.mjs";import{isTypedSchema as oo}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{g as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,qe as DEFAULT_TARGET,U as FLAGS_FILENAME,Gr as GENERATED_HEADER,Er as LUNORA_ERROR_CODES,br as LUNORA_SOLUTION_RULES,Y as MUTATORS_FILENAME,re as NOTIFY_FILENAME,We as OPENRPC_VERSION,jr as PROJECT_CONFIG_FILENAMES,de as QUEUES_FILENAME,rr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,vr as SDK_LANGUAGES,Nr as SDK_TARGETS,Te as SHAPES_FILENAME,mr as SchemaSnapshotParseError,e as VERSION,he as WORKFLOWS_FILENAME,ye as buildOpenApiDocument,Ke as buildOpenRpcDocument,fr as buildSchemaSnapshot,or as createCodegenProject,c as describeErrorLevelFindings,v as diagnosticAt,s as diffSchemaSnapshots,C as discoverAgents,_ as discoverAuthApiCalls,M as discoverContainers,F as discoverCrons,b as discoverFlags,y as discoverFunctions,k as discoverHttpRoutes,W as discoverHyperdriveCalls,V as discoverInserts,Q as discoverMaskProcedures,w as discoverMigrations,X as discoverMutators,$ as discoverNondeterministicCalls,oe as discoverNotifyCalls,te as discoverNotifyConfig,me as discoverQueries,pe as discoverQueues,ne as discoverR2sqlCalls,Ee as discoverRlsMetadata,xe as discoverRlsProcedures,Ae as discoverSandboxUsage,Ne as discoverSchema,_e as discoverShapes,Le as discoverStorageRulesMetadata,Fe as discoverWorkflows,Wr as emitAgents,Qr as emitApi,De as emitApp,qr as emitCollections,Kr as emitContainers,Jr as emitCrons,eo as emitDataModel,_r as emitDrizzleSchema,Lr as emitFunctions,je as emitOpenApi,ke as emitOpenApiModule,Ve as emitOpenRpc,ze as emitOpenRpcModule,Yr as emitScheduler,hr as emitServer,Pr as emitShard,Xr as emitVectors,Vr as emitWorkflows,Zr as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,dr as evaluateSchemaDrift,Hr as findLunoraSolution,kr as findProjectConfigFile,tr as findTsconfig,nr as fingerprintSchemaSources,m as formatAdvisories,gr as generateSdk,Ue as isD1GlobalTable,be as isHyperdriveGlobalTable,oo as isTypedSchema,f as lintSchema,R as listLunoraSourceFiles,Ze as loadProjectConfig,pr as parseSchemaSnapshot,we as platformMatrixIds,ae as readPackageDependencies,$e as readProjectConfigLiterals,Je as readProjectTarget,Ce as readServiceBindings,Or as redact,sr as refreshCodegenProject,Ye as resolveCodegenTarget,Oe as resolveServiceBindings,ar as runCodegen,xr as schemaFromIr,Rr as secretKindOf,a as serializeSchemaSnapshot,x as sortedUniqueNames,D as sourceCapabilitySignals,d as toAdvisorContext,ur 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-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};
@@ -14,11 +14,12 @@ const n=[{contextProperty:"access",key:"access",moduleSpecifier:"@lunora/cloudfl
14
14
  readonly sql: import("@lunora/hyperdrive").SqlClient;`,shardBinding:{clientType:"SqlClient",instrument:"instrumentSql",missingMessage:"ctx.sql: provide a `sql` config thunk that builds a SqlClient from your driver, e.g. `sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString))`.",stubMethods:["query"]},tier:"action"},{appMethod:{configKey:"images",doc:"Override the Images binding backing `ctx.images` (defaults to `env.IMAGES`).",method:"images"},contextProperty:"images",key:"images",moduleSpecifier:"@lunora/bindings/images",requiredPackage:"@lunora/bindings",serverCtxField:`
15
15
  /** Cloudflare Images transforms (resize/format/optimize). Non-deterministic — available only in actions. */
16
16
  readonly images: import("@lunora/bindings/images").Images;`,shardBinding:{binding:{bindingType:"ImagesBindingLike",envName:"IMAGES",factory:{name:"createImages",option:"binding"}},clientType:"Images",missingMessage:"ctx.images: no Images binding found. Add an `images` binding (env.IMAGES) to wrangler.jsonc, or pass `images` to createShardDO().",stubMethods:["info","transform"]},tier:"action"},{appMethod:{configKey:"kv",doc:"Override the Workers KV binding backing `ctx.kv` (defaults to `env.KV`).",method:"kv"},contextProperty:"kv",key:"kv",moduleSpecifier:"@lunora/bindings/kv",requiredPackage:"@lunora/bindings",serverCtxField:`
17
- readonly kv: import("@lunora/bindings/kv").Kv;`,shardBinding:{binding:{bindingType:"KVNamespaceLike",envName:"KV",factory:{name:"createKv",option:"namespace"},unvouchableReads:["get","getRaw","getWithMetadata","list"]},clientType:"Kv",missingMessage:"ctx.kv: no KV binding found. Add a `kv_namespaces` binding (env.KV) to wrangler.jsonc, or pass `kv` to createShardDO().",stubMethods:["delete","get","getRaw","getWithMetadata","list","put"]},tier:"every"},{key:"mail",moduleSpecifier:"@lunora/mail"},{contextProperty:"notify",key:"notify",moduleSpecifier:"@lunora/notify"},{appMethod:{configKey:"payment",doc:"Wire the payment options backing `ctx.payments`.",method:"payment"},contextProperty:"payments",key:"payments",moduleSpecifier:"@lunora/payment",requiredPackage:"@lunora/payment"},{appMethod:{configKey:"x402",doc:"Wire the x402 agent-wallet pay rail backing `ctx.x402` — a payment-enabled `fetch` that answers `402` challenges under a mandatory spend policy (ActionCtx-only; spends real funds).",method:"x402"},contextProperty:"x402",key:"x402",moduleSpecifier:"@lunora/x402/pay",requiredPackage:"@lunora/x402",serverCtxField:`
17
+ readonly kv: import("@lunora/bindings/kv").Kv;`,shardBinding:{binding:{bindingType:"KVNamespaceLike",envName:"KV",factory:{name:"createKv",option:"namespace"},unvouchableReads:["get","getRaw","getWithMetadata","list"]},clientType:"Kv",missingMessage:"ctx.kv: no KV binding found. Add a `kv_namespaces` binding (env.KV) to wrangler.jsonc, or pass `kv` to createShardDO().",stubMethods:["delete","get","getRaw","getWithMetadata","list","put"]},tier:"every"},{key:"mail",moduleSpecifier:"@lunora/mail"},{contextProperty:"notify",key:"notify",moduleSpecifier:"@lunora/notify"},{appMethod:{configKey:"payment",doc:"Wire the payment options backing `ctx.payments`.",method:"payment"},contextProperty:"payments",key:"payments",moduleSpecifier:"@lunora/payment",requiredPackage:"@lunora/payment",serverCtxField:`
18
+ readonly payments: import("@lunora/payment").LunoraPayment;`,tier:"action"},{appMethod:{configKey:"x402",doc:"Wire the x402 agent-wallet pay rail backing `ctx.x402` — a payment-enabled `fetch` that answers `402` challenges under a mandatory spend policy (ActionCtx-only; spends real funds).",method:"x402"},contextProperty:"x402",key:"x402",moduleSpecifier:"@lunora/x402/pay",requiredPackage:"@lunora/x402",serverCtxField:`
18
19
  readonly x402: import("@lunora/x402/pay").X402Pay;`,shardBinding:"bespoke",tier:"action"},{contextProperty:"pipelines",key:"pipelines",moduleSpecifier:"@lunora/bindings/pipelines",requiredPackage:"@lunora/bindings",serverCtxField:`
19
20
  /** Pipelines ingestion sink (durable, R2-backed). Fire-and-forget and batched; do not read it back in-handler. */
20
21
  readonly pipelines: import("@lunora/bindings/pipelines").PipelineClient;`,shardBinding:{binding:{bindingType:"PipelineBindingLike",envName:"PIPELINES",factory:{name:"createPipelines",option:"binding"}},clientType:"PipelineClient",missingMessage:"ctx.pipelines: no Pipelines binding found. Add a `pipelines` binding (env.PIPELINES) to wrangler.jsonc, or pass `pipelines` to createShardDO().",stubMethods:["send"]},tier:"action"},{appMethod:{configKey:"r2sql",doc:"Wire the R2 SQL client backing `ctx.r2sql` — build it with `createR2Sql({ accountId, apiToken, bucket })` (defaults to env `R2_SQL_TOKEN` / `R2_SQL_ACCOUNT_ID` / `R2_SQL_BUCKET`).",method:"r2sql"},contextProperty:"r2sql",key:"r2sql",moduleSpecifier:"@lunora/bindings/r2sql",requiredPackage:"@lunora/bindings",serverCtxField:`
21
22
  /**
22
23
  * R2 SQL over Apache Iceberg tables (window functions, DISTINCT, set operations). Non-deterministic — available only in actions. Reads here are NOT tracked by Lunora live queries.
23
24
  */
24
- readonly r2sql: import("@lunora/bindings/r2sql").R2SqlClient;`,shardBinding:"bespoke",tier:"action"},{contextProperty:"scheduler",key:"scheduler",moduleSpecifier:"@lunora/scheduler"},{contextProperty:"storage",key:"storage",moduleSpecifier:"@lunora/storage"},{contextProperty:"vectors",key:"vectors",moduleSpecifier:"@lunora/bindings/vectors"},{contextProperty:"workflows",key:"workflows",moduleSpecifier:"@lunora/workflow"}],a=n,r=n.flatMap(e=>"appMethod"in e?[{appMethod:e.appMethod,key:e.key}]:[]),o=a.map(({contextProperty:e,key:i,moduleSpecifier:t})=>({contextProperty:e,key:i,moduleSpecifier:t})),s=e=>new Set(a.filter(i=>e[i.key]).map(i=>i.key));export{r as APP_METHOD_CAPABILITIES,a as CAPABILITIES,o as CAPABILITY_PROBES,s as usedCapabilities};
25
+ readonly r2sql: import("@lunora/bindings/r2sql").R2SqlClient;`,shardBinding:"bespoke",tier:"action"},{contextProperty:"scheduler",key:"scheduler",moduleSpecifier:"@lunora/scheduler"},{contextProperty:"storage",key:"storage",moduleSpecifier:"@lunora/storage"},{contextProperty:"vectors",key:"vectors",moduleSpecifier:"@lunora/bindings/vectors"},{contextProperty:"workflows",key:"workflows",moduleSpecifier:"@lunora/workflow"}],a=n,r=n.flatMap(e=>"appMethod"in e?[{appMethod:e.appMethod,key:e.key}]:[]),o=Object.fromEntries(a.map(({contextProperty:e,key:i,moduleSpecifier:t})=>[i,{contextProperty:e,moduleSpecifier:t}])),s=e=>new Set(a.filter(i=>e[i.key]).map(i=>i.key));export{r as APP_METHOD_CAPABILITIES,a as CAPABILITIES,o as CAPABILITY_PROBES,s as usedCapabilities};
@@ -1,4 +1,4 @@
1
- import{existsSync as w,mkdirSync as rn,readFileSync as cs,writeFileSync as on,rmSync as an}from"node:fs";import{join as h,dirname as he}from"node:path";import{performance as Ke}from"node:perf_hooks";import{runAdvisor as cn}from"@lunora/advisor";import{LunoraError as U}from"@lunora/errors";import{SyntaxKind as l,Node as i,VariableDeclarationKind as ln,Project as Ot}from"ts-morph";import{serializeSchemaSnapshot as un}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{toAdvisorContext as dn}from"./formatAdvisories-DwmUKYuc.mjs";import{readProjectConfigLiterals as fn}from"./loadProjectConfig-nNIDOrlR.mjs";import{a as Rt,d as pn,r as gn}from"./modules-DyCocr1e.mjs";import{QUEUES_FILENAME as mn,discoverQueueDeclarations as hn}from"./QUEUES_FILENAME-RGwht3Xu.mjs";import{WORKFLOWS_FILENAME as vn,discoverWorkflows as xn}from"./WORKFLOWS_FILENAME-4-ib4HH-.mjs";import{r as En}from"./json-data-Chfs2Cz5.mjs";import{s as be}from"./paths-C-9fwEgQ.mjs";import{G as Sn}from"./shared-DjUziztz.mjs";import{CAPABILITIES as yn,usedCapabilities as An}from"./CAPABILITY_PROBES-BPeV994T.mjs";import{isD1GlobalTable as ls,isHyperdriveGlobalTable as us}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as bn}from"./AGENTS_FILENAME-D8SgT3OR.mjs";import{discoverContainers as Nn}from"./CONTAINERS_FILENAME-C13yKxas.mjs";import wn from"./discoverCrons-BEALHx1S.mjs";import{diagnosticAt as ae}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as Ne}from"./module-specifiers-WF8iAydP.mjs";import{contextPropertiesRead as Pn,discoverFeatureUsage as In}from"./sourceCapabilitySignals-NsxX0VDV.mjs";import Tn from"./readPackageDependencies-C6h6FZuP.mjs";import{listLunoraSourceFiles as g,propertyKeyName as x,unwrapExpression as ne,listSecurityScanFiles as we,objectLiteralFromCallbackBody as ds,propertyInitializer as b,lunoraRelativePath as m,enclosingExportName as re,bindingKeyName as Pe,collectCallRows as F,findObjectProperty as C,collectSecurityCallRows as Cn,RUN_METHODS as fs,functionReferenceSegments as ps,limitNameOf as gs,optionsObjectLiteral as ms,isContextIdentifier as Ve,handlerOf as Fn,isDatabaseAccessor as k,readTargetOf as hs}from"./listLunoraSourceFiles-CSlcBYlo.mjs";import{discoverSandboxUsage as On}from"./discoverSandboxUsage-BnsPld5I.mjs";import{resolveServiceBindings as Rn}from"./readServiceBindings-CeQvSswr.mjs";import Ln from"./discoverStorageRulesMetadata-D3Ot9g5f.mjs";import{a as S,c as B,d as vs,e as kn}from"./classify-procedure-call-CmcShAze.mjs";import{i as Dn}from"./ir-DBSvhNa-.mjs";import{gatePlatformFeatures as Mn,resolveCodegenTarget as xs,readTargetDiagnostics as _n,studioPlatformFor as Kn}from"./DEFAULT_TARGET-Co7ZXJ21.mjs";import{b as Es,e as $n}from"./shard-CBwweXGB.mjs";import zn from"./emitServer-DThb0DLe.mjs";import{emitDataModel as Un}from"./emitDataModel-D3WuEZ4b.mjs";import{r as Ie,s as Bn}from"./parse-validator-C6fHL7OS.mjs";import qn from"./discoverAuthApiCalls-DoSN_yc3.mjs";import{i as jn,a as Wn,e as Vn,b as Hn,d as Gn,c as Yn}from"./unwrap-handler-return-DVY_kFF7.mjs";import Qn from"./discoverFunctions-BcBzcG5x.mjs";import Xn from"./discoverHttpRoutes-CJHS4llq.mjs";import Jn from"./discoverHyperdriveCalls-Bkbh4tG7.mjs";import Zn from"./discoverInserts-DpuLYPPd.mjs";import{m as Ze,a as Ee,s as Ss,d as er}from"./index-D7dKfGPh.mjs";import{e as ys}from"./exported-procedure-chains-D48EXUVQ.mjs";import tr from"./discoverMigrations-Dt7ywfZv.mjs";import{MUTATORS_FILENAME as sr,isDefineMutatorCallee as nr,discoverMutators as rr}from"./MUTATORS_FILENAME-DqWOgC5Z.mjs";import or from"./discoverNondeterministicCalls-CNJV2BiP.mjs";import{discoverNotifyConfig as ir,discoverNotifyCalls as ar}from"./NOTIFY_FILENAME-C1J_47et.mjs";import cr from"./discoverQueries-BcdqjYky.mjs";import lr from"./discoverR2sqlCalls-30Wtbc0P.mjs";import ur from"./discoverRlsProcedures-F4Cy-kSi.mjs";import dr from"./discoverRlsMetadata-mXBmPOGj.mjs";import fr from"./discoverSchema-D5R60b4F.mjs";import{secretKindOf as pr,redact as gr,isHeuristicSecretKind as mr,isSecretishName as hr}from"./redact-Cy14LEnc.mjs";import{discoverShapes as vr}from"./SHAPES_FILENAME-DRUFomCj.mjs";import{emitApp as xr}from"./emitApp-CokyctXT.mjs";import{buildOpenApiDocument as Er,emitOpenApiModule as Sr}from"./buildOpenApiDocument-SxfElVzK.mjs";import{buildOpenRpcDocument as yr,emitOpenRpcModule as Ar}from"./OPENRPC_VERSION-Cr7Zzp6s.mjs";import{buildSchemaSnapshot as br}from"./SchemaSnapshotParseError-CPOXlFhI.mjs";import{emitCollections as Nr,emitSeed as wr,emitApi as Pr}from"./emitApi-DdW9RyGG.mjs";import{t as Ir,u as Tr,s as Cr,v as Fr}from"./shard-runtime-DTSpJxxd.mjs";import{emitCrons as Or,emitScheduler as Rr,emitShardRegistry as Lr,emitVectors as kr,emitWranglerCronTriggers as Dr}from"./emitCrons-BRKXFGFu.mjs";import Mr from"./emitDrizzleSchema-Cv0HtLR3.mjs";import _r from"./emitFunctions-BgNeOZt_.mjs";const Lt={error:"ERROR",info:"INFO",warn:"WARN"},kt={ERROR:2,INFO:0,WARN:1},Kr=e=>({cacheKey:"advisor_min_severity_invalid",categories:["SCHEMA"],description:"`advisor.minSeverity` in `lunora.config.*` sets the lowest advisory level codegen reports and writes into `_generated/shard.ts`. Codegen reads it by parsing the file, so it has to be a string literal.",detail:e,facing:"INTERNAL",level:"WARN",metadata:{},name:"advisor_min_severity_invalid",remediation:'Set `advisor: { minSeverity: "info" | "warn" | "error" }` as a literal on the config\'s default export.',title:"`advisor.minSeverity` is not a level codegen can read, so every advisory was reported"}),$r=(e,t)=>{const{advisor:s}=fn(e);if(s===void 0||s.minSeverity===void 0&&s.unreadable!==!0)return[...t];const{minSeverity:n}=s,o=n!==void 0&&Object.hasOwn(Lt,n)?Lt[n]:void 0;return o===void 0?[...t,Kr(n===void 0?"`advisor.minSeverity` is not a string literal codegen can read without evaluating the config: a computed value or key, or a spread that could set or override it.":`\`advisor.minSeverity\` is "${n}", which is not one of "info", "warn" or "error".`)]:t.filter(r=>kt[r.level]>=kt[o])},zr={call:"function",enqueue:"queue",invoke:"service",publish:"topic",schedule:"function"},As=mn.replace(/\.ts$/u,""),Ur="crons",Br=vn.replace(/\.ts$/u,""),te=(e,t)=>`${be(e)}:${t}`,$e=(e,t,s)=>t===""?{reason:`the ${s} is not a string literal`}:{to:`${e}:${t}`},qr=e=>[...e.callEdges.map(t=>{const s=t.target===void 0?{reason:t.reason??"unreadable target"}:{to:`${zr[t.kind]}:${t.target}`};return{exportName:t.exportName,file:t.file,kind:t.kind,line:t.line,...s}}),...e.queries.map(t=>({exportName:t.exportName,file:t.file,kind:"read",line:t.line,...$e("table",t.table,"table name")})),...[...e.inserts,...e.tableWrites].map(t=>({exportName:t.exportName,file:t.file,kind:"write",line:t.line,...$e("table",t.table,"written table")})),...e.workflowCalls.map(t=>({exportName:t.exportName,file:t.file,kind:"start",line:t.line,...$e("workflow",t.workflow,"workflow name")}))],jr=e=>[...e.queues.flatMap(t=>t.topic===void 0?[]:[{exportName:t.exportName,file:As,from:`topic:${t.topic}`,kind:"subscribe",line:0,to:`queue:${t.exportName}`}]),...e.crons.map(t=>{const s=t.workflow===void 0?void 0:`workflow:${t.workflow.exportName}`,n=t.functionPath===void 0?void 0:`function:${t.functionPath}`,o=s??n;return{exportName:t.name,file:Ur,from:`cron:${t.name}`,kind:"trigger",line:0,...o===void 0?{reason:"the cron has no target"}:{to:o}}})],Wr=e=>new Map(e.flatMap(t=>t.tables.map(s=>[s,t.name]))),ze=(e,t)=>t===void 0?e:{...e,module:t},Vr=e=>{const t=new Map,s=new Map,n=Wr(e.modules),o=(r,a)=>{t.set(r.id,r),a!==void 0&&s.set(a,r.id)};for(const r of e.functions){const a=te(r.filePath,r.exportName),c=`${be(r.filePath)}.${r.exportName}`;o(ze({detail:r.kind,id:`function:${a}`,kind:"function",name:c},Rt(e.modules,r.filePath)),a)}for(const r of e.httpRoutes){const a=te(r.filePath,r.exportName);o(ze({id:`http:${a}`,kind:"http",name:`${r.method} ${r.path}`},Rt(e.modules,r.filePath)),a)}for(const r of e.schema.tables)o(ze({id:`table:${r.name}`,kind:"table",name:r.name},n.get(r.name)));for(const r of e.queues){const a=r.topic===void 0?{}:{detail:"subscription"};o({...a,id:`queue:${r.exportName}`,kind:"queue",name:r.exportName},te(As,r.exportName))}for(const r of e.topics)o({id:`topic:${r.exportName}`,kind:"topic",name:r.exportName});for(const r of e.workflows)o({id:`workflow:${r.exportName}`,kind:"workflow",name:r.exportName},te(Br,r.exportName));for(const r of e.crons)o({detail:r.cron,id:`cron:${r.name}`,kind:"cron",name:r.name});for(const r of e.services){const a=r.rpcEntrypoint===void 0?"fetch":"rpc";o({detail:r.entrypoint===void 0?a:`${a} · ${r.entrypoint}`,id:`service:${r.name}`,kind:"service",name:r.worker})}return{nodes:t,sites:s}},Hr=e=>e===""?"inside a non-exported helper":e==="default"?"the default export is not a registered function":`"${e}" is not a registered function`,Gr=(e,t,s)=>{if("reason"in e)return{reason:e.reason};const n=e.from??t.get(te(e.file,e.exportName));return n===void 0?{reason:Hr(e.exportName)}:s.has(e.to)?{drawn:{from:n,kind:e.kind,to:e.to}}:{reason:`${e.to} is not declared`}},Ue=e=>`${e.from}|${e.kind}|${e.to}`,Yr=e=>`${e.file}|${String(e.line)}|${e.kind}|${e.reason}`,Qr=e=>{const{nodes:t,sites:s}=Vr(e),n=new Map,o=new Map;for(const r of[...jr(e),...qr(e)]){const a=Gr(r,s,t);if("drawn"in a)n.set(Ue(a.drawn),a.drawn);else{const c={file:r.file,kind:r.kind,line:r.line,reason:a.reason};o.set(Yr(c),c)}}return{edges:[...n.values()].toSorted((r,a)=>Ue(r).localeCompare(Ue(a))),nodes:[...t.values()].toSorted((r,a)=>r.id.localeCompare(a.id)),modules:e.modules.map(r=>({...r.description===void 0?{}:{description:r.description},...r.installed===!0?{installed:!0}:{},...r.ownsFolder===!1?{ownsFolder:!1}:{},name:r.name,tables:[...r.tables]})),unresolved:[...o.values()].toSorted((r,a)=>r.file.localeCompare(a.file)||r.line-a.line),version:1}},Xr=e=>`${Sn}export const architecture = ${En(e,"Record<string, unknown>")};
1
+ import{existsSync as w,mkdirSync as rn,readFileSync as cs,writeFileSync as on,rmSync as an}from"node:fs";import{join as h,dirname as he}from"node:path";import{performance as Ke}from"node:perf_hooks";import{runAdvisor as cn}from"@lunora/advisor";import{LunoraError as U}from"@lunora/errors";import{SyntaxKind as l,Node as i,VariableDeclarationKind as ln,Project as Ot}from"ts-morph";import{serializeSchemaSnapshot as un}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{toAdvisorContext as dn}from"./formatAdvisories-DwmUKYuc.mjs";import{readProjectConfigLiterals as fn}from"./loadProjectConfig-nNIDOrlR.mjs";import{a as Rt,d as pn,r as gn}from"./modules-DyCocr1e.mjs";import{QUEUES_FILENAME as mn,discoverQueueDeclarations as hn}from"./QUEUES_FILENAME-RGwht3Xu.mjs";import{WORKFLOWS_FILENAME as vn,discoverWorkflows as xn}from"./WORKFLOWS_FILENAME-4-ib4HH-.mjs";import{r as En}from"./json-data-Chfs2Cz5.mjs";import{s as be}from"./paths-C-9fwEgQ.mjs";import{G as Sn}from"./shared-DjUziztz.mjs";import{CAPABILITIES as yn,usedCapabilities as An}from"./CAPABILITY_PROBES-DFsutD7g.mjs";import{isD1GlobalTable as ls,isHyperdriveGlobalTable as us}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as bn}from"./AGENTS_FILENAME-D8SgT3OR.mjs";import{discoverContainers as Nn}from"./CONTAINERS_FILENAME-C13yKxas.mjs";import wn from"./discoverCrons-BEALHx1S.mjs";import{diagnosticAt as ae}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as Ne}from"./module-specifiers-WF8iAydP.mjs";import{contextPropertiesRead as Pn,discoverFeatureUsage as In}from"./capabilitiesUsedBy-DqrbgTKV.mjs";import Tn from"./readPackageDependencies-C6h6FZuP.mjs";import{listLunoraSourceFiles as g,propertyKeyName as x,unwrapExpression as ne,listSecurityScanFiles as we,objectLiteralFromCallbackBody as ds,propertyInitializer as b,lunoraRelativePath as m,enclosingExportName as re,bindingKeyName as Pe,collectCallRows as F,findObjectProperty as C,collectSecurityCallRows as Cn,RUN_METHODS as fs,functionReferenceSegments as ps,limitNameOf as gs,optionsObjectLiteral as ms,isContextIdentifier as Ve,handlerOf as Fn,isDatabaseAccessor as k,readTargetOf as hs}from"./listLunoraSourceFiles-CSlcBYlo.mjs";import{discoverSandboxUsage as On}from"./discoverSandboxUsage-DC6q7rZy.mjs";import{resolveServiceBindings as Rn}from"./readServiceBindings-CeQvSswr.mjs";import Ln from"./discoverStorageRulesMetadata-D3Ot9g5f.mjs";import{a as S,c as B,d as vs,e as kn}from"./classify-procedure-call-CmcShAze.mjs";import{i as Dn}from"./ir-DBSvhNa-.mjs";import{gatePlatformFeatures as Mn,resolveCodegenTarget as xs,readTargetDiagnostics as _n,studioPlatformFor as Kn}from"./DEFAULT_TARGET-Co7ZXJ21.mjs";import{b as Es,e as $n}from"./shard-Do57J5-c.mjs";import zn from"./emitServer-mdlKhXYb.mjs";import{emitDataModel as Un}from"./emitDataModel-D3WuEZ4b.mjs";import{r as Ie,s as Bn}from"./parse-validator-C6fHL7OS.mjs";import qn from"./discoverAuthApiCalls-DoSN_yc3.mjs";import{i as jn,a as Wn,e as Vn,b as Hn,d as Gn,c as Yn}from"./unwrap-handler-return-DVY_kFF7.mjs";import Qn from"./discoverFunctions-BcBzcG5x.mjs";import Xn from"./discoverHttpRoutes-CJHS4llq.mjs";import Jn from"./discoverHyperdriveCalls-Bkbh4tG7.mjs";import Zn from"./discoverInserts-DpuLYPPd.mjs";import{m as Ze,a as Ee,s as Ss,d as er}from"./index-D7dKfGPh.mjs";import{e as ys}from"./exported-procedure-chains-D48EXUVQ.mjs";import tr from"./discoverMigrations-Dt7ywfZv.mjs";import{MUTATORS_FILENAME as sr,isDefineMutatorCallee as nr,discoverMutators as rr}from"./MUTATORS_FILENAME-DqWOgC5Z.mjs";import or from"./discoverNondeterministicCalls-CNJV2BiP.mjs";import{discoverNotifyConfig as ir,discoverNotifyCalls as ar}from"./NOTIFY_FILENAME-C1J_47et.mjs";import cr from"./discoverQueries-BcdqjYky.mjs";import lr from"./discoverR2sqlCalls-30Wtbc0P.mjs";import ur from"./discoverRlsProcedures-F4Cy-kSi.mjs";import dr from"./discoverRlsMetadata-mXBmPOGj.mjs";import fr from"./discoverSchema-D5R60b4F.mjs";import{secretKindOf as pr,redact as gr,isHeuristicSecretKind as mr,isSecretishName as hr}from"./redact-Cy14LEnc.mjs";import{discoverShapes as vr}from"./SHAPES_FILENAME-DRUFomCj.mjs";import{emitApp as xr}from"./emitApp-0rC4g46B.mjs";import{buildOpenApiDocument as Er,emitOpenApiModule as Sr}from"./buildOpenApiDocument-SxfElVzK.mjs";import{buildOpenRpcDocument as yr,emitOpenRpcModule as Ar}from"./OPENRPC_VERSION-Cr7Zzp6s.mjs";import{buildSchemaSnapshot as br}from"./SchemaSnapshotParseError-CPOXlFhI.mjs";import{emitCollections as Nr,emitSeed as wr,emitApi as Pr}from"./emitApi-DdW9RyGG.mjs";import{t as Ir,u as Tr,s as Cr,v as Fr}from"./shard-runtime-B8rucwkF.mjs";import{emitCrons as Or,emitScheduler as Rr,emitShardRegistry as Lr,emitVectors as kr,emitWranglerCronTriggers as Dr}from"./emitCrons-BRKXFGFu.mjs";import Mr from"./emitDrizzleSchema-Cv0HtLR3.mjs";import _r from"./emitFunctions-BgNeOZt_.mjs";const Lt={error:"ERROR",info:"INFO",warn:"WARN"},kt={ERROR:2,INFO:0,WARN:1},Kr=e=>({cacheKey:"advisor_min_severity_invalid",categories:["SCHEMA"],description:"`advisor.minSeverity` in `lunora.config.*` sets the lowest advisory level codegen reports and writes into `_generated/shard.ts`. Codegen reads it by parsing the file, so it has to be a string literal.",detail:e,facing:"INTERNAL",level:"WARN",metadata:{},name:"advisor_min_severity_invalid",remediation:'Set `advisor: { minSeverity: "info" | "warn" | "error" }` as a literal on the config\'s default export.',title:"`advisor.minSeverity` is not a level codegen can read, so every advisory was reported"}),$r=(e,t)=>{const{advisor:s}=fn(e);if(s===void 0||s.minSeverity===void 0&&s.unreadable!==!0)return[...t];const{minSeverity:n}=s,o=n!==void 0&&Object.hasOwn(Lt,n)?Lt[n]:void 0;return o===void 0?[...t,Kr(n===void 0?"`advisor.minSeverity` is not a string literal codegen can read without evaluating the config: a computed value or key, or a spread that could set or override it.":`\`advisor.minSeverity\` is "${n}", which is not one of "info", "warn" or "error".`)]:t.filter(r=>kt[r.level]>=kt[o])},zr={call:"function",enqueue:"queue",invoke:"service",publish:"topic",schedule:"function"},As=mn.replace(/\.ts$/u,""),Ur="crons",Br=vn.replace(/\.ts$/u,""),te=(e,t)=>`${be(e)}:${t}`,$e=(e,t,s)=>t===""?{reason:`the ${s} is not a string literal`}:{to:`${e}:${t}`},qr=e=>[...e.callEdges.map(t=>{const s=t.target===void 0?{reason:t.reason??"unreadable target"}:{to:`${zr[t.kind]}:${t.target}`};return{exportName:t.exportName,file:t.file,kind:t.kind,line:t.line,...s}}),...e.queries.map(t=>({exportName:t.exportName,file:t.file,kind:"read",line:t.line,...$e("table",t.table,"table name")})),...[...e.inserts,...e.tableWrites].map(t=>({exportName:t.exportName,file:t.file,kind:"write",line:t.line,...$e("table",t.table,"written table")})),...e.workflowCalls.map(t=>({exportName:t.exportName,file:t.file,kind:"start",line:t.line,...$e("workflow",t.workflow,"workflow name")}))],jr=e=>[...e.queues.flatMap(t=>t.topic===void 0?[]:[{exportName:t.exportName,file:As,from:`topic:${t.topic}`,kind:"subscribe",line:0,to:`queue:${t.exportName}`}]),...e.crons.map(t=>{const s=t.workflow===void 0?void 0:`workflow:${t.workflow.exportName}`,n=t.functionPath===void 0?void 0:`function:${t.functionPath}`,o=s??n;return{exportName:t.name,file:Ur,from:`cron:${t.name}`,kind:"trigger",line:0,...o===void 0?{reason:"the cron has no target"}:{to:o}}})],Wr=e=>new Map(e.flatMap(t=>t.tables.map(s=>[s,t.name]))),ze=(e,t)=>t===void 0?e:{...e,module:t},Vr=e=>{const t=new Map,s=new Map,n=Wr(e.modules),o=(r,a)=>{t.set(r.id,r),a!==void 0&&s.set(a,r.id)};for(const r of e.functions){const a=te(r.filePath,r.exportName),c=`${be(r.filePath)}.${r.exportName}`;o(ze({detail:r.kind,id:`function:${a}`,kind:"function",name:c},Rt(e.modules,r.filePath)),a)}for(const r of e.httpRoutes){const a=te(r.filePath,r.exportName);o(ze({id:`http:${a}`,kind:"http",name:`${r.method} ${r.path}`},Rt(e.modules,r.filePath)),a)}for(const r of e.schema.tables)o(ze({id:`table:${r.name}`,kind:"table",name:r.name},n.get(r.name)));for(const r of e.queues){const a=r.topic===void 0?{}:{detail:"subscription"};o({...a,id:`queue:${r.exportName}`,kind:"queue",name:r.exportName},te(As,r.exportName))}for(const r of e.topics)o({id:`topic:${r.exportName}`,kind:"topic",name:r.exportName});for(const r of e.workflows)o({id:`workflow:${r.exportName}`,kind:"workflow",name:r.exportName},te(Br,r.exportName));for(const r of e.crons)o({detail:r.cron,id:`cron:${r.name}`,kind:"cron",name:r.name});for(const r of e.services){const a=r.rpcEntrypoint===void 0?"fetch":"rpc";o({detail:r.entrypoint===void 0?a:`${a} · ${r.entrypoint}`,id:`service:${r.name}`,kind:"service",name:r.worker})}return{nodes:t,sites:s}},Hr=e=>e===""?"inside a non-exported helper":e==="default"?"the default export is not a registered function":`"${e}" is not a registered function`,Gr=(e,t,s)=>{if("reason"in e)return{reason:e.reason};const n=e.from??t.get(te(e.file,e.exportName));return n===void 0?{reason:Hr(e.exportName)}:s.has(e.to)?{drawn:{from:n,kind:e.kind,to:e.to}}:{reason:`${e.to} is not declared`}},Ue=e=>`${e.from}|${e.kind}|${e.to}`,Yr=e=>`${e.file}|${String(e.line)}|${e.kind}|${e.reason}`,Qr=e=>{const{nodes:t,sites:s}=Vr(e),n=new Map,o=new Map;for(const r of[...jr(e),...qr(e)]){const a=Gr(r,s,t);if("drawn"in a)n.set(Ue(a.drawn),a.drawn);else{const c={file:r.file,kind:r.kind,line:r.line,reason:a.reason};o.set(Yr(c),c)}}return{edges:[...n.values()].toSorted((r,a)=>Ue(r).localeCompare(Ue(a))),nodes:[...t.values()].toSorted((r,a)=>r.id.localeCompare(a.id)),modules:e.modules.map(r=>({...r.description===void 0?{}:{description:r.description},...r.installed===!0?{installed:!0}:{},...r.ownsFolder===!1?{ownsFolder:!1}:{},name:r.name,tables:[...r.tables]})),unresolved:[...o.values()].toSorted((r,a)=>r.file.localeCompare(a.file)||r.line-a.line),version:1}},Xr=e=>`${Sn}export const architecture = ${En(e,"Record<string, unknown>")};
2
2
  `,Jr=(e,t)=>{if(!(!t||e.jurisdiction!=="fedramp"))throw new U("CODEGEN_DIAGNOSTIC",'@lunora/codegen: the schema pins data to the "fedramp" jurisdiction, but this app uses Cloudflare Artifacts (`ctx.artifacts`), which supports only the "eu" and "us" jurisdictions. Repo data would be stored outside the declared residency. Remove the `ctx.artifacts` usage, or pin the schema to a jurisdiction Artifacts supports.')},Dt=(e,t="api")=>{const s=new Map;for(const n of e){const o=be(n),r=s.get(o);if(r===void 0){s.set(o,n);continue}if(r!==n){const a=t==="api"?`the generated api.ts would declare "${o}" twice and the dispatch key "${o}:<fn>" would be ambiguous`:`the generated api.ts would declare "${o}" twice in HttpStreamsRef and again in the httpStreams object literal`;throw new U("INTERNAL",`@lunora/codegen: "${r}" and "${n}" both map to the ${t} namespace "${o}" — ${a}. Rename one file so the two differ by more than a non-identifier character (\`-\`, \`.\`, \`/\` and \`_\` all sanitize to \`_\`).`,{status:500})}}},Zr=(e,t={})=>{const{hasVectors:s=!0,scheduler:n=!1,storage:o=!1,usage:r}=t,a=[];e.tables.some(c=>ls(c))&&a.push({name:"@lunora/d1",reason:"`.global()` tables are D1-backed, so `_generated/app.ts` imports the D1 `ctx.db` adapter"}),e.tables.some(c=>us(c))&&a.push({name:"@lunora/hyperdrive",reason:'`.global({ backend: "hyperdrive" })` tables route through `@lunora/hyperdrive/global`'},{name:"@lunora/sql-store",reason:'`.global({ backend: "hyperdrive" })` makes `_generated/app.ts` import the `SqlCtxDbOptions` / `SqlExec` types'}),n&&a.push({name:"@lunora/scheduler",reason:"a declared cron (or `ctx.scheduler` use) makes `_generated/app.ts` import `createScheduler`"}),o&&a.push({name:"@lunora/storage",reason:"a `v.storage()` column, a storage access rule (or `ctx.storage` use) makes `_generated/app.ts` import `createStorage`"}),e.vectorIndexes.length>0&&s&&a.push({name:"@lunora/bindings",reason:"`.vectorize()` indexes make `_generated/shard.ts` import `@lunora/bindings/vectors`"});for(const c of r===void 0?[]:yn)c.requiredPackage!==void 0&&r?.[c.key]===!0&&a.push({name:c.requiredPackage,reason:`\`ctx.${c.contextProperty??c.key}\` usage makes \`_generated/\` import \`${c.moduleSpecifier}\``});return a.filter((c,u)=>a.findIndex(d=>d.name===c.name)===u)},eo=(e,t,s={})=>{if(t===void 0)return;const n=Zr(e,s).filter(r=>!t.has(r.name));if(n.length===0)return;const o=n.map(r=>` - ${r.name} — ${r.reason}`).join(`
3
3
  `);throw new U("INTERNAL",`@lunora/codegen: this schema's generated code imports packages the project does not declare:
4
4
  ${o}
@@ -0,0 +1 @@
1
+ import{SyntaxKind as c,Node as r}from"ts-morph";import{CAPABILITIES as f}from"./CAPABILITY_PROBES-DFsutD7g.mjs";import{bindingKeyName as p,listLunoraSourceFiles as g}from"./listLunoraSourceFiles-CSlcBYlo.mjs";import{scanImportDeclaration as u,noSandboxUsage as l}from"./discoverSandboxUsage-DC6q7rZy.mjs";const d="ctx",x=e=>{const t=new Set,n=new Set([d]),s=o=>{if(r.isObjectBindingPattern(o))for(const i of o.getElements()){const m=p(i);m&&t.add(m)}};for(const o of e.getDescendantsOfKind(c.BindingElement)){if(p(o)!==d)continue;const i=o.getNameNode();r.isIdentifier(i)?n.add(i.getText()):s(i)}const a=o=>r.isIdentifier(o)&&n.has(o.getText());for(const o of e.getDescendantsOfKind(c.PropertyAccessExpression))a(o.getExpression())&&t.add(o.getName());for(const o of e.getDescendantsOfKind(c.VariableDeclaration)){const i=o.getInitializer();i!==void 0&&a(i)&&s(o.getNameNode())}return t},E=e=>{if(e.isTypeOnly())return!0;if(r.isExportDeclaration(e)){const n=e.getNamedExports();return!e.isNamespaceExport()&&n.length>0&&n.every(s=>s.isTypeOnly())}const t=e.getNamedImports();return e.getDefaultImport()===void 0&&e.getNamespaceImport()===void 0&&t.length>0&&t.every(n=>n.isTypeOnly())},S=e=>{const t=new Set;for(const n of e.getDescendantsOfKind(c.CallExpression)){const[s]=n.getArguments();n.getExpression().getKind()===c.ImportKeyword&&(r.isStringLiteral(s)||r.isNoSubstitutionTemplateLiteral(s))&&t.add(s.getLiteralValue())}return t},y=e=>{const t=e.getImportDeclarations(),n=l();for(const s of t){const a=u(s);for(const o of Object.keys(n))n[o]||=a[o]}return{contextReads:x(e),dynamicImports:S(e),sandboxTools:n,valueImports:new Set([...t,...e.getExportDeclarations()].flatMap(s=>{const a=s.getModuleSpecifierValue();return a===void 0||E(s)?[]:[a]}))}},T=e=>{const t=new Set,n=new Set,s=l(),a=new Set;for(const o of e){for(const i of o.contextReads)t.add(i);for(const i of o.dynamicImports)n.add(i);for(const i of o.valueImports)a.add(i);for(const i of Object.keys(s))s[i]||=o.sandboxTools[i]}return{contextReads:t,dynamicImports:n,sandboxTools:s,valueImports:a}},I=e=>new Set(f.filter(({contextProperty:t,moduleSpecifier:n})=>e.valueImports.has(n)||t!==void 0&&e.contextReads.has(t)).map(({key:t})=>t)),N=new RegExp(String.raw`\b${d}\b`,"u"),b=new RegExp(String.raw`\b(?:${f.flatMap(({contextProperty:e})=>e===void 0?[]:[e]).join("|")})\b`,"u"),C=e=>N.test(e)&&b.test(e),D=(e,t)=>{const n=T(g(t).map(a=>y(e.getSourceFile(a)??e.addSourceFileAtPath(a)))),s=I(n);return Object.fromEntries(f.map(({key:a})=>[a,s.has(a)]))};export{I as capabilitiesUsedBy,x as contextPropertiesRead,D as discoverFeatureUsage,T as foldCapabilitySignals,C as mayReadCapabilityContext,y as sourceCapabilitySignals};
@@ -1 +1 @@
1
- import{listLunoraSourceFiles as d}from"./listLunoraSourceFiles-CSlcBYlo.mjs";const f=new Set(["@lunora/agent","@lunora/agent/sandbox"]),t={browserTool:"usesSandboxBrowser",containerFsTool:"usesSandboxContainer",containerTool:"usesSandboxContainer",fsTool:"usesSandboxFs",jsCodeTool:"usesSandboxLoader"},u=()=>({usesSandboxBrowser:!1,usesSandboxContainer:!1,usesSandboxFs:!1,usesSandboxLoader:!1}),i=o=>{const s=u();if(!f.has(o.getModuleSpecifierValue())||o.isTypeOnly())return s;for(const e of o.getNamedImports()){if(e.isTypeOnly())continue;const n=t[e.getNameNode().getText()];n!==void 0&&(s[n]=!0)}return s},b=(o,s)=>{const e=u();for(const n of d(s)){const c=o.getSourceFile(n)??o.addSourceFileAtPath(n);for(const a of c.getImportDeclarations()){const l=i(a);for(const r of Object.values(t))e[r]||=l[r]}if(Object.values(t).every(a=>e[a]))break}return e};export{b as discoverSandboxUsage};
1
+ import{listLunoraSourceFiles as d}from"./listLunoraSourceFiles-CSlcBYlo.mjs";const f=new Set(["@lunora/agent","@lunora/agent/sandbox"]),t={browserTool:"usesSandboxBrowser",containerFsTool:"usesSandboxContainer",containerTool:"usesSandboxContainer",fsTool:"usesSandboxFs",jsCodeTool:"usesSandboxLoader"},u=()=>({usesSandboxBrowser:!1,usesSandboxContainer:!1,usesSandboxFs:!1,usesSandboxLoader:!1}),i=o=>{const s=u();if(!f.has(o.getModuleSpecifierValue())||o.isTypeOnly())return s;for(const e of o.getNamedImports()){if(e.isTypeOnly())continue;const n=t[e.getNameNode().getText()];n!==void 0&&(s[n]=!0)}return s},b=(o,s)=>{const e=u();for(const n of d(s)){const c=o.getSourceFile(n)??o.addSourceFileAtPath(n);for(const a of c.getImportDeclarations()){const l=i(a);for(const r of Object.values(t))e[r]||=l[r]}if(Object.values(t).every(a=>e[a]))break}return e};export{b as discoverSandboxUsage,u as noSandboxUsage,i as scanImportDeclaration};
@@ -1 +1 @@
1
- import"./ir-DBSvhNa-.mjs";import"./json-data-Chfs2Cz5.mjs";import{o as i,j as r,s as o,h as n,t as g,k as F,d as u,v as p,m as f,g as l,f as d,i as k,u as w,l as Q}from"./shard-runtime-DTSpJxxd.mjs";import"./shared-DjUziztz.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,o as emitAgents,n as emitContainerFragments,g as emitContainers,F as emitPaymentFragments,u as emitQueueFragments,p as emitQueues,f as emitQueuesMetadataFragments,l as emitServiceFragments,d as emitTopicFragments,k as emitWorkflowFragments,w as emitWorkflows,Q as emitWorkflowsMetadataFragments};
1
+ import"./ir-DBSvhNa-.mjs";import"./json-data-Chfs2Cz5.mjs";import{o as i,j as r,s as o,h as n,t as g,k as F,d as u,v as p,m as f,g as l,f as d,i as k,u as w,l as Q}from"./shard-runtime-B8rucwkF.mjs";import"./shared-DjUziztz.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,o as emitAgents,n as emitContainerFragments,g as emitContainers,F as emitPaymentFragments,u as emitQueueFragments,p as emitQueues,f as emitQueuesMetadataFragments,l as emitServiceFragments,d as emitTopicFragments,k as emitWorkflowFragments,w as emitWorkflows,Q as emitWorkflowsMetadataFragments};