gencow 0.1.299 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/bin/gencow.mjs +0 -6
  2. package/core/package.json +1 -1
  3. package/docs/packaging.md +14 -4
  4. package/lib/cli-artifact-guard.mjs +53 -3
  5. package/lib/cli-dev-runtime.mjs +1 -0
  6. package/lib/cli-project-runtime.mjs +26 -14
  7. package/lib/codegen-command.mjs +16 -0
  8. package/lib/coding-guardrails.mjs +2 -0
  9. package/lib/dashboard-artifact.mjs +65 -0
  10. package/lib/dashboard-assets.mjs +20 -0
  11. package/lib/db-command.mjs +121 -80
  12. package/lib/db-migration-command-steps.mjs +19 -16
  13. package/lib/db-push-command.mjs +1 -1
  14. package/lib/deploy-codegen-preflight.mjs +1 -0
  15. package/lib/dev-cloud-command.mjs +1 -1
  16. package/lib/dev-local-command.mjs +19 -56
  17. package/lib/document-local-converter.mjs +11 -0
  18. package/lib/local-dashboard-plan.mjs +60 -0
  19. package/lib/local-database-commands.mjs +127 -0
  20. package/lib/local-development-migrations.mjs +157 -0
  21. package/lib/local-drizzle-database.config.mjs +10 -0
  22. package/lib/local-runtime-features.mjs +12 -0
  23. package/lib/rag-selection.mjs +7 -0
  24. package/lib/runtime-local-worker.mjs +116 -0
  25. package/lib/runtime-mode.mjs +3 -0
  26. package/lib/standalone-codegen-adapter.mjs +91 -0
  27. package/lib/ts-codegen-import-extension.mjs +228 -19
  28. package/package.json +15 -8
  29. package/runtime/config.mjs +218 -2
  30. package/runtime/engine/chunk-2HA4CUMS.mjs +90 -0
  31. package/runtime/engine/chunk-2JLO3KMM.mjs +305 -0
  32. package/runtime/engine/chunk-2SR2M7SR.mjs +1045 -0
  33. package/runtime/engine/chunk-3D7MHEUC.mjs +253 -0
  34. package/runtime/engine/chunk-3R7COBWG.mjs +309 -0
  35. package/runtime/engine/chunk-3ZKA54UW.mjs +1560 -0
  36. package/runtime/engine/chunk-45I4YR2J.mjs +9 -0
  37. package/runtime/engine/chunk-4MLRXO7F.mjs +74 -0
  38. package/runtime/engine/chunk-5575APCJ.mjs +215 -0
  39. package/runtime/engine/chunk-5GUJZQF3.mjs +114 -0
  40. package/runtime/engine/chunk-5MXY3T75.mjs +428 -0
  41. package/runtime/engine/chunk-5TACQ2US.mjs +44 -0
  42. package/runtime/engine/chunk-66G4YEDT.mjs +3104 -0
  43. package/runtime/engine/chunk-67YO53WW.mjs +1426 -0
  44. package/runtime/engine/chunk-6GQRM7XY.mjs +87 -0
  45. package/runtime/engine/chunk-6JO72SPP.mjs +68 -0
  46. package/runtime/engine/chunk-6W653LXI.mjs +13 -0
  47. package/runtime/engine/chunk-7ITSMI3S.mjs +69 -0
  48. package/runtime/engine/chunk-7KUJ2H2S.mjs +128 -0
  49. package/runtime/engine/chunk-A5BMQ5IC.mjs +45 -0
  50. package/runtime/engine/chunk-ADF3UR6L.mjs +428 -0
  51. package/runtime/engine/chunk-AEBW7XZJ.mjs +4510 -0
  52. package/runtime/engine/chunk-AGPQ5XIV.mjs +156 -0
  53. package/runtime/engine/chunk-CPU4OZSX.mjs +753 -0
  54. package/runtime/engine/chunk-CSWPPWBL.mjs +50 -0
  55. package/runtime/engine/chunk-DPWXSMWO.mjs +53 -0
  56. package/runtime/engine/chunk-EAIELFKU.mjs +151 -0
  57. package/runtime/engine/chunk-EDU5CBKT.mjs +10 -0
  58. package/runtime/engine/chunk-EQCTAET7.mjs +173 -0
  59. package/runtime/engine/chunk-EQCXDF2Z.mjs +70 -0
  60. package/runtime/engine/chunk-F3G4UGV4.mjs +330 -0
  61. package/runtime/engine/chunk-F62NUNOO.mjs +26 -0
  62. package/runtime/engine/chunk-FKPNIFRP.mjs +2492 -0
  63. package/runtime/engine/chunk-FM23RGVI.mjs +81 -0
  64. package/runtime/engine/chunk-FW5AK4YP.mjs +1041 -0
  65. package/runtime/engine/chunk-GDWYAGWV.mjs +23 -0
  66. package/runtime/engine/chunk-GO5PZUYW.mjs +53 -0
  67. package/runtime/engine/chunk-GOLP7OSG.mjs +340 -0
  68. package/runtime/engine/chunk-GSLM44EF.mjs +242 -0
  69. package/runtime/engine/chunk-GYAJ7OX2.mjs +125 -0
  70. package/runtime/engine/chunk-I3GWR43K.mjs +14 -0
  71. package/runtime/engine/chunk-IFMOTJNU.mjs +106 -0
  72. package/runtime/engine/chunk-IKQKBE2G.mjs +128 -0
  73. package/runtime/engine/chunk-ITH2NEKM.mjs +282 -0
  74. package/runtime/engine/chunk-J6SDRCG4.mjs +96 -0
  75. package/runtime/engine/chunk-JODRNM3S.mjs +29596 -0
  76. package/runtime/engine/chunk-JUDKX53X.mjs +137 -0
  77. package/runtime/engine/chunk-K2YZVPJ4.mjs +827 -0
  78. package/runtime/engine/chunk-KEZJUXEE.mjs +151 -0
  79. package/runtime/engine/chunk-KVLTJFCH.mjs +234 -0
  80. package/runtime/engine/chunk-KX2PRQPS.mjs +126 -0
  81. package/runtime/engine/chunk-LEW5ZMLR.mjs +76 -0
  82. package/runtime/engine/chunk-LINVSJEM.mjs +175 -0
  83. package/runtime/engine/chunk-M7K2ICSM.mjs +11 -0
  84. package/runtime/engine/chunk-MZXDXSDC.mjs +292 -0
  85. package/runtime/engine/chunk-N2TA2IK2.mjs +678 -0
  86. package/runtime/engine/chunk-N4LTCKJP.mjs +695 -0
  87. package/runtime/engine/chunk-N6GCLOUX.mjs +13 -0
  88. package/runtime/engine/chunk-NAG2OXS5.mjs +37 -0
  89. package/runtime/engine/chunk-NNZ2QJUG.mjs +381 -0
  90. package/runtime/engine/chunk-NZPPLDNW.mjs +15 -0
  91. package/runtime/engine/chunk-ODWM57W6.mjs +138 -0
  92. package/runtime/engine/chunk-P5IIXAIE.mjs +23 -0
  93. package/runtime/engine/chunk-PBOXB2BV.mjs +6 -0
  94. package/runtime/engine/chunk-PMOJLN2P.mjs +8 -0
  95. package/runtime/engine/chunk-PZFMKFHO.mjs +180 -0
  96. package/runtime/engine/chunk-QL2TQX2N.mjs +114 -0
  97. package/runtime/engine/chunk-RITT2RSJ.mjs +258 -0
  98. package/runtime/engine/chunk-RODBVJ5M.mjs +135 -0
  99. package/runtime/engine/chunk-RW65MPVY.mjs +261 -0
  100. package/runtime/engine/chunk-S67UYPB6.mjs +25 -0
  101. package/runtime/engine/chunk-SVJCOUI3.mjs +47 -0
  102. package/runtime/engine/chunk-TCN3ZASV.mjs +957 -0
  103. package/runtime/engine/chunk-U2NRG6KC.mjs +32 -0
  104. package/runtime/engine/chunk-UM3F7HUV.mjs +432 -0
  105. package/runtime/engine/chunk-VWU7JJ3P.mjs +146 -0
  106. package/runtime/engine/chunk-WDTKPPMU.mjs +310 -0
  107. package/runtime/engine/chunk-WJOO4XTB.mjs +31 -0
  108. package/runtime/engine/chunk-XNFVL2OY.mjs +63 -0
  109. package/runtime/engine/chunk-XPWJXP2J.mjs +58 -0
  110. package/runtime/engine/chunk-Y3HSBJ3I.mjs +1132 -0
  111. package/runtime/engine/chunk-YMH4RYSX.mjs +317 -0
  112. package/runtime/engine/chunk-YNOMPSGS.mjs +8 -0
  113. package/runtime/engine/chunk-YRBAYTEZ.mjs +251 -0
  114. package/runtime/engine/chunk-YRHM272W.mjs +528 -0
  115. package/runtime/engine/chunk-ZQUZAGIQ.mjs +149 -0
  116. package/runtime/engine/chunk-ZXMM7QFP.mjs +176 -0
  117. package/runtime/engine/chunk-ZZJSIPV2.mjs +262 -0
  118. package/runtime/engine/composition.mjs +325 -0
  119. package/runtime/engine/document-local.mjs +504 -0
  120. package/runtime/engine/graph.json +4134 -0
  121. package/runtime/engine/index.mjs +265 -0
  122. package/runtime/engine/local-postgres-support.mjs +69 -0
  123. package/runtime/engine/local.mjs +3275 -0
  124. package/runtime/engine/pglite-directory-lock.mjs +8 -0
  125. package/runtime/engine/rag.mjs +11 -0
  126. package/runtime/engine/search.mjs +18 -0
  127. package/runtime/framework-migrations/foundation-bootstrap/rag.sql +115 -0
  128. package/runtime/framework-migrations/foundation-bootstrap/workflow.sql +194 -0
  129. package/runtime/framework-migrations/journal-bootstrap/migration.sql +26 -0
  130. package/runtime/framework-migrations/manifest.json +56 -0
  131. package/runtime/framework-migrations/rag/20261006111509_mushy_warhawk/migration.sql +121 -0
  132. package/runtime/framework-migrations/rag/20261013234621_rag_v2_lifecycle_markers/migration.sql +6 -0
  133. package/runtime/framework-migrations/workflow/20261006111508_perpetual_star_brand/migration.sql +31 -0
  134. package/runtime/runtime-metadata.json +27 -0
  135. package/runtime/tooling.mjs +10399 -8951
  136. package/scripts/bundle-runtime-config.mjs +23 -0
  137. package/scripts/bundle-runtime.mjs +100 -0
  138. package/scripts/bundle-runtime.test.mjs +33 -0
  139. package/scripts/bundle-shared.mjs +3 -0
  140. package/scripts/copy-dashboard.mjs +16 -0
  141. package/scripts/pre-publish-check.mjs +23 -11
  142. package/templateFeature/ai/ai-facade.ts +38 -15
  143. package/templateFeature/ai/manifest.json +1 -0
  144. package/templateFeature/sso/sso-auth-callback.tsx +37 -5
  145. package/templateFeature/tools/manifest.json +5 -2
  146. package/templateFeature/tools/tools.ts +3 -3
  147. package/runtime/server.mjs +0 -14389
  148. package/scripts/bundle-server.mjs +0 -223
  149. package/server/config.js +0 -1
  150. package/server/index.js +0 -1
  151. package/server/package.json +0 -6
