gencow 0.1.298 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/gencow.mjs +0 -6
- package/core/index.js +261 -1447
- package/core/package.json +1 -1
- package/dashboard/assets/{index-BnBn8uo4.js → index-DYqUzCmS.js} +3 -3
- package/dashboard/assets/index-OH2xW1ZG.css +2 -0
- package/dashboard/index.html +2 -2
- package/docs/packaging.md +14 -4
- package/lib/cli-artifact-guard.mjs +53 -3
- package/lib/cli-command-runner.d.mts +11 -0
- package/lib/cli-dev-runtime.mjs +1 -0
- package/lib/cli-project-runtime.mjs +26 -14
- package/lib/codegen-command.mjs +16 -0
- package/lib/coding-guardrails.mjs +2 -0
- package/lib/component-readme.mjs +4 -4
- package/lib/dashboard-artifact.mjs +65 -0
- package/lib/dashboard-assets.mjs +20 -0
- package/lib/db-command.mjs +121 -80
- package/lib/db-migration-command-steps.mjs +19 -16
- package/lib/db-push-command.mjs +1 -1
- package/lib/deploy-codegen-preflight.mjs +1 -0
- package/lib/deploy-cron-manifest-diagnostic.mjs +93 -0
- package/lib/deploy-failure-diagnostic.mjs +4 -43
- package/lib/deploy-route-target-rejection-diagnostic.mjs +43 -0
- package/lib/dev-cloud-command.mjs +1 -1
- package/lib/dev-local-command.mjs +19 -56
- package/lib/document-local-converter.mjs +11 -0
- package/lib/jobs-command.mjs +33 -1
- package/lib/local-dashboard-plan.mjs +60 -0
- package/lib/local-database-commands.mjs +127 -0
- package/lib/local-development-migrations.mjs +157 -0
- package/lib/local-drizzle-database.config.mjs +10 -0
- package/lib/local-runtime-features.mjs +12 -0
- package/lib/rag-selection.mjs +7 -0
- package/lib/readme-codegen.mjs +2 -2
- package/lib/runtime-local-worker.mjs +116 -0
- package/lib/runtime-mode.mjs +3 -0
- package/lib/standalone-codegen-adapter.mjs +91 -0
- package/lib/ts-codegen-import-extension.mjs +228 -19
- package/package.json +16 -9
- package/runtime/config.mjs +218 -2
- package/runtime/dependency-lock.mjs +5 -1
- package/runtime/engine/chunk-2HA4CUMS.mjs +90 -0
- package/runtime/engine/chunk-2JLO3KMM.mjs +305 -0
- package/runtime/engine/chunk-2SR2M7SR.mjs +1045 -0
- package/runtime/engine/chunk-3D7MHEUC.mjs +253 -0
- package/runtime/engine/chunk-3R7COBWG.mjs +309 -0
- package/runtime/engine/chunk-3ZKA54UW.mjs +1560 -0
- package/runtime/engine/chunk-45I4YR2J.mjs +9 -0
- package/runtime/engine/chunk-4MLRXO7F.mjs +74 -0
- package/runtime/engine/chunk-5575APCJ.mjs +215 -0
- package/runtime/engine/chunk-5GUJZQF3.mjs +114 -0
- package/runtime/engine/chunk-5MXY3T75.mjs +428 -0
- package/runtime/engine/chunk-5TACQ2US.mjs +44 -0
- package/runtime/engine/chunk-66G4YEDT.mjs +3104 -0
- package/runtime/engine/chunk-67YO53WW.mjs +1426 -0
- package/runtime/engine/chunk-6GQRM7XY.mjs +87 -0
- package/runtime/engine/chunk-6JO72SPP.mjs +68 -0
- package/runtime/engine/chunk-6W653LXI.mjs +13 -0
- package/runtime/engine/chunk-7ITSMI3S.mjs +69 -0
- package/runtime/engine/chunk-7KUJ2H2S.mjs +128 -0
- package/runtime/engine/chunk-A5BMQ5IC.mjs +45 -0
- package/runtime/engine/chunk-ADF3UR6L.mjs +428 -0
- package/runtime/engine/chunk-AEBW7XZJ.mjs +4510 -0
- package/runtime/engine/chunk-AGPQ5XIV.mjs +156 -0
- package/runtime/engine/chunk-CPU4OZSX.mjs +753 -0
- package/runtime/engine/chunk-CSWPPWBL.mjs +50 -0
- package/runtime/engine/chunk-DPWXSMWO.mjs +53 -0
- package/runtime/engine/chunk-EAIELFKU.mjs +151 -0
- package/runtime/engine/chunk-EDU5CBKT.mjs +10 -0
- package/runtime/engine/chunk-EQCTAET7.mjs +173 -0
- package/runtime/engine/chunk-EQCXDF2Z.mjs +70 -0
- package/runtime/engine/chunk-F3G4UGV4.mjs +330 -0
- package/runtime/engine/chunk-F62NUNOO.mjs +26 -0
- package/runtime/engine/chunk-FKPNIFRP.mjs +2492 -0
- package/runtime/engine/chunk-FM23RGVI.mjs +81 -0
- package/runtime/engine/chunk-FW5AK4YP.mjs +1041 -0
- package/runtime/engine/chunk-GDWYAGWV.mjs +23 -0
- package/runtime/engine/chunk-GO5PZUYW.mjs +53 -0
- package/runtime/engine/chunk-GOLP7OSG.mjs +340 -0
- package/runtime/engine/chunk-GSLM44EF.mjs +242 -0
- package/runtime/engine/chunk-GYAJ7OX2.mjs +125 -0
- package/runtime/engine/chunk-I3GWR43K.mjs +14 -0
- package/runtime/engine/chunk-IFMOTJNU.mjs +106 -0
- package/runtime/engine/chunk-IKQKBE2G.mjs +128 -0
- package/runtime/engine/chunk-ITH2NEKM.mjs +282 -0
- package/runtime/engine/chunk-J6SDRCG4.mjs +96 -0
- package/runtime/engine/chunk-JODRNM3S.mjs +29596 -0
- package/runtime/engine/chunk-JUDKX53X.mjs +137 -0
- package/runtime/engine/chunk-K2YZVPJ4.mjs +827 -0
- package/runtime/engine/chunk-KEZJUXEE.mjs +151 -0
- package/runtime/engine/chunk-KVLTJFCH.mjs +234 -0
- package/runtime/engine/chunk-KX2PRQPS.mjs +126 -0
- package/runtime/engine/chunk-LEW5ZMLR.mjs +76 -0
- package/runtime/engine/chunk-LINVSJEM.mjs +175 -0
- package/runtime/engine/chunk-M7K2ICSM.mjs +11 -0
- package/runtime/engine/chunk-MZXDXSDC.mjs +292 -0
- package/runtime/engine/chunk-N2TA2IK2.mjs +678 -0
- package/runtime/engine/chunk-N4LTCKJP.mjs +695 -0
- package/runtime/engine/chunk-N6GCLOUX.mjs +13 -0
- package/runtime/engine/chunk-NAG2OXS5.mjs +37 -0
- package/runtime/engine/chunk-NNZ2QJUG.mjs +381 -0
- package/runtime/engine/chunk-NZPPLDNW.mjs +15 -0
- package/runtime/engine/chunk-ODWM57W6.mjs +138 -0
- package/runtime/engine/chunk-P5IIXAIE.mjs +23 -0
- package/runtime/engine/chunk-PBOXB2BV.mjs +6 -0
- package/runtime/engine/chunk-PMOJLN2P.mjs +8 -0
- package/runtime/engine/chunk-PZFMKFHO.mjs +180 -0
- package/runtime/engine/chunk-QL2TQX2N.mjs +114 -0
- package/runtime/engine/chunk-RITT2RSJ.mjs +258 -0
- package/runtime/engine/chunk-RODBVJ5M.mjs +135 -0
- package/runtime/engine/chunk-RW65MPVY.mjs +261 -0
- package/runtime/engine/chunk-S67UYPB6.mjs +25 -0
- package/runtime/engine/chunk-SVJCOUI3.mjs +47 -0
- package/runtime/engine/chunk-TCN3ZASV.mjs +957 -0
- package/runtime/engine/chunk-U2NRG6KC.mjs +32 -0
- package/runtime/engine/chunk-UM3F7HUV.mjs +432 -0
- package/runtime/engine/chunk-VWU7JJ3P.mjs +146 -0
- package/runtime/engine/chunk-WDTKPPMU.mjs +310 -0
- package/runtime/engine/chunk-WJOO4XTB.mjs +31 -0
- package/runtime/engine/chunk-XNFVL2OY.mjs +63 -0
- package/runtime/engine/chunk-XPWJXP2J.mjs +58 -0
- package/runtime/engine/chunk-Y3HSBJ3I.mjs +1132 -0
- package/runtime/engine/chunk-YMH4RYSX.mjs +317 -0
- package/runtime/engine/chunk-YNOMPSGS.mjs +8 -0
- package/runtime/engine/chunk-YRBAYTEZ.mjs +251 -0
- package/runtime/engine/chunk-YRHM272W.mjs +528 -0
- package/runtime/engine/chunk-ZQUZAGIQ.mjs +149 -0
- package/runtime/engine/chunk-ZXMM7QFP.mjs +176 -0
- package/runtime/engine/chunk-ZZJSIPV2.mjs +262 -0
- package/runtime/engine/composition.mjs +325 -0
- package/runtime/engine/document-local.mjs +504 -0
- package/runtime/engine/graph.json +4134 -0
- package/runtime/engine/index.mjs +265 -0
- package/runtime/engine/local-postgres-support.mjs +69 -0
- package/runtime/engine/local.mjs +3275 -0
- package/runtime/engine/pglite-directory-lock.mjs +8 -0
- package/runtime/engine/rag.mjs +11 -0
- package/runtime/engine/search.mjs +18 -0
- package/runtime/framework-migrations/foundation-bootstrap/rag.sql +115 -0
- package/runtime/framework-migrations/foundation-bootstrap/workflow.sql +194 -0
- package/runtime/framework-migrations/journal-bootstrap/migration.sql +26 -0
- package/runtime/framework-migrations/manifest.json +56 -0
- package/runtime/framework-migrations/rag/20261006111509_mushy_warhawk/migration.sql +121 -0
- package/runtime/framework-migrations/rag/20261013234621_rag_v2_lifecycle_markers/migration.sql +6 -0
- package/runtime/framework-migrations/workflow/20261006111508_perpetual_star_brand/migration.sql +31 -0
- package/runtime/runtime-metadata.json +27 -0
- package/runtime/tooling.mjs +10549 -10543
- package/scripts/bundle-runtime-config.mjs +23 -0
- package/scripts/bundle-runtime.mjs +100 -0
- package/scripts/bundle-runtime.test.mjs +33 -0
- package/scripts/bundle-shared.mjs +3 -0
- package/scripts/copy-dashboard.mjs +16 -0
- package/scripts/pre-publish-check.mjs +23 -11
- package/templateFeature/ai/ai-embedding-result.ts +82 -0
- package/templateFeature/ai/ai-facade.ts +24 -7
- package/templateFeature/ai/ai-provider.ts +17 -1
- package/templateFeature/ai/ai.ts +1 -0
- package/templateFeature/ai/manifest.json +4 -3
- package/templateFeature/reranker/manifest.json +1 -1
- package/templateFeature/reranker/reranker.ts +4 -3
- package/templateFeature/sso/sso-auth-callback.tsx +37 -5
- package/templateFeature/tools/manifest.json +2 -1
- package/templateFeature/tools/tools.ts +3 -3
- package/dashboard/assets/index-C6-BpKKR.css +0 -2
- package/runtime/server.mjs +0 -14320
- package/scripts/bundle-server.mjs +0 -223
- package/server/config.js +0 -1
- package/server/index.js +0 -1
- package/server/package.json +0 -6
package/runtime/config.mjs
CHANGED
|
@@ -19721,6 +19721,161 @@ function date4(params) {
|
|
|
19721
19721
|
return _coercedDate(ZodDate, params);
|
|
19722
19722
|
}
|
|
19723
19723
|
|
|
19724
|
+
// ../shared/dist/src/config/declaration-diagnostic.js
|
|
19725
|
+
import { randomUUID } from "node:crypto";
|
|
19726
|
+
function failProjectConfig(code, retryPrecondition, nextAction) {
|
|
19727
|
+
const diagnostic = Object.freeze({
|
|
19728
|
+
code,
|
|
19729
|
+
stage: "declaration",
|
|
19730
|
+
capability: "application",
|
|
19731
|
+
servingStarted: false,
|
|
19732
|
+
dataImpact: "none",
|
|
19733
|
+
projectFilesChanged: false,
|
|
19734
|
+
retryable: false,
|
|
19735
|
+
retryPrecondition,
|
|
19736
|
+
nextAction,
|
|
19737
|
+
correlationId: randomUUID()
|
|
19738
|
+
});
|
|
19739
|
+
throw Object.assign(new Error([
|
|
19740
|
+
`Code: ${diagnostic.code}`,
|
|
19741
|
+
`Stage: ${diagnostic.stage}`,
|
|
19742
|
+
`Capability: ${diagnostic.capability}`,
|
|
19743
|
+
"Serving started: no",
|
|
19744
|
+
"Data impact: none",
|
|
19745
|
+
"Project files/dependencies changed: no",
|
|
19746
|
+
"Retryable: no",
|
|
19747
|
+
`Retry precondition: ${diagnostic.retryPrecondition}`,
|
|
19748
|
+
`Next action: ${diagnostic.nextAction}`,
|
|
19749
|
+
`Correlation: ${diagnostic.correlationId}`
|
|
19750
|
+
].join("\n")), { code, diagnostic });
|
|
19751
|
+
}
|
|
19752
|
+
|
|
19753
|
+
// ../shared/dist/src/codegen/domain/standalone-diagnostics.js
|
|
19754
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
19755
|
+
function validateStandaloneOutput(config2) {
|
|
19756
|
+
if (!config2 || typeof config2 !== "object")
|
|
19757
|
+
return;
|
|
19758
|
+
const experimental = config2.experimental;
|
|
19759
|
+
if (!experimental || typeof experimental !== "object" || Array.isArray(experimental))
|
|
19760
|
+
return;
|
|
19761
|
+
const output2 = experimental.output;
|
|
19762
|
+
if (output2 === void 0 || output2 === "standalone")
|
|
19763
|
+
return;
|
|
19764
|
+
const diagnostic = {
|
|
19765
|
+
code: "RUNTIME_STANDALONE_TARGET_UNSUPPORTED",
|
|
19766
|
+
stage: "declaration",
|
|
19767
|
+
capability: "standalone",
|
|
19768
|
+
servingStarted: false,
|
|
19769
|
+
dataImpact: "none",
|
|
19770
|
+
projectFilesChanged: false,
|
|
19771
|
+
retryable: false,
|
|
19772
|
+
retryPrecondition: "Correct the experimental output declaration before retrying.",
|
|
19773
|
+
nextAction: 'Set experimental.output to "standalone" or remove it, then rerun gencow codegen.',
|
|
19774
|
+
correlationId: randomUUID2()
|
|
19775
|
+
};
|
|
19776
|
+
throw Object.assign(new Error([
|
|
19777
|
+
`Code: ${diagnostic.code}`,
|
|
19778
|
+
`Stage: ${diagnostic.stage}`,
|
|
19779
|
+
`Capability: ${diagnostic.capability}`,
|
|
19780
|
+
"Serving started: no",
|
|
19781
|
+
"Data impact: none",
|
|
19782
|
+
"Project files/dependencies changed: no",
|
|
19783
|
+
"Retryable: no",
|
|
19784
|
+
`Retry precondition: ${diagnostic.retryPrecondition}`,
|
|
19785
|
+
`Next action: ${diagnostic.nextAction}`,
|
|
19786
|
+
`Correlation: ${diagnostic.correlationId}`
|
|
19787
|
+
].join("\n")), { code: diagnostic.code, diagnostic: Object.freeze(diagnostic) });
|
|
19788
|
+
}
|
|
19789
|
+
|
|
19790
|
+
// ../shared/dist/src/config/local-features.js
|
|
19791
|
+
var DEFAULT_LOCAL_STORAGE_PATH = "./.gencow/uploads";
|
|
19792
|
+
function isAzureBlobAccountUrl(value) {
|
|
19793
|
+
try {
|
|
19794
|
+
const url2 = new URL(value);
|
|
19795
|
+
return url2.protocol === "https:" && !url2.username && !url2.password && url2.pathname === "/" && !url2.search && !url2.hash;
|
|
19796
|
+
} catch {
|
|
19797
|
+
return false;
|
|
19798
|
+
}
|
|
19799
|
+
}
|
|
19800
|
+
var uploadLimits = {
|
|
19801
|
+
maxFileSizeBytes: external_exports.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
19802
|
+
maxMultipartBodyBytes: external_exports.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
19803
|
+
maxFilesPerRequest: external_exports.number().int().positive().max(16).optional()
|
|
19804
|
+
};
|
|
19805
|
+
var localAdapterInputs = {
|
|
19806
|
+
database: external_exports.object({ adapter: external_exports.enum(["postgres", "pglite"]) }).strict().optional(),
|
|
19807
|
+
rag: external_exports.union([external_exports.boolean(), external_exports.object({ adapter: external_exports.literal("pgvector").optional() }).strict()]).optional(),
|
|
19808
|
+
search: external_exports.union([external_exports.boolean(), external_exports.object({ adapter: external_exports.literal("postgres").optional() }).strict()]).optional(),
|
|
19809
|
+
storage: external_exports.discriminatedUnion("adapter", [
|
|
19810
|
+
external_exports.object({ adapter: external_exports.literal("filesystem"), path: external_exports.string().trim().min(1).optional(), ...uploadLimits }).strict(),
|
|
19811
|
+
external_exports.object({
|
|
19812
|
+
adapter: external_exports.literal("azure-blob"),
|
|
19813
|
+
accountUrl: external_exports.string().url().refine(isAzureBlobAccountUrl),
|
|
19814
|
+
container: external_exports.string().trim().min(3).max(63).regex(/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/u),
|
|
19815
|
+
...uploadLimits
|
|
19816
|
+
}).strict()
|
|
19817
|
+
]).optional()
|
|
19818
|
+
};
|
|
19819
|
+
var stableLocalFeaturesInput = external_exports.object({
|
|
19820
|
+
...localAdapterInputs,
|
|
19821
|
+
dashboard: external_exports.union([external_exports.boolean(), external_exports.object({ enabled: external_exports.boolean().optional() }).strict()]).optional()
|
|
19822
|
+
}).optional();
|
|
19823
|
+
var legacyLocalFeaturesInput = external_exports.object({
|
|
19824
|
+
...localAdapterInputs,
|
|
19825
|
+
dashboard: external_exports.object({
|
|
19826
|
+
enabled: external_exports.boolean().optional(),
|
|
19827
|
+
path: external_exports.string().min(1).optional(),
|
|
19828
|
+
port: external_exports.number().int().min(1).max(65535).optional()
|
|
19829
|
+
}).optional(),
|
|
19830
|
+
seed: external_exports.object({ enabled: external_exports.boolean().optional() }).optional(),
|
|
19831
|
+
reset: external_exports.object({ enabled: external_exports.boolean().optional() }).optional()
|
|
19832
|
+
}).optional();
|
|
19833
|
+
function validateStableLocalFeatures(config2) {
|
|
19834
|
+
if (!config2 || typeof config2 !== "object" || !Object.hasOwn(config2, "localFeatures"))
|
|
19835
|
+
return;
|
|
19836
|
+
const parsed = stableLocalFeaturesInput.safeParse(config2.localFeatures);
|
|
19837
|
+
if (parsed.success)
|
|
19838
|
+
return;
|
|
19839
|
+
const key = parsed.error.issues[0]?.path[0];
|
|
19840
|
+
const field = typeof key === "string" && (Object.hasOwn(localAdapterInputs, key) || key === "dashboard") ? key : void 0;
|
|
19841
|
+
failProjectConfig(field === "rag" ? "CONFIG_LOCAL_RAG_INVALID" : "CONFIG_LOCAL_FEATURES_INVALID", "Correct the local feature configuration before retrying.", field === "rag" ? 'Set localFeatures.rag to true, false, {}, or { adapter: "pgvector" } in gencow.config.js or gencow.config.ts, then rerun the command.' : `Correct localFeatures${field ? `.${field}` : ""} in gencow.config.js or gencow.config.ts, then rerun the command.`);
|
|
19842
|
+
}
|
|
19843
|
+
function normalizeLocalFeatures(config2) {
|
|
19844
|
+
const stable = config2.localFeatures;
|
|
19845
|
+
const legacy = config2.experimental?.localFeatures;
|
|
19846
|
+
const database = stable?.database ?? legacy?.database;
|
|
19847
|
+
const rag = stable?.rag ?? legacy?.rag;
|
|
19848
|
+
const search = stable?.search ?? legacy?.search;
|
|
19849
|
+
const dashboard = stable?.dashboard ?? legacy?.dashboard?.enabled ?? (legacy?.dashboard === void 0 ? void 0 : {});
|
|
19850
|
+
const storage = stable?.storage ?? legacy?.storage;
|
|
19851
|
+
return {
|
|
19852
|
+
...database === void 0 ? {} : { database },
|
|
19853
|
+
...rag === void 0 ? {} : { rag },
|
|
19854
|
+
...search === void 0 ? {} : { search },
|
|
19855
|
+
...dashboard === void 0 ? {} : { dashboard },
|
|
19856
|
+
...storage === void 0 ? {} : {
|
|
19857
|
+
storage: storage.adapter === "filesystem" ? {
|
|
19858
|
+
...storage,
|
|
19859
|
+
path: storage.path ?? (stable?.storage ? void 0 : config2.storage) ?? DEFAULT_LOCAL_STORAGE_PATH
|
|
19860
|
+
} : storage
|
|
19861
|
+
}
|
|
19862
|
+
};
|
|
19863
|
+
}
|
|
19864
|
+
function resolveLocalRuntimeFeatures(config2, environment) {
|
|
19865
|
+
const features = normalizeLocalFeatures(config2);
|
|
19866
|
+
return {
|
|
19867
|
+
...features,
|
|
19868
|
+
database: features.database ?? {
|
|
19869
|
+
adapter: environment.DATABASE_URL?.trim() ? "postgres" : "pglite"
|
|
19870
|
+
},
|
|
19871
|
+
search: features.search ?? true,
|
|
19872
|
+
storage: features.storage ?? { adapter: "filesystem", path: config2.storage ?? DEFAULT_LOCAL_STORAGE_PATH },
|
|
19873
|
+
dashboard: {
|
|
19874
|
+
enabled: typeof features.dashboard === "boolean" ? features.dashboard : features.dashboard?.enabled !== false
|
|
19875
|
+
}
|
|
19876
|
+
};
|
|
19877
|
+
}
|
|
19878
|
+
|
|
19724
19879
|
// ../shared/dist/src/config/index.js
|
|
19725
19880
|
function isLocalHttpOrigin(url2) {
|
|
19726
19881
|
return url2.protocol === "http:" && (url2.hostname === "localhost" || url2.hostname === "127.0.0.1") && url2.port !== "";
|
|
@@ -19795,7 +19950,50 @@ var cloudFeaturesInput = external_exports.object({
|
|
|
19795
19950
|
ai: cloudFeatureToggleInput.optional(),
|
|
19796
19951
|
admin: cloudFeatureToggleInput.optional()
|
|
19797
19952
|
}).catchall(cloudFeatureToggleInput).optional();
|
|
19953
|
+
var experimentalInput = external_exports.object({
|
|
19954
|
+
output: external_exports.literal("standalone").optional(),
|
|
19955
|
+
standaloneEntryDir: external_exports.string().trim().min(1).optional(),
|
|
19956
|
+
localFeatures: legacyLocalFeaturesInput
|
|
19957
|
+
}).optional();
|
|
19958
|
+
function validateExperimentalConfig(config2) {
|
|
19959
|
+
if (!config2 || typeof config2 !== "object" || !Object.hasOwn(config2, "experimental"))
|
|
19960
|
+
return;
|
|
19961
|
+
const parsed = experimentalInput.safeParse(config2.experimental);
|
|
19962
|
+
if (parsed.success)
|
|
19963
|
+
return;
|
|
19964
|
+
const safeKeys = /* @__PURE__ */ new Set([
|
|
19965
|
+
"output",
|
|
19966
|
+
"standaloneEntryDir",
|
|
19967
|
+
"localFeatures",
|
|
19968
|
+
"database",
|
|
19969
|
+
"adapter",
|
|
19970
|
+
"rag",
|
|
19971
|
+
"search",
|
|
19972
|
+
"storage",
|
|
19973
|
+
"accountUrl",
|
|
19974
|
+
"container",
|
|
19975
|
+
"maxFileSizeBytes",
|
|
19976
|
+
"maxMultipartBodyBytes",
|
|
19977
|
+
"maxFilesPerRequest",
|
|
19978
|
+
"dashboard",
|
|
19979
|
+
"enabled",
|
|
19980
|
+
"path",
|
|
19981
|
+
"port",
|
|
19982
|
+
"seed",
|
|
19983
|
+
"reset"
|
|
19984
|
+
]);
|
|
19985
|
+
const issuePath = parsed.error.issues[0]?.path ?? [];
|
|
19986
|
+
const field = issuePath.every((part) => typeof part === "string" && safeKeys.has(part)) ? ["experimental", ...issuePath].join(".") : "experimental";
|
|
19987
|
+
failProjectConfig("CONFIG_EXPERIMENTAL_INVALID", "Correct the experimental configuration before retrying.", `Correct ${field} in gencow.config.js or gencow.config.ts, then rerun the command.`);
|
|
19988
|
+
}
|
|
19989
|
+
function validateProjectFeatures(config2) {
|
|
19990
|
+
validateStandaloneOutput(config2);
|
|
19991
|
+
validateExperimentalConfig(config2);
|
|
19992
|
+
validateStableLocalFeatures(config2);
|
|
19993
|
+
}
|
|
19798
19994
|
var rawConfigSchema = external_exports.object({
|
|
19995
|
+
experimental: experimentalInput,
|
|
19996
|
+
localFeatures: stableLocalFeaturesInput,
|
|
19799
19997
|
rootDir: external_exports.string().optional(),
|
|
19800
19998
|
functionsDir: external_exports.string().optional().describe("Deprecated \u2014 use `rootDir`."),
|
|
19801
19999
|
envFile: external_exports.string().optional(),
|
|
@@ -19821,7 +20019,7 @@ var GENCOW_CONFIG_DEFAULTS = Object.freeze({
|
|
|
19821
20019
|
envFile: "./gencow/.env",
|
|
19822
20020
|
schema: "./gencow/schema.ts",
|
|
19823
20021
|
codegen: { clientOutDir: "./src/gencow", authSchema: true, importExtension: "none" },
|
|
19824
|
-
storage:
|
|
20022
|
+
storage: DEFAULT_LOCAL_STORAGE_PATH,
|
|
19825
20023
|
db: { url: "./.gencow/data" },
|
|
19826
20024
|
port: 5456,
|
|
19827
20025
|
frontendOrigins: [],
|
|
@@ -19901,6 +20099,20 @@ var gencowConfigSchema = rawConfigSchema.transform((v) => {
|
|
|
19901
20099
|
frontendOrigins: (v.frontendOrigins ?? []).map((origin) => normalizeFrontendOrigin(origin)),
|
|
19902
20100
|
trustedOrigins: v.trustedOrigins ?? []
|
|
19903
20101
|
};
|
|
20102
|
+
const localFeatures = normalizeLocalFeatures(v);
|
|
20103
|
+
if (Object.keys(localFeatures).length)
|
|
20104
|
+
result.localFeatures = localFeatures;
|
|
20105
|
+
if (v.experimental) {
|
|
20106
|
+
const { localFeatures: legacy, ...experimental } = v.experimental;
|
|
20107
|
+
result.experimental = {
|
|
20108
|
+
...experimental,
|
|
20109
|
+
...legacy ? { localFeatures: {
|
|
20110
|
+
...legacy.seed === void 0 ? {} : { seed: legacy.seed },
|
|
20111
|
+
...legacy.reset === void 0 ? {} : { reset: legacy.reset }
|
|
20112
|
+
} } : {},
|
|
20113
|
+
...experimental.output === "standalone" && experimental.standaloneEntryDir === void 0 ? { standaloneEntryDir: "./.gencow/build/gencow" } : {}
|
|
20114
|
+
};
|
|
20115
|
+
}
|
|
19904
20116
|
if (clients?.length)
|
|
19905
20117
|
result.clients = clients;
|
|
19906
20118
|
if (v.deploy?.app)
|
|
@@ -19925,5 +20137,9 @@ export {
|
|
|
19925
20137
|
isAnalyzerAuditorConfigured,
|
|
19926
20138
|
normalizeFrontendOrigin,
|
|
19927
20139
|
resolveConfiguredAuditorImplementation,
|
|
19928
|
-
|
|
20140
|
+
resolveLocalRuntimeFeatures,
|
|
20141
|
+
shouldSyncManagedDependencies,
|
|
20142
|
+
validateExperimentalConfig,
|
|
20143
|
+
validateProjectFeatures,
|
|
20144
|
+
validateStandaloneOutput
|
|
19929
20145
|
};
|
|
@@ -12,7 +12,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
12
12
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
13
|
});
|
|
14
14
|
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
-
|
|
15
|
+
try {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw mod = 0, e;
|
|
19
|
+
}
|
|
16
20
|
};
|
|
17
21
|
var __copyProps = (to, from, except, desc) => {
|
|
18
22
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ragOperationError,
|
|
3
|
+
snapshotRagScopeInput
|
|
4
|
+
} from "./chunk-5TACQ2US.mjs";
|
|
5
|
+
import {
|
|
6
|
+
RuntimeDiagnosticError
|
|
7
|
+
} from "./chunk-AEBW7XZJ.mjs";
|
|
8
|
+
|
|
9
|
+
// ../runtime/dist/rag/operations-diagnostic.js
|
|
10
|
+
var actions = {
|
|
11
|
+
RAG_OPERATIONS_INPUT_INVALID: "Correct the operation filters or fixtures. Supply a valid scope, finite limit, known mode/operation and required source IDs/full-rebuild confirmation. No provider or RAG write was admitted.",
|
|
12
|
+
RAG_OPERATIONS_STATE_INVALID: "Inspect the same corpus and selected database readiness. Preserve existing sources, jobs and metrics; do not edit internal rows or start replacement provider work.",
|
|
13
|
+
RAG_OPERATIONS_OBSERVATION_UNAVAILABLE: "Restore selected database readiness and read access, then inspect the same corpus. This read changed no data; do not recreate framework tables.",
|
|
14
|
+
RAG_OPERATIONS_SIZE_LIMIT_EXCEEDED: "Reduce fixtures, queries, claims or source IDs; filter summary by corpus or plan smaller explicit source sets. Inputs are limited to 128 fixtures/1 MiB, 8192 plan sources and 1024 summary scopes. No new provider work was admitted for input rejection.",
|
|
15
|
+
RAG_EVALUATION_CAPABILITY_UNAVAILABLE: "Select and restore the required search/grounding capability before evaluating. Summary, metrics and reindex planning remain available; do not enable a paid provider implicitly.",
|
|
16
|
+
RAG_EVALUATION_OUTCOME_UNKNOWN: "Inspect rag_operations.metrics with operation evaluate for the same evaluation receipt before another explicit evaluation. Provider work or metrics may have committed; do not blindly repeat calls or infer exactly-once charging."
|
|
17
|
+
};
|
|
18
|
+
function ragOperationsError(code, dataImpact = "none", evaluationId) {
|
|
19
|
+
return new RuntimeDiagnosticError({
|
|
20
|
+
code,
|
|
21
|
+
stage: "request",
|
|
22
|
+
capability: code === "RAG_OPERATIONS_OBSERVATION_UNAVAILABLE" ? "database" : "application",
|
|
23
|
+
servingStarted: "unchanged",
|
|
24
|
+
dataImpact,
|
|
25
|
+
retryable: false,
|
|
26
|
+
retryPrecondition: code === "RAG_EVALUATION_OUTCOME_UNKNOWN" ? "Establish the prior provider/metric outcome for this same evaluation before a new action." : "Correct the named input, scope, state or selected capability before resubmitting this operation.",
|
|
27
|
+
nextAction: `${actions[code]}${evaluationId && /^[a-f0-9-]{36}$/u.test(evaluationId) ? ` Evaluation receipt: ${evaluationId}.` : ""}`
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ../runtime/dist/rag/operations-scope.js
|
|
32
|
+
function createRagOperationsScope(requireIdentity) {
|
|
33
|
+
let owner;
|
|
34
|
+
function active() {
|
|
35
|
+
const identity = requireIdentity();
|
|
36
|
+
if (!identity)
|
|
37
|
+
throw new RuntimeDiagnosticError({
|
|
38
|
+
code: "RUNTIME_AUTHENTICATION_REQUIRED",
|
|
39
|
+
stage: "request",
|
|
40
|
+
capability: "auth",
|
|
41
|
+
servingStarted: "unchanged",
|
|
42
|
+
dataImpact: "none",
|
|
43
|
+
retryable: false,
|
|
44
|
+
retryPrecondition: "Authenticate before using RAG operations.",
|
|
45
|
+
nextAction: "Sign in as the intended corpus owner. No operation was admitted."
|
|
46
|
+
});
|
|
47
|
+
owner ??= identity.id;
|
|
48
|
+
if (owner !== identity.id)
|
|
49
|
+
throw ragOperationError("RAG_SCOPE_FORBIDDEN");
|
|
50
|
+
return owner;
|
|
51
|
+
}
|
|
52
|
+
function scope(input) {
|
|
53
|
+
const user = active();
|
|
54
|
+
let captured;
|
|
55
|
+
try {
|
|
56
|
+
captured = snapshotRagScopeInput(input);
|
|
57
|
+
} catch {
|
|
58
|
+
throw ragOperationsError("RAG_OPERATIONS_INPUT_INVALID");
|
|
59
|
+
}
|
|
60
|
+
const ownerUserId = captured.ownerUserId ?? (captured.visibility === "private" ? user : null);
|
|
61
|
+
if (ownerUserId !== null && ownerUserId !== user)
|
|
62
|
+
throw ragOperationError("RAG_SCOPE_FORBIDDEN");
|
|
63
|
+
return Object.freeze({
|
|
64
|
+
corpus: captured.corpus,
|
|
65
|
+
visibility: captured.visibility,
|
|
66
|
+
ownerUserId
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return Object.freeze({ active, scope });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ../runtime/dist/adapters/rag/pgvector/operations-scope.js
|
|
73
|
+
import { sql } from "drizzle-orm";
|
|
74
|
+
function ragOperationsPredicate(alias, scope) {
|
|
75
|
+
const prefix = sql.raw(alias);
|
|
76
|
+
return sql`${prefix}.corpus=${scope.corpus} AND ${prefix}.visibility_scope=${scope.visibility} AND ${prefix}.owner_user_id IS NOT DISTINCT FROM ${scope.ownerUserId}`;
|
|
77
|
+
}
|
|
78
|
+
var ragMetricKinds = ["ingest", "retrieve", "answer", "reindex", "evaluate"];
|
|
79
|
+
var validRagMetric = sql`m.visibility_scope IN ('private','shared','public') AND (m.owner_user_id IS NOT NULL OR m.visibility_scope IN ('shared','public'))
|
|
80
|
+
AND m.operation IN ('ingest','retrieve','answer','reindex','evaluate') AND m.metric_value NOT IN ('NaN'::float8,'Infinity'::float8,'-Infinity'::float8)
|
|
81
|
+
AND isfinite(m.recorded_at) AND octet_length(m.metadata::text)<=65536 AND octet_length(m.metric_name)<=256
|
|
82
|
+
AND (m.unit IS NULL OR m.unit IN ('ms','count','tokens','usd'))`;
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
ragOperationsError,
|
|
86
|
+
createRagOperationsScope,
|
|
87
|
+
ragOperationsPredicate,
|
|
88
|
+
ragMetricKinds,
|
|
89
|
+
validRagMetric
|
|
90
|
+
};
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import {
|
|
2
|
+
administrationMetadata,
|
|
3
|
+
captureAzureNamespaceOption,
|
|
4
|
+
resolveRuntimeUploadLimits,
|
|
5
|
+
storageAdministrationMetadataInvalid,
|
|
6
|
+
storageAdministrationReadLimit
|
|
7
|
+
} from "./chunk-N4LTCKJP.mjs";
|
|
8
|
+
import {
|
|
9
|
+
runtimeStartupError
|
|
10
|
+
} from "./chunk-IFMOTJNU.mjs";
|
|
11
|
+
import {
|
|
12
|
+
RUNTIME_REQUEST_CORRELATION_HEADER,
|
|
13
|
+
RuntimeDiagnosticError,
|
|
14
|
+
runtimeRequestCorrelation
|
|
15
|
+
} from "./chunk-AEBW7XZJ.mjs";
|
|
16
|
+
|
|
17
|
+
// ../runtime/dist/adapters/storage/config.js
|
|
18
|
+
function parseRuntimeStorageConfig(input, environment = {}) {
|
|
19
|
+
const namespace = input.adapter === "azure-blob" ? captureAzureNamespaceOption(input) : void 0;
|
|
20
|
+
const limits = resolveRuntimeUploadLimits(input);
|
|
21
|
+
const required = environment.GENCOW_STORAGE_REQUIRE_READ_GRANT === "1";
|
|
22
|
+
const appName = environment.GENCOW_APP_NAME;
|
|
23
|
+
const readGrantSecret = environment.GENCOW_INTERNAL_TOKEN;
|
|
24
|
+
if (required && (!appName || !readGrantSecret))
|
|
25
|
+
throw runtimeStartupError("RUNTIME_STORAGE_READ_POLICY_MISSING", "Supply the captured storage app/signing binding before starting grant-protected storage; retain existing keys and namespace.", "none", "storage");
|
|
26
|
+
const readPolicy = appName || readGrantSecret || required ? Object.freeze({
|
|
27
|
+
appName,
|
|
28
|
+
readGrantSecret,
|
|
29
|
+
requireReadGrant: required,
|
|
30
|
+
maxFileSizeBytes: limits.maxFileSizeBytes
|
|
31
|
+
}) : void 0;
|
|
32
|
+
if (input.adapter === "filesystem" && input.directory)
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
adapter: "filesystem",
|
|
35
|
+
directory: input.directory,
|
|
36
|
+
image: resolveRuntimeFilesystemImagePolicy(input.image),
|
|
37
|
+
...limits,
|
|
38
|
+
...readPolicy ? { readPolicy } : {}
|
|
39
|
+
});
|
|
40
|
+
if (input.adapter === "azure-blob" && isAzureAccountUrl(input.accountUrl) && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/u.test(input.container)) {
|
|
41
|
+
const tenantId = environment.AZURE_TENANT_ID;
|
|
42
|
+
const clientId = environment.AZURE_CLIENT_ID;
|
|
43
|
+
const clientSecret = environment.AZURE_CLIENT_SECRET;
|
|
44
|
+
if (!tenantId || !clientId || !clientSecret)
|
|
45
|
+
throw runtimeStartupError("RUNTIME_STORAGE_CREDENTIALS_MISSING", "Supply the selected Azure service-principal credentials through the trusted launcher configuration before restarting.", "none", "storage");
|
|
46
|
+
return Object.freeze({
|
|
47
|
+
...limits,
|
|
48
|
+
adapter: input.adapter,
|
|
49
|
+
accountUrl: input.accountUrl,
|
|
50
|
+
container: input.container,
|
|
51
|
+
namespace,
|
|
52
|
+
credential: Object.freeze({ tenantId, clientId, clientSecret }),
|
|
53
|
+
...readPolicy ? { readPolicy } : {}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
throw runtimeStartupError("RUNTIME_STORAGE_CONFIG_INVALID", "Configure a supported Runtime storage adapter and restart.", "none", "storage");
|
|
57
|
+
}
|
|
58
|
+
function resolveRuntimeFilesystemImagePolicy(value) {
|
|
59
|
+
if (value === void 0)
|
|
60
|
+
return Object.freeze({ enabled: true });
|
|
61
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
62
|
+
throw runtimeStartupError("RUNTIME_STORAGE_CONFIG_INVALID", "Set only the optional filesystem image enabled flag in trusted Runtime storage configuration, then restart.");
|
|
63
|
+
let enabled = true;
|
|
64
|
+
try {
|
|
65
|
+
const prototype = Object.getPrototypeOf(value);
|
|
66
|
+
const keys = Reflect.ownKeys(value);
|
|
67
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, "enabled");
|
|
68
|
+
if (prototype !== Object.prototype && prototype !== null || keys.some((key) => key !== "enabled") || descriptor !== void 0 && (!Object.hasOwn(descriptor, "value") || typeof descriptor.value !== "boolean"))
|
|
69
|
+
throw new Error("Invalid filesystem image selection");
|
|
70
|
+
if (descriptor)
|
|
71
|
+
enabled = descriptor.value;
|
|
72
|
+
} catch {
|
|
73
|
+
throw runtimeStartupError("RUNTIME_STORAGE_CONFIG_INVALID", "Set only the optional filesystem image enabled flag in trusted Runtime storage configuration, then restart.");
|
|
74
|
+
}
|
|
75
|
+
return Object.freeze({ enabled });
|
|
76
|
+
}
|
|
77
|
+
function isAzureAccountUrl(value) {
|
|
78
|
+
try {
|
|
79
|
+
const url = new URL(value);
|
|
80
|
+
return url.protocol === "https:" && !url.username && !url.password && url.pathname === "/" && !url.search && !url.hash;
|
|
81
|
+
} catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ../runtime/dist/adapters/storage/content-response.js
|
|
87
|
+
function safeStorageContentMetadata(file) {
|
|
88
|
+
return administrationMetadata(file, file.createdAt === void 0 ? void 0 : new Date(file.createdAt), file.source);
|
|
89
|
+
}
|
|
90
|
+
var storageObjectNotFoundFields = {
|
|
91
|
+
code: "RUNTIME_STORAGE_OBJECT_NOT_FOUND",
|
|
92
|
+
stage: "request",
|
|
93
|
+
capability: "storage",
|
|
94
|
+
servingStarted: "unchanged",
|
|
95
|
+
dataImpact: "none",
|
|
96
|
+
retryable: false
|
|
97
|
+
};
|
|
98
|
+
function publicStorageObjectNotFound() {
|
|
99
|
+
return new RuntimeDiagnosticError({
|
|
100
|
+
...storageObjectNotFoundFields,
|
|
101
|
+
retryPrecondition: "For private storage, obtain a current short-lived grant from the selected app's trusted Storage API; for public storage, ask the app owner to confirm public access is intended.",
|
|
102
|
+
nextAction: "If authorized in the app, call ctx.storage.createReadGrant for the intended object and share the short-lived URL only with its recipient. Otherwise ask the app owner for an authorized grant. Do not make private storage public just to bypass a missing, expired, or invalid grant; no bytes were returned."
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function publicStorageObjectNotFoundResponse(request, status = 404) {
|
|
106
|
+
const correlationId = runtimeRequestCorrelation(request);
|
|
107
|
+
const headers = {
|
|
108
|
+
"cache-control": "no-store",
|
|
109
|
+
"content-type": "application/json",
|
|
110
|
+
[RUNTIME_REQUEST_CORRELATION_HEADER]: correlationId
|
|
111
|
+
};
|
|
112
|
+
if (request.method === "HEAD")
|
|
113
|
+
return new Response(null, { status, headers });
|
|
114
|
+
return Response.json({
|
|
115
|
+
error: "The storage object was not found.",
|
|
116
|
+
...storageObjectNotFoundFields,
|
|
117
|
+
retryPrecondition: "Do not retry this link. For private storage, first open the file through the app from an active authorized session to request a fresh short-lived link; for public storage, ask the app owner to verify intended access.",
|
|
118
|
+
nextAction: "Open the file through the app while signed into an active authorized session to get a fresh link. If the file should be public, ask the app owner to verify that setting. No bytes were returned, and file data and metadata were unchanged; do not make private storage public to bypass a missing, expired, or invalid link.",
|
|
119
|
+
correlationId
|
|
120
|
+
}, { status, headers });
|
|
121
|
+
}
|
|
122
|
+
async function storageContentResponse(port, id, request, publicOnly = false, notFound = publicStorageObjectNotFound) {
|
|
123
|
+
if (publicOnly && (!isSupportedReadRequest(request) || (await port.inspect(id))?.visibility !== "public"))
|
|
124
|
+
throw notFound();
|
|
125
|
+
const content = await port.content(id);
|
|
126
|
+
if (!content)
|
|
127
|
+
throw notFound();
|
|
128
|
+
const metadata = safeStorageContentMetadata(content.metadata);
|
|
129
|
+
if (metadata.id !== id || !(content.bytes instanceof Uint8Array) || content.bytes.byteLength !== metadata.size)
|
|
130
|
+
throw storageAdministrationMetadataInvalid();
|
|
131
|
+
if (metadata.size > port.limits.maxFileSizeBytes)
|
|
132
|
+
throw storageAdministrationReadLimit(port.limits.maxFileSizeBytes);
|
|
133
|
+
if (publicOnly) {
|
|
134
|
+
const currentValue = await port.inspect(id);
|
|
135
|
+
if (!currentValue || metadata.visibility !== "public" || currentValue.visibility !== "public")
|
|
136
|
+
throw notFound();
|
|
137
|
+
const current = safeStorageContentMetadata(currentValue);
|
|
138
|
+
if (JSON.stringify(current) !== JSON.stringify(metadata))
|
|
139
|
+
throw notFound();
|
|
140
|
+
}
|
|
141
|
+
return formatStorageContentResponse(metadata, content.bytes, request);
|
|
142
|
+
}
|
|
143
|
+
function isSupportedReadRequest(request) {
|
|
144
|
+
return (request.method === "GET" || request.method === "HEAD") && request.body === null;
|
|
145
|
+
}
|
|
146
|
+
function formatStorageContentResponse(metadata, bytes, request, disposition, varyAccept = false) {
|
|
147
|
+
const type = metadata.type.split(";", 1)[0].trim().toLowerCase();
|
|
148
|
+
const safeType = /^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/u.test(type) ? type : "application/octet-stream";
|
|
149
|
+
const inline = disposition === "attachment" ? false : disposition === "inline" ? true : /^(?:image\/(?:png|jpeg|gif|webp|avif)|audio\/(?:mpeg|wav|ogg)|video\/(?:mp4|webm))$/u.test(safeType);
|
|
150
|
+
const filename = Array.from(Buffer.from(metadata.name, "utf8").toString("utf8")).slice(0, 160).join("");
|
|
151
|
+
const ascii = filename.replace(/[^a-zA-Z0-9._ -]/gu, "_").slice(0, 160) || "download";
|
|
152
|
+
const encoded = encodeURIComponent(filename).replace(/['()*]/gu, (char) => "%" + char.charCodeAt(0).toString(16).toUpperCase());
|
|
153
|
+
const headers = {
|
|
154
|
+
"content-type": safeType,
|
|
155
|
+
"content-length": String(metadata.size),
|
|
156
|
+
"cache-control": "no-store",
|
|
157
|
+
"content-disposition": `${inline ? "inline" : "attachment"}; filename="${ascii}"; filename*=UTF-8''${encoded}`,
|
|
158
|
+
"x-content-type-options": "nosniff",
|
|
159
|
+
"x-frame-options": "DENY",
|
|
160
|
+
"content-security-policy": "sandbox; default-src 'none'; base-uri 'none'; frame-ancestors 'none'"
|
|
161
|
+
};
|
|
162
|
+
if (varyAccept)
|
|
163
|
+
headers.vary = "Accept";
|
|
164
|
+
return new Response(request.method === "HEAD" ? null : bytes, { headers });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ../runtime/dist/adapters/storage/image-transform-policy.js
|
|
168
|
+
var runtimeFilesystemImagePolicy = Object.freeze({
|
|
169
|
+
maxInputBytes: 16 * 1024 * 1024,
|
|
170
|
+
maxOutputBytes: 16 * 1024 * 1024,
|
|
171
|
+
maxDecodedPixels: 4096 * 4096,
|
|
172
|
+
maxDimension: 4096,
|
|
173
|
+
maxCacheBytes: 128 * 1024 * 1024,
|
|
174
|
+
maxCacheEntries: 1e3,
|
|
175
|
+
maxActive: 1,
|
|
176
|
+
maxQueued: 8,
|
|
177
|
+
queueWaitMs: 750,
|
|
178
|
+
workTimeoutMs: 3e3,
|
|
179
|
+
autoQuality: 80
|
|
180
|
+
});
|
|
181
|
+
var transformNames = ["w", "h", "q", "f", "fit"];
|
|
182
|
+
var formats = /* @__PURE__ */ new Set(["webp", "avif", "jpeg", "png"]);
|
|
183
|
+
var fits = /* @__PURE__ */ new Set(["cover", "contain", "fill", "inside"]);
|
|
184
|
+
function integerValue(value, minimum, maximum) {
|
|
185
|
+
if (!/^[0-9]+$/u.test(value))
|
|
186
|
+
return void 0;
|
|
187
|
+
const parsed = Number(value);
|
|
188
|
+
return Number.isSafeInteger(parsed) && parsed >= minimum && parsed <= maximum ? parsed : void 0;
|
|
189
|
+
}
|
|
190
|
+
function parseExplicitTransform(url) {
|
|
191
|
+
const values = /* @__PURE__ */ new Map();
|
|
192
|
+
for (const name of transformNames) {
|
|
193
|
+
const found = url.searchParams.getAll(name);
|
|
194
|
+
if (found.length > 1)
|
|
195
|
+
return "invalid";
|
|
196
|
+
if (found.length === 1)
|
|
197
|
+
values.set(name, found[0]);
|
|
198
|
+
}
|
|
199
|
+
if (values.size === 0)
|
|
200
|
+
return "none";
|
|
201
|
+
const width = values.has("w") ? integerValue(values.get("w"), 1, runtimeFilesystemImagePolicy.maxDimension) : void 0;
|
|
202
|
+
const height = values.has("h") ? integerValue(values.get("h"), 1, runtimeFilesystemImagePolicy.maxDimension) : void 0;
|
|
203
|
+
const quality = values.has("q") ? integerValue(values.get("q"), 1, 100) : runtimeFilesystemImagePolicy.autoQuality;
|
|
204
|
+
const rawFormat = values.get("f");
|
|
205
|
+
const format = rawFormat === void 0 ? "webp" : rawFormat;
|
|
206
|
+
const rawFit = values.get("fit");
|
|
207
|
+
const fit = rawFit === void 0 ? "cover" : rawFit;
|
|
208
|
+
if (values.has("w") && width === void 0 || values.has("h") && height === void 0 || quality === void 0 || !formats.has(format) || !fits.has(fit))
|
|
209
|
+
return "invalid";
|
|
210
|
+
return Object.freeze({
|
|
211
|
+
format,
|
|
212
|
+
...width !== void 0 ? { width } : {},
|
|
213
|
+
...height !== void 0 ? { height } : {},
|
|
214
|
+
quality,
|
|
215
|
+
fit
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function parseAccept(value) {
|
|
219
|
+
if (!value)
|
|
220
|
+
return [];
|
|
221
|
+
const output = [];
|
|
222
|
+
for (const entry of value.split(",")) {
|
|
223
|
+
const [media = "", ...parameters] = entry.trim().split(";");
|
|
224
|
+
const [type = "", subtype = ""] = media.trim().toLowerCase().split("/", 2);
|
|
225
|
+
if (!/^(?:[a-z0-9!#$&^_.+-]+|\*)$/u.test(type) || !/^(?:[a-z0-9!#$&^_.+-]+|\*)$/u.test(subtype) || type === "*" && subtype !== "*")
|
|
226
|
+
continue;
|
|
227
|
+
let quality = 1;
|
|
228
|
+
for (const parameter of parameters) {
|
|
229
|
+
const [rawName, ...rawValue] = parameter.trim().split("=");
|
|
230
|
+
if (rawName?.trim().toLowerCase() !== "q")
|
|
231
|
+
continue;
|
|
232
|
+
const rawQuality = rawValue.join("=").trim().replace(/^"|"$/gu, "");
|
|
233
|
+
if (!/^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/u.test(rawQuality)) {
|
|
234
|
+
quality = 0;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
quality = Number(rawQuality);
|
|
238
|
+
}
|
|
239
|
+
output.push({ type, subtype, quality });
|
|
240
|
+
}
|
|
241
|
+
return output;
|
|
242
|
+
}
|
|
243
|
+
function acceptedQuality(ranges, mime) {
|
|
244
|
+
const [wantedType, wantedSubtype] = mime.split("/", 2);
|
|
245
|
+
let specificity = -1;
|
|
246
|
+
let quality = 0;
|
|
247
|
+
for (const range of ranges) {
|
|
248
|
+
if (range.type !== "*" && range.type !== wantedType)
|
|
249
|
+
continue;
|
|
250
|
+
if (range.subtype !== "*" && range.subtype !== wantedSubtype)
|
|
251
|
+
continue;
|
|
252
|
+
const candidateSpecificity = range.type === "*" ? 0 : range.subtype === "*" ? 1 : 2;
|
|
253
|
+
if (candidateSpecificity > specificity) {
|
|
254
|
+
specificity = candidateSpecificity;
|
|
255
|
+
quality = range.quality;
|
|
256
|
+
} else if (candidateSpecificity === specificity) {
|
|
257
|
+
quality = Math.max(quality, range.quality);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return quality;
|
|
261
|
+
}
|
|
262
|
+
function acceptsWebpInsteadOf(request, normalizedType) {
|
|
263
|
+
const ranges = parseAccept(request.headers.get("accept"));
|
|
264
|
+
const webpQuality = acceptedQuality(ranges, "image/webp");
|
|
265
|
+
const originalQuality = acceptedQuality(ranges, normalizedType === "image/jpg" ? "image/jpeg" : normalizedType);
|
|
266
|
+
return webpQuality > 0 && webpQuality >= originalQuality;
|
|
267
|
+
}
|
|
268
|
+
function selectRuntimeImageTransform(request, sourceType) {
|
|
269
|
+
const explicit = parseExplicitTransform(new URL(request.url));
|
|
270
|
+
if (explicit === "invalid")
|
|
271
|
+
return { kind: "invalid", varyAccept: false };
|
|
272
|
+
const normalizedType = sourceType.split(";", 1)[0].trim().toLowerCase();
|
|
273
|
+
if (explicit !== "none") {
|
|
274
|
+
if (!/^image\/(?:png|jpeg|jpg|webp)$/u.test(normalizedType))
|
|
275
|
+
return { kind: "original", varyAccept: false };
|
|
276
|
+
return { kind: "transform", transform: explicit, varyAccept: false };
|
|
277
|
+
}
|
|
278
|
+
if (!/^image\/(?:png|jpeg|jpg)$/u.test(normalizedType))
|
|
279
|
+
return { kind: "original", varyAccept: false };
|
|
280
|
+
if (acceptsWebpInsteadOf(request, normalizedType)) {
|
|
281
|
+
return {
|
|
282
|
+
kind: "transform",
|
|
283
|
+
transform: Object.freeze({
|
|
284
|
+
format: "webp",
|
|
285
|
+
quality: runtimeFilesystemImagePolicy.autoQuality,
|
|
286
|
+
fit: "inside"
|
|
287
|
+
}),
|
|
288
|
+
varyAccept: true
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
return { kind: "original", varyAccept: true };
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export {
|
|
295
|
+
safeStorageContentMetadata,
|
|
296
|
+
publicStorageObjectNotFound,
|
|
297
|
+
publicStorageObjectNotFoundResponse,
|
|
298
|
+
storageContentResponse,
|
|
299
|
+
formatStorageContentResponse,
|
|
300
|
+
runtimeFilesystemImagePolicy,
|
|
301
|
+
acceptsWebpInsteadOf,
|
|
302
|
+
selectRuntimeImageTransform,
|
|
303
|
+
parseRuntimeStorageConfig,
|
|
304
|
+
resolveRuntimeFilesystemImagePolicy
|
|
305
|
+
};
|