@@ -0,0 +1,87 @@
1
+ import {
2
+ frameworkSchemaReadyOutcome
3
+ } from "./chunk-U2NRG6KC.mjs";
4
+ import {
5
+ runtimeDatabaseSchemaReadyCorrelation,
6
+ runtimeDatabaseSchemaReadyImpact
7
+ } from "./chunk-KEZJUXEE.mjs";
8
+ import {
9
+ runtimeDatabaseSetupError
10
+ } from "./chunk-SVJCOUI3.mjs";
11
+ import {
12
+ runtimeStartupError
13
+ } from "./chunk-IFMOTJNU.mjs";
14
+ import {
15
+ RuntimeDiagnosticError,
16
+ runtimeDiagnostic
17
+ } from "./chunk-AEBW7XZJ.mjs";
18
+
19
+ // ../runtime/dist/app/startup-cleanup-association.js
20
+ var handles = /* @__PURE__ */ new WeakMap();
21
+ function associateRuntimeStartupCleanup(error, handle) {
22
+ handles.set(error, handle);
23
+ }
24
+ function getRuntimeStartupCleanup(error) {
25
+ if (typeof error !== "object" && typeof error !== "function" || error === null)
26
+ return void 0;
27
+ const handle = handles.get(error);
28
+ return !handle || handle.status() === "complete" ? void 0 : handle;
29
+ }
30
+ function preserveRuntimeStartupCleanup(original, projected) {
31
+ const handle = getRuntimeStartupCleanup(original);
32
+ if (handle)
33
+ handles.set(projected, handle);
34
+ return projected;
35
+ }
36
+
37
+ // ../runtime/dist/database-setup/startup-outcomes.js
38
+ function captureApplicationMigrationOutcome(input) {
39
+ if (input === void 0)
40
+ return void 0;
41
+ if (!input || !["none", "committed", "unknown"].includes(input.applicationImpact) || typeof input.correlationId !== "string" || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/iu.test(input.correlationId))
42
+ throw runtimeStartupError("RUNTIME_COMPONENT_DEPENDENCY_INVALID", "Use the local application migration owner's classified outcome before starting Runtime. Inspect any uncertain effects before retrying.");
43
+ return Object.freeze({ applicationImpact: input.applicationImpact, correlationId: input.correlationId });
44
+ }
45
+ function withStartupMigrationImpacts(error, application, frameworkImpact, frameworkCorrelationId) {
46
+ const diagnostic = runtimeDiagnostic(error);
47
+ if (!diagnostic || !application && frameworkImpact === "none")
48
+ return error;
49
+ if (diagnostic.applicationImpact !== void 0 && diagnostic.frameworkImpact !== void 0)
50
+ return error;
51
+ const applicationImpact = application?.applicationImpact ?? "none";
52
+ const impacts = [diagnostic.dataImpact, applicationImpact, frameworkImpact];
53
+ const dataImpact = impacts.includes("unknown") ? "unknown" : impacts.includes("committed") ? "committed" : "none";
54
+ return preserveRuntimeStartupCleanup(error, new RuntimeDiagnosticError({
55
+ ...diagnostic,
56
+ applicationImpact,
57
+ frameworkImpact,
58
+ dataImpact,
59
+ ...application ? { applicationCorrelationId: application.correlationId } : {},
60
+ ...frameworkCorrelationId ? { frameworkCorrelationId } : {}
61
+ }));
62
+ }
63
+ function runtimeDatabaseSchemaStartupOutcome(ready, database, binding, frameworkTargetPlan) {
64
+ if (ready.kind === "coordinated")
65
+ return {
66
+ impact: runtimeDatabaseSchemaReadyImpact(ready.proof, database, binding),
67
+ correlationId: runtimeDatabaseSchemaReadyCorrelation(ready.proof, database, binding)
68
+ };
69
+ if (ready.kind === "framework") {
70
+ if (!frameworkTargetPlan)
71
+ throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_OUTCOME_UNKNOWN", "unknown");
72
+ try {
73
+ return frameworkSchemaReadyOutcome(ready.proof, database, binding, frameworkTargetPlan);
74
+ } catch {
75
+ throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_OUTCOME_UNKNOWN", "unknown");
76
+ }
77
+ }
78
+ return { impact: "unknown", correlationId: void 0 };
79
+ }
80
+
81
+ export {
82
+ associateRuntimeStartupCleanup,
83
+ getRuntimeStartupCleanup,
84
+ captureApplicationMigrationOutcome,
85
+ withStartupMigrationImpacts,
86
+ runtimeDatabaseSchemaStartupOutcome
87
+ };
@@ -0,0 +1,68 @@
1
+ import {
2
+ RuntimeDiagnosticError
3
+ } from "./chunk-AEBW7XZJ.mjs";
4
+
5
+ // ../runtime/dist/adapters/document/errors.js
6
+ var recovery = {
7
+ DOCUMENT_CONVERSION_MODE_REQUIRED: "Request mode: text-only or no-external-provider for standalone binary extraction, or select a managed converter.",
8
+ DOCUMENT_CONVERSION_POLICY_INVALID: "Use a basic mode with provider auto/local_text, or select a managed converter for external conversion.",
9
+ DOCUMENT_CONVERSION_POLICY_UNAVAILABLE: "Restore the trusted corpus disclosure-policy observation before resuming this same Workflow. No document converter or provider call started; do not bypass policy or start replacement work.",
10
+ DOCUMENT_LOCAL_DEPENDENCY_MISSING: "Install the required optional parser, then restart the process before retrying this conversion.",
11
+ DOCUMENT_LOCAL_DEPENDENCY_INCOMPATIBLE: "Install the tested compatible parser version, then restart the process before retrying this conversion.",
12
+ DOCUMENT_BASIC_EXTRACTION_INSUFFICIENT: "Supply a text-readable document, or explicitly select an authorized external/OCR converter.",
13
+ DOCUMENT_INPUT_INVALID: "Supply a valid document whose bytes match its MIME type; do not retry the unchanged input.",
14
+ DOCUMENT_SIZE_LIMIT_EXCEEDED: "Reduce the document size to the configured input limit before retrying.",
15
+ DOCUMENT_CONVERSION_CANCELLED: "Inspect the existing ingest job before resuming; do not replace an accepted job identity.",
16
+ DOCUMENT_PARSER_TIMEOUT: "The selected document parser exceeded its time limit. Inspect this run and its prior effects, then supply a document within the parser's supported limits before resuming.",
17
+ DOCUMENT_PARSER_CONFIGURATION_INVALID: "Restore the selected document parser's supported configuration and worker artifacts before resuming this run.",
18
+ DOCUMENT_PARSER_CAPACITY_EXCEEDED: "Wait for the selected document parser's capacity to recover before resuming this run.",
19
+ DOCUMENT_PARSER_MEMORY_LIMIT_EXCEEDED: "Reduce document complexity or restore sufficient selected parser capacity before resuming this run.",
20
+ DOCUMENT_PARSER_OUTPUT_LIMIT_EXCEEDED: "Reduce document output size before resuming this run; inspect earlier effects first.",
21
+ DOCUMENT_PARSER_CLOSING: "Wait for the selected parser to finish closing and for a ready generation before resuming this run.",
22
+ DOCUMENT_BASIC_EXTRACTION_FAILED: "Supply an unencrypted, valid supported document; inspect the existing ingest job before retrying.",
23
+ DOCUMENT_SCOPE_INVALID: "Use the actual Workflow owner's authorized corpus/storage scope; caller-supplied owner, filename or visibility does not grant access.",
24
+ DOCUMENT_STORAGE_AUTHORITY_UNAVAILABLE: "Restore the trusted app/owner-bound storage read-grant supplier before conversion. Raw Storage access or visibility is not ownership; no bytes or provider call occurred.",
25
+ DOCUMENT_STORAGE_SCOPE_FORBIDDEN: "Use a document uploaded by the same authenticated app/user or supply its trusted explicit read-grant authority. Public visibility or legacy ownerless metadata does not prove document ownership; this storage boundary admitted no document converter/provider call.",
26
+ DOCUMENT_STORAGE_NOT_FOUND: "Verify the document ID and its authorized owner, or upload the missing document before resuming this same Workflow. The document is unavailable to this scope; do not bypass ownership or start replacement work.",
27
+ DOCUMENT_STORAGE_SCOPE_EXPIRED: "Inspect the same upload/Workflow and its earlier storage effects before resuming under a ready verified scope. An ended scope does not prove rollback; do not blindly repeat writes or document conversion.",
28
+ DOCUMENT_WORKFLOW_FENCE_LOST: "Inspect this same workflows.get run and its cancellation/ownership state. Do not continue from an ended or superseded attempt or blindly redispatch external conversion.",
29
+ DOCUMENT_WORKFLOW_OBSERVATION_UNAVAILABLE: "Restore the selected Workflow database's observation capability and inspect this same run. An unavailable observation is not cancellation, rollback or safe redispatch evidence; preserve existing identities and provider effects.",
30
+ DOCUMENT_EXTERNAL_PROVIDER_REQUIRED: "Use an authorized corpus/disclosure policy for the requested external mode, or explicitly choose a basic mode. Do not bypass ownership, policy or paid consent; no converter/provider call was admitted by this denied facade.",
31
+ DOCUMENT_RESULT_INVALID: "Repair the selected converter's normalized output/trace and inspect this same Workflow's earlier provider effects before safe resumption; do not blindly redispatch.",
32
+ DOCUMENT_RESULT_SIZE_LIMIT_EXCEEDED: "Reduce converted output to the selected byte limit and inspect this same Workflow's earlier provider effects before safe resumption; do not blindly redispatch.",
33
+ DOCUMENT_CONVERT_OUTCOME_UNKNOWN: "Inspect this same Workflow and any existing ingest job/provider evidence before resuming. A lost acknowledgement is not safe redispatch or refund evidence; do not start replacement work."
34
+ };
35
+ function isDocumentConversionErrorCode(code) {
36
+ return Object.hasOwn(recovery, code);
37
+ }
38
+ var DocumentConversionError = class extends RuntimeDiagnosticError {
39
+ code;
40
+ constructor(code, correlationId, dependency) {
41
+ const nextAction = dependency === "provided-parser" ? "Restore the selected converter provider's parser dependencies and restart the generation; when the provider supplies the parser, tenants need not install optional peers. Inspect the existing job before resuming." : dependency ? `Run npm install ${dependency}@${dependency === "pdf-parse" ? "^2.4.5" : "^1.12.0"}, restart the process, then retry the affected conversion after inspecting its existing job.` : recovery[code];
42
+ super({
43
+ code,
44
+ stage: "request",
45
+ capability: "application",
46
+ servingStarted: "unchanged",
47
+ dataImpact: [
48
+ "DOCUMENT_STORAGE_SCOPE_EXPIRED",
49
+ "DOCUMENT_WORKFLOW_FENCE_LOST",
50
+ "DOCUMENT_WORKFLOW_OBSERVATION_UNAVAILABLE",
51
+ "DOCUMENT_RESULT_INVALID",
52
+ "DOCUMENT_RESULT_SIZE_LIMIT_EXCEEDED",
53
+ "DOCUMENT_CONVERT_OUTCOME_UNKNOWN"
54
+ ].includes(code) ? "unknown" : "none",
55
+ retryable: false,
56
+ retryPrecondition: dependency === "provided-parser" ? nextAction : recovery[code],
57
+ nextAction,
58
+ ...correlationId && /^[A-Za-z0-9._-]{1,128}$/u.test(correlationId) ? { correlationId } : {}
59
+ });
60
+ this.name = "DocumentConversionError";
61
+ this.code = code;
62
+ }
63
+ };
64
+
65
+ export {
66
+ isDocumentConversionErrorCode,
67
+ DocumentConversionError
68
+ };
@@ -0,0 +1,13 @@
1
+ import {
2
+ validateRuntimeWorkflowSchema,
3
+ workflowSchemaBootstrapUnavailable,
4
+ workflowSchemaFailure
5
+ } from "./chunk-LINVSJEM.mjs";
6
+ import "./chunk-GOLP7OSG.mjs";
7
+ import "./chunk-IFMOTJNU.mjs";
8
+ import "./chunk-AEBW7XZJ.mjs";
9
+ export {
10
+ validateRuntimeWorkflowSchema,
11
+ workflowSchemaBootstrapUnavailable,
12
+ workflowSchemaFailure
13
+ };
@@ -0,0 +1,69 @@
1
+ import {
2
+ RuntimeDiagnosticError,
3
+ STORAGE_LIST_DEFAULT_LIMIT,
4
+ STORAGE_LIST_MAX_LIMIT,
5
+ StorageListUnsupportedError
6
+ } from "./chunk-AEBW7XZJ.mjs";
7
+
8
+ // ../runtime/dist/adapters/storage/listing.js
9
+ function storageListOptions(input) {
10
+ const limit = input?.limit;
11
+ return {
12
+ order: input?.order === "asc" ? "asc" : "desc",
13
+ limit: typeof limit === "number" && Number.isFinite(limit) ? Math.max(1, Math.min(STORAGE_LIST_MAX_LIMIT, Math.trunc(limit))) : STORAGE_LIST_DEFAULT_LIMIT
14
+ };
15
+ }
16
+ function cursorFailure() {
17
+ return new RuntimeDiagnosticError({
18
+ code: "RUNTIME_STORAGE_CURSOR_INVALID",
19
+ stage: "request",
20
+ servingStarted: "unchanged",
21
+ dataImpact: "none",
22
+ retryable: false,
23
+ retryPrecondition: "Start a new listing without a cursor, using the intended order and storage catalog.",
24
+ nextAction: "Call ctx.storage.listMeta without a cursor; retain its returned cursor with the same order for following pages.",
25
+ capability: "storage"
26
+ });
27
+ }
28
+ function encodeStorageCursor(payload) {
29
+ return Buffer.from(JSON.stringify({ v: 1, ...payload })).toString("base64url");
30
+ }
31
+ function decodeStorageCursor(raw, catalog, order) {
32
+ try {
33
+ if (typeof raw !== "string" || raw.length > 16384 || !/^[A-Za-z0-9_-]+$/u.test(raw))
34
+ throw cursorFailure();
35
+ const value = JSON.parse(Buffer.from(raw, "base64url").toString());
36
+ if (!value || typeof value !== "object" || Array.isArray(value))
37
+ throw cursorFailure();
38
+ const payload = value;
39
+ if (payload.v !== 1 || payload.catalog !== catalog || payload.order !== order)
40
+ throw cursorFailure();
41
+ return payload;
42
+ } catch {
43
+ throw cursorFailure();
44
+ }
45
+ }
46
+ function invalidStorageCursor() {
47
+ throw cursorFailure();
48
+ }
49
+ function azureDescendingListUnsupported() {
50
+ const diagnostic = {
51
+ code: "STORAGE_LIST_UNSUPPORTED",
52
+ stage: "request",
53
+ servingStarted: "unchanged",
54
+ dataImpact: "none",
55
+ retryable: false,
56
+ retryPrecondition: "Use ascending order for this provider's bounded inventory listing.",
57
+ nextAction: 'Call ctx.storage.listMeta({ order: "asc" }); descending inventory requires a separately selected catalog-backed implementation.',
58
+ capability: "storage"
59
+ };
60
+ return Object.assign(new StorageListUnsupportedError("Azure flat inventory supports ascending order only."), { diagnostic });
61
+ }
62
+
63
+ export {
64
+ storageListOptions,
65
+ encodeStorageCursor,
66
+ decodeStorageCursor,
67
+ invalidStorageCursor,
68
+ azureDescendingListUnsupported
69
+ };
@@ -0,0 +1,128 @@
1
+ // ../runtime/dist/workflow/list-read-observation.js
2
+ import { performance } from "node:perf_hooks";
3
+ var runtimeWorkflowListReadTaskId = "core-workflow-owner-lists:pglite";
4
+ var runtimeWorkflowListReadMaxRecords = 64;
5
+ function createRuntimeWorkflowListReadObserver(options = {}) {
6
+ const environment = options.environment ?? process.env;
7
+ if (environment.GENCOW_RUNTIME_TEST_TASK_ID !== runtimeWorkflowListReadTaskId || typeof environment.GENCOW_RUNTIME_TEST_METRICS_DIR !== "string" || environment.GENCOW_RUNTIME_TEST_METRICS_DIR.length === 0)
8
+ return void 0;
9
+ const monotonicNow = options.monotonicNow ?? (() => performance.now());
10
+ const write = options.write ?? ((line) => console.log(line));
11
+ let startedRecords = 0;
12
+ return Object.freeze({
13
+ begin() {
14
+ if (startedRecords >= runtimeWorkflowListReadMaxRecords)
15
+ return void 0;
16
+ startedRecords += 1;
17
+ let clockInvalid = false;
18
+ let transactionStartedAt;
19
+ let callbackExitedAt;
20
+ let admissionMs;
21
+ let coreReaderMs;
22
+ let projectionRepairMs;
23
+ let transactionSettlementMs;
24
+ let selectedCount;
25
+ let isFinished = false;
26
+ function readTime() {
27
+ if (clockInvalid)
28
+ return void 0;
29
+ try {
30
+ const value = monotonicNow();
31
+ if (Number.isFinite(value) && value >= 0)
32
+ return value;
33
+ } catch {
34
+ }
35
+ clockInvalid = true;
36
+ return void 0;
37
+ }
38
+ function elapsed(startedAt) {
39
+ const endedAt = readTime();
40
+ if (startedAt === void 0 || endedAt === void 0 || endedAt < startedAt) {
41
+ clockInvalid = true;
42
+ return void 0;
43
+ }
44
+ const rounded = Math.round((endedAt - startedAt) * 1e3) / 1e3;
45
+ if (!Number.isFinite(rounded) || rounded < 0) {
46
+ clockInvalid = true;
47
+ return void 0;
48
+ }
49
+ return rounded;
50
+ }
51
+ function endPhase(phase, startedAt) {
52
+ const wallMs = elapsed(startedAt);
53
+ if (phase === "core-reader")
54
+ coreReaderMs = wallMs;
55
+ else
56
+ projectionRepairMs = wallMs;
57
+ }
58
+ const measurement = {
59
+ transactionStarted() {
60
+ transactionStartedAt = readTime();
61
+ },
62
+ callbackEntered() {
63
+ admissionMs = elapsed(transactionStartedAt);
64
+ transactionStartedAt = void 0;
65
+ },
66
+ callbackExited() {
67
+ callbackExitedAt = readTime();
68
+ },
69
+ phaseStarted(_phase) {
70
+ return readTime();
71
+ },
72
+ phaseFinished(phase, startedAt) {
73
+ endPhase(phase, startedAt);
74
+ },
75
+ selected(count) {
76
+ if (Number.isSafeInteger(count) && count >= 0)
77
+ selectedCount = count;
78
+ },
79
+ finish(outcome, repairSqlCount) {
80
+ if (isFinished)
81
+ return;
82
+ isFinished = true;
83
+ if (callbackExitedAt !== void 0)
84
+ transactionSettlementMs = elapsed(callbackExitedAt);
85
+ const validRepairSqlCount = Number.isSafeInteger(repairSqlCount) && repairSqlCount >= 0 ? repairSqlCount : 0;
86
+ const phases = [admissionMs, coreReaderMs, projectionRepairMs, transactionSettlementMs];
87
+ const anyTiming = phases.some((value) => value !== void 0);
88
+ const completeTiming = phases.every((value) => value !== void 0);
89
+ const timing = clockInvalid ? "unavailable" : completeTiming ? "available" : anyTiming ? "partial" : "unavailable";
90
+ const phaseField = (value) => timing === "unavailable" || value === void 0 ? "na" : String(value);
91
+ const selectionField = selectedCount === void 0 ? "" : ` selection=${selectedCount === 0 ? "empty" : "nonempty"} selectedCount=${selectedCount}`;
92
+ const line = `[runtime-test] LIST_READ ${runtimeWorkflowListReadTaskId} outcome=${outcome}${selectionField} repairSqlCount=${validRepairSqlCount} timing=${timing} admissionMs=${phaseField(admissionMs)} coreReaderMs=${phaseField(coreReaderMs)} projectionRepairMs=${phaseField(projectionRepairMs)} transactionSettlementMs=${phaseField(transactionSettlementMs)}`;
93
+ try {
94
+ setImmediate(() => {
95
+ try {
96
+ const result = write(line);
97
+ if (result !== void 0)
98
+ void Promise.resolve(result).catch(() => {
99
+ });
100
+ } catch {
101
+ }
102
+ });
103
+ } catch {
104
+ }
105
+ }
106
+ };
107
+ return Object.freeze(measurement);
108
+ }
109
+ });
110
+ }
111
+ function countRuntimeWorkflowSqlExecutions(transaction, onExecute) {
112
+ const execute = transaction.execute;
113
+ return Object.freeze({
114
+ execute(statement) {
115
+ try {
116
+ onExecute();
117
+ } catch {
118
+ }
119
+ return Reflect.apply(execute, transaction, [statement]);
120
+ }
121
+ });
122
+ }
123
+
124
+ export {
125
+ runtimeWorkflowListReadTaskId,
126
+ createRuntimeWorkflowListReadObserver,
127
+ countRuntimeWorkflowSqlExecutions
128
+ };
@@ -0,0 +1,45 @@
1
+ import {
2
+ ownedPostgresQuerySqlState
3
+ } from "./chunk-KX2PRQPS.mjs";
4
+
5
+ // ../runtime/dist/adapters/database/private-query-failure-evidence.js
6
+ var pgliteQueryStates = /* @__PURE__ */ new WeakMap();
7
+ function markPgliteQueryFailure(error, sqlState) {
8
+ if (isObject(error) && /^[0-9A-Z]{5}$/.test(sqlState))
9
+ pgliteQueryStates.set(error, sqlState);
10
+ }
11
+ function pgliteRuntimeQuerySqlState(error) {
12
+ return isObject(error) ? pgliteQueryStates.get(error) : void 0;
13
+ }
14
+ function trustedRuntimeQuerySqlState(error) {
15
+ const visited = /* @__PURE__ */ new Set();
16
+ let current = error;
17
+ for (let depth = 0; isObject(current) && depth < 8 && !visited.has(current); depth++) {
18
+ visited.add(current);
19
+ const pgliteState = pgliteRuntimeQuerySqlState(current);
20
+ if (pgliteState)
21
+ return pgliteState;
22
+ const postgresState = ownedPostgresQuerySqlState(current);
23
+ if (postgresState)
24
+ return postgresState;
25
+ current = ownDataValue(current, "cause");
26
+ }
27
+ return void 0;
28
+ }
29
+ function ownDataValue(value, key) {
30
+ try {
31
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
32
+ return descriptor && "value" in descriptor ? descriptor.value : void 0;
33
+ } catch {
34
+ return void 0;
35
+ }
36
+ }
37
+ function isObject(value) {
38
+ return typeof value === "object" && value !== null;
39
+ }
40
+
41
+ export {
42
+ markPgliteQueryFailure,
43
+ pgliteRuntimeQuerySqlState,
44
+ trustedRuntimeQuerySqlState
45
+ };