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.
Files changed (169) hide show
  1. package/bin/gencow.mjs +0 -6
  2. package/core/index.js +261 -1447
  3. package/core/package.json +1 -1
  4. package/dashboard/assets/{index-BnBn8uo4.js → index-DYqUzCmS.js} +3 -3
  5. package/dashboard/assets/index-OH2xW1ZG.css +2 -0
  6. package/dashboard/index.html +2 -2
  7. package/docs/packaging.md +14 -4
  8. package/lib/cli-artifact-guard.mjs +53 -3
  9. package/lib/cli-command-runner.d.mts +11 -0
  10. package/lib/cli-dev-runtime.mjs +1 -0
  11. package/lib/cli-project-runtime.mjs +26 -14
  12. package/lib/codegen-command.mjs +16 -0
  13. package/lib/coding-guardrails.mjs +2 -0
  14. package/lib/component-readme.mjs +4 -4
  15. package/lib/dashboard-artifact.mjs +65 -0
  16. package/lib/dashboard-assets.mjs +20 -0
  17. package/lib/db-command.mjs +121 -80
  18. package/lib/db-migration-command-steps.mjs +19 -16
  19. package/lib/db-push-command.mjs +1 -1
  20. package/lib/deploy-codegen-preflight.mjs +1 -0
  21. package/lib/deploy-cron-manifest-diagnostic.mjs +93 -0
  22. package/lib/deploy-failure-diagnostic.mjs +4 -43
  23. package/lib/deploy-route-target-rejection-diagnostic.mjs +43 -0
  24. package/lib/dev-cloud-command.mjs +1 -1
  25. package/lib/dev-local-command.mjs +19 -56
  26. package/lib/document-local-converter.mjs +11 -0
  27. package/lib/jobs-command.mjs +33 -1
  28. package/lib/local-dashboard-plan.mjs +60 -0
  29. package/lib/local-database-commands.mjs +127 -0
  30. package/lib/local-development-migrations.mjs +157 -0
  31. package/lib/local-drizzle-database.config.mjs +10 -0
  32. package/lib/local-runtime-features.mjs +12 -0
  33. package/lib/rag-selection.mjs +7 -0
  34. package/lib/readme-codegen.mjs +2 -2
  35. package/lib/runtime-local-worker.mjs +116 -0
  36. package/lib/runtime-mode.mjs +3 -0
  37. package/lib/standalone-codegen-adapter.mjs +91 -0
  38. package/lib/ts-codegen-import-extension.mjs +228 -19
  39. package/package.json +16 -9
  40. package/runtime/config.mjs +218 -2
  41. package/runtime/dependency-lock.mjs +5 -1
  42. package/runtime/engine/chunk-2HA4CUMS.mjs +90 -0
  43. package/runtime/engine/chunk-2JLO3KMM.mjs +305 -0
  44. package/runtime/engine/chunk-2SR2M7SR.mjs +1045 -0
  45. package/runtime/engine/chunk-3D7MHEUC.mjs +253 -0
  46. package/runtime/engine/chunk-3R7COBWG.mjs +309 -0
  47. package/runtime/engine/chunk-3ZKA54UW.mjs +1560 -0
  48. package/runtime/engine/chunk-45I4YR2J.mjs +9 -0
  49. package/runtime/engine/chunk-4MLRXO7F.mjs +74 -0
  50. package/runtime/engine/chunk-5575APCJ.mjs +215 -0
  51. package/runtime/engine/chunk-5GUJZQF3.mjs +114 -0
  52. package/runtime/engine/chunk-5MXY3T75.mjs +428 -0
  53. package/runtime/engine/chunk-5TACQ2US.mjs +44 -0
  54. package/runtime/engine/chunk-66G4YEDT.mjs +3104 -0
  55. package/runtime/engine/chunk-67YO53WW.mjs +1426 -0
  56. package/runtime/engine/chunk-6GQRM7XY.mjs +87 -0
  57. package/runtime/engine/chunk-6JO72SPP.mjs +68 -0
  58. package/runtime/engine/chunk-6W653LXI.mjs +13 -0
  59. package/runtime/engine/chunk-7ITSMI3S.mjs +69 -0
  60. package/runtime/engine/chunk-7KUJ2H2S.mjs +128 -0
  61. package/runtime/engine/chunk-A5BMQ5IC.mjs +45 -0
  62. package/runtime/engine/chunk-ADF3UR6L.mjs +428 -0
  63. package/runtime/engine/chunk-AEBW7XZJ.mjs +4510 -0
  64. package/runtime/engine/chunk-AGPQ5XIV.mjs +156 -0
  65. package/runtime/engine/chunk-CPU4OZSX.mjs +753 -0
  66. package/runtime/engine/chunk-CSWPPWBL.mjs +50 -0
  67. package/runtime/engine/chunk-DPWXSMWO.mjs +53 -0
  68. package/runtime/engine/chunk-EAIELFKU.mjs +151 -0
  69. package/runtime/engine/chunk-EDU5CBKT.mjs +10 -0
  70. package/runtime/engine/chunk-EQCTAET7.mjs +173 -0
  71. package/runtime/engine/chunk-EQCXDF2Z.mjs +70 -0
  72. package/runtime/engine/chunk-F3G4UGV4.mjs +330 -0
  73. package/runtime/engine/chunk-F62NUNOO.mjs +26 -0
  74. package/runtime/engine/chunk-FKPNIFRP.mjs +2492 -0
  75. package/runtime/engine/chunk-FM23RGVI.mjs +81 -0
  76. package/runtime/engine/chunk-FW5AK4YP.mjs +1041 -0
  77. package/runtime/engine/chunk-GDWYAGWV.mjs +23 -0
  78. package/runtime/engine/chunk-GO5PZUYW.mjs +53 -0
  79. package/runtime/engine/chunk-GOLP7OSG.mjs +340 -0
  80. package/runtime/engine/chunk-GSLM44EF.mjs +242 -0
  81. package/runtime/engine/chunk-GYAJ7OX2.mjs +125 -0
  82. package/runtime/engine/chunk-I3GWR43K.mjs +14 -0
  83. package/runtime/engine/chunk-IFMOTJNU.mjs +106 -0
  84. package/runtime/engine/chunk-IKQKBE2G.mjs +128 -0
  85. package/runtime/engine/chunk-ITH2NEKM.mjs +282 -0
  86. package/runtime/engine/chunk-J6SDRCG4.mjs +96 -0
  87. package/runtime/engine/chunk-JODRNM3S.mjs +29596 -0
  88. package/runtime/engine/chunk-JUDKX53X.mjs +137 -0
  89. package/runtime/engine/chunk-K2YZVPJ4.mjs +827 -0
  90. package/runtime/engine/chunk-KEZJUXEE.mjs +151 -0
  91. package/runtime/engine/chunk-KVLTJFCH.mjs +234 -0
  92. package/runtime/engine/chunk-KX2PRQPS.mjs +126 -0
  93. package/runtime/engine/chunk-LEW5ZMLR.mjs +76 -0
  94. package/runtime/engine/chunk-LINVSJEM.mjs +175 -0
  95. package/runtime/engine/chunk-M7K2ICSM.mjs +11 -0
  96. package/runtime/engine/chunk-MZXDXSDC.mjs +292 -0
  97. package/runtime/engine/chunk-N2TA2IK2.mjs +678 -0
  98. package/runtime/engine/chunk-N4LTCKJP.mjs +695 -0
  99. package/runtime/engine/chunk-N6GCLOUX.mjs +13 -0
  100. package/runtime/engine/chunk-NAG2OXS5.mjs +37 -0
  101. package/runtime/engine/chunk-NNZ2QJUG.mjs +381 -0
  102. package/runtime/engine/chunk-NZPPLDNW.mjs +15 -0
  103. package/runtime/engine/chunk-ODWM57W6.mjs +138 -0
  104. package/runtime/engine/chunk-P5IIXAIE.mjs +23 -0
  105. package/runtime/engine/chunk-PBOXB2BV.mjs +6 -0
  106. package/runtime/engine/chunk-PMOJLN2P.mjs +8 -0
  107. package/runtime/engine/chunk-PZFMKFHO.mjs +180 -0
  108. package/runtime/engine/chunk-QL2TQX2N.mjs +114 -0
  109. package/runtime/engine/chunk-RITT2RSJ.mjs +258 -0
  110. package/runtime/engine/chunk-RODBVJ5M.mjs +135 -0
  111. package/runtime/engine/chunk-RW65MPVY.mjs +261 -0
  112. package/runtime/engine/chunk-S67UYPB6.mjs +25 -0
  113. package/runtime/engine/chunk-SVJCOUI3.mjs +47 -0
  114. package/runtime/engine/chunk-TCN3ZASV.mjs +957 -0
  115. package/runtime/engine/chunk-U2NRG6KC.mjs +32 -0
  116. package/runtime/engine/chunk-UM3F7HUV.mjs +432 -0
  117. package/runtime/engine/chunk-VWU7JJ3P.mjs +146 -0
  118. package/runtime/engine/chunk-WDTKPPMU.mjs +310 -0
  119. package/runtime/engine/chunk-WJOO4XTB.mjs +31 -0
  120. package/runtime/engine/chunk-XNFVL2OY.mjs +63 -0
  121. package/runtime/engine/chunk-XPWJXP2J.mjs +58 -0
  122. package/runtime/engine/chunk-Y3HSBJ3I.mjs +1132 -0
  123. package/runtime/engine/chunk-YMH4RYSX.mjs +317 -0
  124. package/runtime/engine/chunk-YNOMPSGS.mjs +8 -0
  125. package/runtime/engine/chunk-YRBAYTEZ.mjs +251 -0
  126. package/runtime/engine/chunk-YRHM272W.mjs +528 -0
  127. package/runtime/engine/chunk-ZQUZAGIQ.mjs +149 -0
  128. package/runtime/engine/chunk-ZXMM7QFP.mjs +176 -0
  129. package/runtime/engine/chunk-ZZJSIPV2.mjs +262 -0
  130. package/runtime/engine/composition.mjs +325 -0
  131. package/runtime/engine/document-local.mjs +504 -0
  132. package/runtime/engine/graph.json +4134 -0
  133. package/runtime/engine/index.mjs +265 -0
  134. package/runtime/engine/local-postgres-support.mjs +69 -0
  135. package/runtime/engine/local.mjs +3275 -0
  136. package/runtime/engine/pglite-directory-lock.mjs +8 -0
  137. package/runtime/engine/rag.mjs +11 -0
  138. package/runtime/engine/search.mjs +18 -0
  139. package/runtime/framework-migrations/foundation-bootstrap/rag.sql +115 -0
  140. package/runtime/framework-migrations/foundation-bootstrap/workflow.sql +194 -0
  141. package/runtime/framework-migrations/journal-bootstrap/migration.sql +26 -0
  142. package/runtime/framework-migrations/manifest.json +56 -0
  143. package/runtime/framework-migrations/rag/20261006111509_mushy_warhawk/migration.sql +121 -0
  144. package/runtime/framework-migrations/rag/20261013234621_rag_v2_lifecycle_markers/migration.sql +6 -0
  145. package/runtime/framework-migrations/workflow/20261006111508_perpetual_star_brand/migration.sql +31 -0
  146. package/runtime/runtime-metadata.json +27 -0
  147. package/runtime/tooling.mjs +10549 -10543
  148. package/scripts/bundle-runtime-config.mjs +23 -0
  149. package/scripts/bundle-runtime.mjs +100 -0
  150. package/scripts/bundle-runtime.test.mjs +33 -0
  151. package/scripts/bundle-shared.mjs +3 -0
  152. package/scripts/copy-dashboard.mjs +16 -0
  153. package/scripts/pre-publish-check.mjs +23 -11
  154. package/templateFeature/ai/ai-embedding-result.ts +82 -0
  155. package/templateFeature/ai/ai-facade.ts +24 -7
  156. package/templateFeature/ai/ai-provider.ts +17 -1
  157. package/templateFeature/ai/ai.ts +1 -0
  158. package/templateFeature/ai/manifest.json +4 -3
  159. package/templateFeature/reranker/manifest.json +1 -1
  160. package/templateFeature/reranker/reranker.ts +4 -3
  161. package/templateFeature/sso/sso-auth-callback.tsx +37 -5
  162. package/templateFeature/tools/manifest.json +2 -1
  163. package/templateFeature/tools/tools.ts +3 -3
  164. package/dashboard/assets/index-C6-BpKKR.css +0 -2
  165. package/runtime/server.mjs +0 -14320
  166. package/scripts/bundle-server.mjs +0 -223
  167. package/server/config.js +0 -1
  168. package/server/index.js +0 -1
  169. package/server/package.json +0 -6
@@ -1,5 +1,6 @@
1
+ import { fileURLToPath } from "node:url";
1
2
  import { execSync, spawn } from "child_process";
2
- import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, rmSync, unlinkSync } from "fs";
3
+ import { cpSync, existsSync, mkdirSync, readFileSync, unlinkSync } from "fs";
3
4
  import { dirname, resolve } from "path";
4
5
 
5
6
  import {
@@ -11,13 +12,8 @@ import { formatCommandError } from "./cli-command-runner.mjs";
11
12
  import { runMetadataUpgrade } from "./db-metadata-command.mjs";
12
13
  import { runDrizzleGenerateWithFallback } from "./drizzle-generate.mjs";
13
14
  import { beginMetadataCapture, inspectMetadataHistory, MigrationMetadataError } from "./metadata-upgrade.mjs";
14
- import { resolveProjectSelection } from "./project-context.mjs";
15
-
16
- export function resolveBundledServerEntry(findServerRootValue, resolvePathImpl, existsSyncImpl) {
17
- const runtimeEntry = resolvePathImpl(findServerRootValue, "..", "runtime", "server.mjs");
18
- if (existsSyncImpl(runtimeEntry)) return runtimeEntry;
19
- return resolvePathImpl(findServerRootValue, "index.js");
20
- }
15
+ import { getCliInvocationSelection, resolveProjectSelection } from "./project-context.mjs";
16
+ import { resolveLocalRuntimeFeatures } from "./local-runtime-features.mjs";
21
17
 
22
18
  export function shouldUseLocalDev({ devArgs, processEnv = process.env }) {
23
19
  return processEnv.GENCOW_LOCAL === "1" || devArgs.includes("--local");
@@ -69,7 +65,6 @@ export function createDevLocalCommands({
69
65
  buildEnv,
70
66
  CYAN = "",
71
67
  cleanupOldBackups,
72
- copyFileSyncImpl = copyFileSync,
73
68
  cpSyncImpl = cpSync,
74
69
  cwdImpl = () => process.cwd(),
75
70
  DIM = "",
@@ -78,10 +73,8 @@ export function createDevLocalCommands({
78
73
  execSyncImpl = execSync,
79
74
  existsSyncImpl = existsSync,
80
75
  exitImpl = (code) => process.exit(code ?? 0),
81
- findServerRoot,
82
76
  generateApiTsImpl,
83
77
  GREEN = "",
84
- isMonorepo,
85
78
  loadConfig,
86
79
  logImpl,
87
80
  infoImpl,
@@ -94,7 +87,6 @@ export function createDevLocalCommands({
94
87
  readFileSyncImpl = readFileSync,
95
88
  RESET = "",
96
89
  resolvePathImpl = resolve,
97
- rmSyncImpl = rmSync,
98
90
  runDevCloudImpl,
99
91
  renderDevHelpImpl = (log) => {
100
92
  log("Usage: gencow dev [--local] [--verbose] [--app <name>]");
@@ -102,7 +94,6 @@ export function createDevLocalCommands({
102
94
  },
103
95
  setTimeoutImpl = setTimeout,
104
96
  spawnImpl = spawn,
105
- spawnInServer,
106
97
  unlinkSyncImpl = unlinkSync,
107
98
  } = {}) {
108
99
  function resolveProjectDirFromInvocation(cwd) {
@@ -127,7 +118,8 @@ export function createDevLocalCommands({
127
118
 
128
119
  const cwd = cwdImpl();
129
120
  const projectDir = resolveProjectDirFromInvocation(cwd);
130
- const config = await loadConfig({ cwd: projectDir, processEnv });
121
+ const { assertLocalDashboardConfiguration } = await import("./local-dashboard-plan.mjs");
122
+ const config = await loadConfig({ cwd: projectDir, processEnv, validateLoadedConfig: assertLocalDashboardConfiguration });
131
123
  const authDup = detectConflictingAuthSchemaFiles(projectDir, config, { existsSyncImpl, resolvePathImpl });
132
124
  if (authDup.conflict) {
133
125
  logImpl("");
@@ -137,20 +129,20 @@ export function createDevLocalCommands({
137
129
  }
138
130
  logImpl(`\n${BOLD}${CYAN}Gencow Dev${RESET} ${DIM}(local)${RESET}\n`);
139
131
  infoImpl(`Backend root: ${DIM}${config.rootDir}${RESET}`);
140
- infoImpl(`Storage: ${DIM}${config.storage}${RESET}`);
132
+ const { storage } = await resolveLocalRuntimeFeatures(config, processEnv);
133
+ infoImpl(`Storage: ${DIM}${storage.adapter === "filesystem" ? storage.path : storage.adapter}${RESET}`);
141
134
  infoImpl(`DB: ${DIM}${config.db.url}${RESET}`);
142
135
  logImpl("");
143
136
 
144
137
  const functionsAbsolute = resolvePathImpl(projectDir, config.rootDir);
145
138
  const dbDir = resolvePathImpl(projectDir, config.db.url);
146
- const storageDir = resolvePathImpl(projectDir, config.storage);
147
139
  const migrationsDir = resolvePathImpl(projectDir, config.rootDir, "migrations");
148
140
  // Metadata failures must stop before touching a running local server or its data.
149
141
  // Keep schema/environment errors on the existing fallback path below.
150
142
  let genEnv;
151
143
  let genEnvError;
152
144
  try {
153
- genEnv = buildEnv(config, { cwd: projectDir });
145
+ genEnv = buildEnv(config, { cwd: projectDir, localStorage: storage });
154
146
  } catch (error) {
155
147
  if (error?.code?.startsWith("MIGRATION_METADATA_")) throw error;
156
148
  genEnvError = error;
@@ -173,7 +165,9 @@ export function createDevLocalCommands({
173
165
  }
174
166
  mkdirSyncImpl(functionsAbsolute, { recursive: true });
175
167
  mkdirSyncImpl(dbDir, { recursive: true });
176
- mkdirSyncImpl(storageDir, { recursive: true });
168
+ if (storage.adapter === "filesystem") {
169
+ mkdirSyncImpl(resolvePathImpl(projectDir, storage.path), { recursive: true, mode: 0o700 });
170
+ }
177
171
  mkdirSyncImpl(migrationsDir, { recursive: true });
178
172
 
179
173
  const oldDataDir = resolvePathImpl(projectDir, "packages/server/data");
@@ -241,44 +235,13 @@ export function createDevLocalCommands({
241
235
  await generateApiTsImpl(config, { cwd: projectDir });
242
236
 
243
237
  logImpl("");
244
- infoImpl("Starting server with hot-reload...\n");
245
- let proc;
246
- if (isMonorepo({ cwd: projectDir, existsSyncImpl, resolvePathImpl })) {
247
- proc = spawnInServer("pnpm", ["dev", "--gencow-local-development"], buildEnv(config, { cwd: projectDir }), { cwd: projectDir });
248
- } else {
249
- const serverRoot = findServerRoot({ cwd: projectDir, existsSyncImpl, resolvePathImpl });
250
- const bundledServer = resolveBundledServerEntry(serverRoot, resolvePathImpl, existsSyncImpl);
251
- const localServer = resolvePathImpl(projectDir, ".gencow", "server.js");
252
-
253
- try {
254
- unlinkSyncImpl(localServer);
255
- } catch {
256
- /* ignore */
257
- }
258
- copyFileSyncImpl(bundledServer, localServer);
259
-
260
- const cliRoot = resolvePathImpl(serverRoot, "..");
261
- const dashboardSource = resolvePathImpl(cliRoot, "dashboard");
262
- const dashboardDest = resolvePathImpl(projectDir, ".gencow", "dashboard");
263
- if (existsSyncImpl(dashboardSource)) {
264
- try {
265
- rmSyncImpl(dashboardDest, { recursive: true, force: true });
266
- } catch {
267
- /* ignore */
268
- }
269
- cpSyncImpl(dashboardSource, dashboardDest, { recursive: true });
270
- }
271
-
272
- proc = spawnImpl("bun", ["--watch", localServer, "--gencow-local-development"], {
273
- cwd: projectDir,
274
- stdio: "inherit",
275
- shell: true,
276
- env: {
277
- ...buildEnv(config, { cwd: projectDir }),
278
- GENCOW_DASHBOARD_DIR: dashboardDest,
279
- },
280
- });
281
- }
238
+ infoImpl("Starting local Runtime with native Bun watch...\n");
239
+ const selection = getCliInvocationSelection();
240
+ const proc = spawnImpl("bun", ["--watch", fileURLToPath(new URL("./runtime-local-worker.mjs", import.meta.url)),
241
+ JSON.stringify({projectDir,configPath:selection?.configPath ?? null,client:selection?.client ?? null,target:selection?.target ?? null})], {
242
+ cwd: projectDir, stdio: "inherit", shell: false,
243
+ env: buildEnv(config, { cwd: projectDir, localStorage: storage }),
244
+ });
282
245
 
283
246
  proc.on("exit", (code) => processRef.exit(code ?? 0));
284
247
  processRef.on("SIGINT", () => {
@@ -0,0 +1,11 @@
1
+ import {
2
+ createAutomaticLocalDocumentConverter,
3
+ createLocalDocumentParserLoaders,
4
+ } from "../runtime/engine/document-local.mjs";
5
+
6
+ /** Trusted CLI-local supplier. Resolve CLI-owned parsers, never the tenant/workspace package graph. */
7
+ export function createCliDocumentConverter() {
8
+ return createAutomaticLocalDocumentConverter({
9
+ loaders: createLocalDocumentParserLoaders(import.meta.url),
10
+ });
11
+ }
@@ -13,7 +13,8 @@ export function normalizeWorkflowCleanupStatus(status) {
13
13
  export function formatCronFailureDetail(errorMessage, failureDomain, maxLength) {
14
14
  const domainPrefix = failureDomain ? `[${failureDomain}] ` : "";
15
15
  try {
16
- if (JSON.parse(String(errorMessage))?.code === "FUNCTION_TIMEOUT_WORK_STILL_LIVE") {
16
+ const code = JSON.parse(String(errorMessage))?.code;
17
+ if (["FUNCTION_TIMEOUT_WORK_STILL_LIVE", "SCHEDULED_JOB_ATTEMPT_OUTCOME_UNKNOWN", "SCHEDULED_JOB_ATTEMPT_STILL_RUNNING"].includes(code)) {
17
18
  return `${domainPrefix}${formatScheduledJobFailure(errorMessage)}`;
18
19
  }
19
20
  } catch {
@@ -22,9 +23,40 @@ export function formatCronFailureDetail(errorMessage, failureDomain, maxLength)
22
23
  return `${domainPrefix}${String(errorMessage).slice(0, maxLength)}`;
23
24
  }
24
25
 
26
+ // Mirrors Server's scheduled-job-attempt-contract.ts by value (packages do not import each other's code).
27
+ const ATTEMPT_RECHECK_SECONDS = 30;
28
+ const ATTEMPT_UNKNOWN_CEILING_SECONDS = 630;
29
+
30
+ function formatDispatchAttemptDiagnostic(d, handlerState, dataImpactLine, extraLines = []) {
31
+ return [
32
+ `${d.code} at ${d.stage}; ${handlerState}.`,
33
+ dataImpactLine,
34
+ `Retryable: ${d.retryable === true ? "yes" : "no"}. Retry condition: ${d.retryCondition}`,
35
+ `Next: ${d.nextAction}`,
36
+ ...extraLines,
37
+ `Correlation ID: ${d.correlationId}`,
38
+ ].join("\n ");
39
+ }
40
+
25
41
  export function formatScheduledJobFailure(errorMessage) {
26
42
  try {
27
43
  const diagnostic = JSON.parse(String(errorMessage));
44
+ if (diagnostic.code === "SCHEDULED_JOB_ATTEMPT_OUTCOME_UNKNOWN") {
45
+ const recheck = `Platform re-check: about every ${ATTEMPT_RECHECK_SECONDS} seconds (first unknown at ${diagnostic.firstUnknownAt}); treated as a normal failure after about 10 minutes (${ATTEMPT_UNKNOWN_CEILING_SECONDS}s) without a result.`;
46
+ return formatDispatchAttemptDiagnostic(
47
+ diagnostic,
48
+ "handler may still be running (outcome unknown)",
49
+ `Data impact: ${diagnostic.dataImpact} (handler side effects not confirmed); serving state: ${diagnostic.servingState}.`,
50
+ [recheck],
51
+ );
52
+ }
53
+ if (diagnostic.code === "SCHEDULED_JOB_ATTEMPT_STILL_RUNNING") {
54
+ return formatDispatchAttemptDiagnostic(
55
+ diagnostic,
56
+ "handler still running (already running)",
57
+ `Data impact: ${diagnostic.dataImpact}; serving state: ${diagnostic.servingState}. Duplicate refused; no handler ran for this delivery.`,
58
+ );
59
+ }
28
60
  if (diagnostic.code === "FUNCTION_TIMEOUT_WORK_STILL_LIVE") {
29
61
  return [
30
62
  `${diagnostic.code} at ${diagnostic.stage}; handler ${diagnostic.execution}.`,
@@ -0,0 +1,60 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { RuntimeDiagnosticError } from "../runtime/engine/index.mjs";
5
+ import { validateDashboardArtifact } from "./dashboard-artifact.mjs";
6
+
7
+ const ownCliRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
8
+
9
+ function failure(code, nextAction) {
10
+ return new RuntimeDiagnosticError({
11
+ code,
12
+ stage: "startup",
13
+ capability: "dashboard",
14
+ servingStarted: false,
15
+ dataImpact: "none",
16
+ retryable: false,
17
+ retryPrecondition:
18
+ "Correct dashboard configuration or restore the intended built artifact before restarting.",
19
+ nextAction,
20
+ correlationId: crypto.randomUUID(),
21
+ });
22
+ }
23
+
24
+ /** Local-only option policy runs before generic schema errors can erase its
25
+ * actionable diagnosis, and again on the normalized launch boundary. */
26
+ export function assertLocalDashboardConfiguration(config) {
27
+ const dashboard = config.localFeatures?.dashboard ?? config.experimental?.localFeatures?.dashboard;
28
+ if (dashboard === false || dashboard?.enabled === false) return undefined;
29
+ if ((dashboard?.path !== undefined && dashboard.path !== "/_dashboard") || dashboard?.port !== undefined) {
30
+ throw failure(
31
+ "RUNTIME_LOCAL_DASHBOARD_CONFIG_UNSUPPORTED",
32
+ "Use localFeatures.dashboard with the default /_dashboard mount and application port; remove dashboard.path/dashboard.port overrides, then run gencow dev --local.",
33
+ );
34
+ }
35
+ }
36
+
37
+ /** CLI owns asset discovery; Runtime receives only immutable resolved launch options. */
38
+ export function resolveLocalDashboardPlan({ config, cliRoot = ownCliRoot }) {
39
+ const dashboard = config.localFeatures?.dashboard ?? config.experimental?.localFeatures?.dashboard;
40
+ if (dashboard === false || dashboard?.enabled === false) return undefined;
41
+ assertLocalDashboardConfiguration(config);
42
+ const checkout = resolve(cliRoot, "../..");
43
+ const workspace =
44
+ existsSync(resolve(checkout, "pnpm-workspace.yaml")) &&
45
+ existsSync(resolve(checkout, "apps/system/dashboard/package.json")) &&
46
+ resolve(checkout, "packages/cli") === resolve(cliRoot);
47
+ const directory = workspace
48
+ ? resolve(checkout, "apps/system/dashboard/dist")
49
+ : resolve(cliRoot, "dashboard");
50
+ try {
51
+ return Object.freeze({ assetsDirectory: validateDashboardArtifact(directory), path: "/_dashboard" });
52
+ } catch {
53
+ throw failure(
54
+ "RUNTIME_LOCAL_DASHBOARD_ASSETS_MISSING",
55
+ workspace
56
+ ? "Run pnpm run build:dashboard in the workspace, then run gencow dev --local."
57
+ : "In this app workspace, reinstall the same intended gencow version/artifact, then run gencow dev --local.",
58
+ );
59
+ }
60
+ }
@@ -0,0 +1,127 @@
1
+ import { buildLocalExecutionFailureDiagnostic } from "./migration-client-diagnostic.mjs";
2
+ import { renderMigrationDiagnosticLines } from "./migration-diagnostic.mjs";
3
+ import { spawnSync } from "node:child_process";
4
+ import { dirname, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import {
7
+ applyLocalDevelopmentMigrations,
8
+ classifyLocalMigrationCommandFailure,
9
+ localMigrationDiagnostic,
10
+ localMigrationOutputFailure,
11
+ requireLocalPostgresUrl,
12
+ } from "./local-development-migrations.mjs";
13
+ import { resolveProjectSelection } from "./project-context.mjs";
14
+ import { resolveLocalRuntimeFeatures } from "./local-runtime-features.mjs";
15
+ import { runDrizzleGenerateWithFallback } from "./drizzle-generate.mjs";
16
+
17
+ const configPath = resolve(dirname(fileURLToPath(import.meta.url)), "local-drizzle-database.config.mjs");
18
+
19
+ function runPostgresPush(deps, env) {
20
+ const tool = deps.drizzleKitCmdImpl("push", { canonicalConfigPath: configPath });
21
+ let result;
22
+ try {
23
+ result = (deps.spawnSyncImpl ?? spawnSync)(tool.command, [...tool.args, "--force"], {
24
+ cwd: deps.cwdImpl(),
25
+ env: { ...env, ...tool.env },
26
+ stdio: "pipe",
27
+ shell: false,
28
+ });
29
+ } catch {
30
+ result = { error: true };
31
+ }
32
+ if (result.error || result.status !== 0) {
33
+ // Never leak a subprocess exception containing credentials or raw SQL.
34
+ const diagnostic = buildLocalExecutionFailureDiagnostic(crypto.randomUUID());
35
+ const failure = new Error(renderMigrationDiagnosticLines(diagnostic).join("\n"));
36
+ failure.diagnostic = diagnostic;
37
+ throw failure;
38
+ }
39
+ }
40
+
41
+ export async function runLocalDatabaseCommand({ command, config, deps, jsonMode = false }) {
42
+ const projectDir = deps.cwdImpl();
43
+ const env = deps.buildEnv(config, {
44
+ cwd: projectDir,
45
+ processEnv: deps.processEnv ?? process.env,
46
+ localStorage: config.localFeatures?.storage,
47
+ });
48
+ const { database } = await resolveLocalRuntimeFeatures(config, env);
49
+ if (database.adapter === "postgres") requireLocalPostgresUrl(env);
50
+ if (command === "db:push") {
51
+ if (database.adapter === "postgres") return runPostgresPush(deps, env);
52
+ runDrizzleGenerateWithFallback({
53
+ cwd: projectDir,
54
+ drizzleKitCmdImpl: deps.drizzleKitCmdImpl,
55
+ env,
56
+ execSyncImpl: deps.execSyncImpl,
57
+ stdio: jsonMode ? "pipe" : "inherit",
58
+ warnImpl: deps.warnImpl,
59
+ });
60
+ }
61
+ return (deps.applyLocalMigrationsImpl ?? applyLocalDevelopmentMigrations)({
62
+ projectDir,
63
+ config: { ...config, localFeatures: { ...config.localFeatures, database } },
64
+ environment: env,
65
+ });
66
+ }
67
+
68
+ export function createLocalDbMigrateCommand(deps) {
69
+ return async (...args) => {
70
+ const json = args.includes("--json");
71
+ let result;
72
+ try {
73
+ const config = await deps.loadConfig();
74
+ const projectDir = resolveProjectSelection({
75
+ allowMissingConfig: true,
76
+ cwd: deps.cwdImpl(),
77
+ existsSyncImpl: deps.existsSyncImpl,
78
+ resolvePathImpl: deps.resolvePathImpl,
79
+ processEnv: deps.processEnv ?? process.env,
80
+ }).projectDir;
81
+ if (!json) deps.infoImpl("Applying pending local migrations...");
82
+ const receipt = await runLocalDatabaseCommand({
83
+ command: "db:migrate",
84
+ config,
85
+ deps: { ...deps, cwdImpl: () => projectDir },
86
+ });
87
+ result = {
88
+ diagnosticVersion: 1,
89
+ ok: true,
90
+ command: "db:migrate",
91
+ target: "local",
92
+ databaseState: "APPLIED",
93
+ applicationImpact: receipt?.applicationImpact ?? "unknown",
94
+ frameworkImpact: "none",
95
+ ...(receipt?.correlationId ? { correlationId: receipt.correlationId } : {}),
96
+ warnings: [],
97
+ };
98
+ } catch (error) {
99
+ const failure = classifyLocalMigrationCommandFailure(error);
100
+ if (!json) throw failure;
101
+ result = {
102
+ diagnosticVersion: 1,
103
+ ok: false,
104
+ command: "db:migrate",
105
+ target: "local",
106
+ ...localMigrationDiagnostic(failure),
107
+ warnings: [],
108
+ };
109
+ }
110
+ // Rendering is outside execution: a broken output stream must never rerun SQL.
111
+ try {
112
+ if (json) deps.logImpl(JSON.stringify(result));
113
+ else {
114
+ deps.logImpl(
115
+ `Application impact: ${result.applicationImpact}\nFramework impact: none${result.correlationId ? `\nCorrelation ID: ${result.correlationId}` : ""}`,
116
+ );
117
+ deps.successImpl("Migrations applied!");
118
+ }
119
+ } catch {
120
+ throw localMigrationOutputFailure();
121
+ }
122
+ if (!result.ok) {
123
+ deps.exitImpl(1);
124
+ return 1;
125
+ }
126
+ };
127
+ }
@@ -0,0 +1,157 @@
1
+ import { createRequire } from "node:module";
2
+ import { resolve } from "node:path";
3
+ import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import { mkdirSync, unlinkSync } from "node:fs";
5
+ import { spawnSync } from "node:child_process";
6
+ import { randomUUID } from "node:crypto";
7
+ import { RuntimeDiagnosticError, runtimeDiagnostic } from "../runtime/engine/index.mjs";
8
+ import { configuredLocalDatabaseAdapter } from "./local-runtime-features.mjs";
9
+
10
+ export const localMigrationDiagnostic = (error) => runtimeDiagnostic(error);
11
+ function migrationFailure(kind = "unknown") {
12
+ const details = {
13
+ dependency: {
14
+ code: "RUNTIME_LOCAL_MIGRATION_DEPENDENCY_MISSING",
15
+ nextAction: "Install the project's dependencies, then run gencow db:migrate. Preserve applied migrations and data.",
16
+ retryPrecondition: "Install the missing project dependencies before retrying.",
17
+ },
18
+ sql: {
19
+ code: "RUNTIME_LOCAL_MIGRATION_SQL_FAILED",
20
+ nextAction: "Inspect the pending migration and database state before retrying gencow db:migrate. Preserve applied migrations and data; do not blindly replay mutations.",
21
+ retryPrecondition: "Resolve the pending migration error and inspect database state before retrying.",
22
+ },
23
+ unknown: {
24
+ code: "RUNTIME_LOCAL_MIGRATION_FAILED",
25
+ nextAction: "Check the local database connection and pending migrations, then run gencow db:migrate. Preserve applied migrations and data; do not blindly replay mutations.",
26
+ retryPrecondition: "Inspect the local migration failure and database state before retrying.",
27
+ },
28
+ }[kind] ?? null;
29
+ if (!details) return migrationFailure();
30
+ return new RuntimeDiagnosticError({
31
+ code: details.code,
32
+ stage: "migration",
33
+ capability: "database",
34
+ servingStarted: false,
35
+ dataImpact: "unknown",
36
+ applicationImpact: "unknown",
37
+ frameworkImpact: "none",
38
+ retryable: false,
39
+ correlationId: randomUUID(),
40
+ retryPrecondition: details.retryPrecondition,
41
+ nextAction: details.nextAction,
42
+ });
43
+ }
44
+ function migrationFailureKind(error) {
45
+ for (let current = error, depth = 0; current && depth < 5; current = current.cause, depth++) {
46
+ if (current.code === "MODULE_NOT_FOUND" || current.code === "ERR_MODULE_NOT_FOUND") return "dependency";
47
+ if (typeof current.code === "string" && /^(22|23|42)[0-9A-Z]{3}$/.test(current.code)) return "sql";
48
+ }
49
+ return "unknown";
50
+ }
51
+ export const classifyLocalMigrationCommandFailure = (error) =>
52
+ localMigrationDiagnostic(error) ? error : migrationFailure();
53
+ export const localMigrationOutputFailure = () => migrationFailure();
54
+
55
+ export function requireLocalPostgresUrl(environment) {
56
+ const value = environment.DATABASE_URL?.trim();
57
+ let valid = false;
58
+ try {
59
+ const url = new URL(value);
60
+ valid = (url.protocol === "postgres:" || url.protocol === "postgresql:") && !!url.hostname;
61
+ } catch {
62
+ // Render a safe diagnostic below rather than exposing the supplied URL.
63
+ }
64
+ if (!valid) throw new RuntimeDiagnosticError({
65
+ code: "RUNTIME_LOCAL_POSTGRES_URL_INVALID",
66
+ stage: "migration",
67
+ capability: "database",
68
+ servingStarted: false,
69
+ dataImpact: "none",
70
+ applicationImpact: "none",
71
+ frameworkImpact: "none",
72
+ retryable: false,
73
+ correlationId: randomUUID(),
74
+ retryPrecondition: "Configure a valid PostgreSQL DATABASE_URL for the intended local database.",
75
+ nextAction: "Set DATABASE_URL to the intended local PostgreSQL connection URL, then retry the command.",
76
+ });
77
+ return value;
78
+ }
79
+
80
+ /** Incumbent local behavior: Drizzle owns migration parsing, execution and history.
81
+ * No additional CLI policy, advisory lock, grant rewriting or outcome recovery.
82
+ */
83
+ export async function applyLocalDevelopmentMigrations(input) {
84
+ const { projectDir, config, environment = process.env } = input;
85
+ const postgres = configuredLocalDatabaseAdapter(config) === "postgres";
86
+ if (postgres) requireLocalPostgresUrl(environment);
87
+ if (!process.versions.bun) {
88
+ const child = spawnSync("bun", [fileURLToPath(import.meta.url)], {
89
+ cwd: projectDir,
90
+ env: environment,
91
+ input: JSON.stringify({ projectDir, config }),
92
+ encoding: "utf8",
93
+ stdio: ["pipe", "pipe", "pipe"],
94
+ });
95
+ if (child.error || child.status !== 0) {
96
+ let kind = "unknown";
97
+ try { kind = JSON.parse(child.stdout).kind; } catch { /* Unknown child failure. */ }
98
+ throw migrationFailure(kind);
99
+ }
100
+ return { applicationImpact: "unknown", frameworkImpact: "none", correlationId: randomUUID() };
101
+ }
102
+ const requireProject = createRequire(resolve(projectDir, "package.json"));
103
+ const load = (name) => import(pathToFileURL(requireProject.resolve(name)).href);
104
+ let client;
105
+ try {
106
+ let db, migrate;
107
+ if (postgres) {
108
+ const { SQL } = await import("bun");
109
+ const sdk = await load("drizzle-orm/bun-sql");
110
+ ({ migrate } = await load("drizzle-orm/bun-sql/migrator"));
111
+ client = new SQL(environment.DATABASE_URL);
112
+ db = sdk.drizzle({ client });
113
+ } else {
114
+ const dataDir = resolve(projectDir, config.db?.url ?? ".gencow/data");
115
+ mkdirSync(dataDir, { recursive: true });
116
+ // Deliberate parity with Server local startup, including its unsafe PID cleanup.
117
+ try {
118
+ unlinkSync(resolve(dataDir, "postmaster.pid"));
119
+ } catch {
120
+ /* Same as Server. */
121
+ }
122
+ const [{ PGlite }, sdk, { vector }, { pg_trgm }] = await Promise.all([
123
+ load("@electric-sql/pglite"),
124
+ load("drizzle-orm/pglite"),
125
+ load("@electric-sql/pglite/vector"),
126
+ load("@electric-sql/pglite/contrib/pg_trgm"),
127
+ ]);
128
+ ({ migrate } = await load("drizzle-orm/pglite/migrator"));
129
+ client = new PGlite({ dataDir, extensions: { vector, pg_trgm } });
130
+ await client.exec("CREATE EXTENSION IF NOT EXISTS vector; CREATE EXTENSION IF NOT EXISTS pg_trgm;");
131
+ db = sdk.drizzle({ client });
132
+ }
133
+ await migrate(db, { migrationsFolder: resolve(projectDir, config.rootDir ?? "gencow", "migrations") });
134
+ return { applicationImpact: "unknown", frameworkImpact: "none", correlationId: randomUUID() };
135
+ } catch (error) {
136
+ throw migrationFailure(migrationFailureKind(error));
137
+ } finally {
138
+ try {
139
+ await client?.close();
140
+ } catch {
141
+ throw migrationFailure();
142
+ }
143
+ }
144
+ }
145
+
146
+ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
147
+ try {
148
+ const input = await Bun.stdin.text();
149
+ await applyLocalDevelopmentMigrations(JSON.parse(input));
150
+ } catch (error) {
151
+ const code = localMigrationDiagnostic(error)?.code;
152
+ const kind = code === "RUNTIME_LOCAL_MIGRATION_DEPENDENCY_MISSING" ? "dependency" :
153
+ code === "RUNTIME_LOCAL_MIGRATION_SQL_FAILED" ? "sql" : "unknown";
154
+ process.stdout.write(JSON.stringify({ kind }));
155
+ process.exitCode = 1;
156
+ }
157
+ }
@@ -0,0 +1,10 @@
1
+ import generation from "./canonical-drizzle-generator.config.mjs";
2
+
3
+ // Generation always uses the portable schema-only contract. Database writes
4
+ // select their actual local provider here, never a repository runtime package.
5
+ const url = process.env.DATABASE_URL?.trim();
6
+ const { driver, dbCredentials, ...schema } = generation;
7
+ export default {
8
+ ...schema,
9
+ ...(url ? { dbCredentials: { url } } : { driver, dbCredentials }),
10
+ };
@@ -0,0 +1,12 @@
1
+ import { loadConfigModuleForRuntime } from "./cli-project-runtime.mjs";
2
+
3
+ /** Resolve defaults through the canonical Shared config implementation. */
4
+ export async function resolveLocalRuntimeFeatures(projectConfig, environment) {
5
+ const config = await loadConfigModuleForRuntime();
6
+ return config.resolveLocalRuntimeFeatures(projectConfig, environment);
7
+ }
8
+
9
+ /** Raw legacy declarations can still enter local DB commands through older callers. */
10
+ export function configuredLocalDatabaseAdapter(config) {
11
+ return config.localFeatures?.database?.adapter ?? config.experimental?.localFeatures?.database?.adapter;
12
+ }
@@ -0,0 +1,7 @@
1
+ import { captureRuntimeRagSelection } from "../runtime/engine/rag.mjs";
2
+
3
+ /** Select local RAG without altering generic Runtime provider contracts. */
4
+ export function selectRuntimeRag(selection) {
5
+ if (selection === undefined || selection === false) return undefined;
6
+ return captureRuntimeRagSelection(selection === true ? {} : selection);
7
+ }
@@ -299,7 +299,7 @@ export function buildAiPrompt(apiObj, namespaces) {
299
299
  md += ` const hash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));\n\n`;
300
300
  md += `AI rules:\n`;
301
301
  md += `- New AI SDK-native code can use createGencowAI() from "./ai" with generateText(), embed(), and generateImage().\n`;
302
- md += `- Existing generated components can use ai.chat(), ai.vision.extractText(), ai.image.generate(), and ai.generateObject() through the Gencow facade. ai.rerank() requires a deployed rerank route; local direct mode has no rerank provider. It accepts Cohere-rerank-v4.0-fast or Cohere-rerank-v4.0-pro with providerPreference auto or azure_cohere; pass no more than 100 documents after applying app ACLs. Ranking uses the query and document text; do not treat document metadata as authorization. gpt_fallback returns HTTP 400 AI_RERANK_PROVIDER_UNSUPPORTED rather than silently substituting a chat model. A provider mismatch returns HTTP 503 AI_RERANK_PROVIDER_UNAVAILABLE; route/admission failures retain their own returned status and code.\n`;
302
+ md += `- Existing generated components can use ai.chat(), ai.vision.extractText(), ai.image.generate(), and ai.generateObject() through the Gencow facade. ai.rerank() requires a deployed rerank route; local direct mode has no rerank provider. It accepts Cohere-rerank-v5.0-fast or Cohere-rerank-v5.0-pro with providerPreference auto or cohere; pass no more than 100 documents after applying app ACLs. Ranking uses the query and document text; do not treat document metadata as authorization. gpt_fallback returns HTTP 400 AI_RERANK_PROVIDER_UNSUPPORTED rather than silently substituting a chat model. A provider mismatch returns HTTP 503 AI_RERANK_PROVIDER_UNAVAILABLE; route/admission failures retain their own returned status and code.\n`;
303
303
  md += `- Do not import @ai-sdk/openai/createOpenAI directly, call provider APIs directly, or create wrapper files such as openai-direct.ts.\n`;
304
304
  md += `- Do not log image base64, prompts, provider tokens, or raw private document snippets.\n`;
305
305
  md += `- The generated createGencowAI() provider accepts llm/economy, llm/balanced, llm/quality, and llm/code in local direct mode and deployed apps. Deployed chat also accepts supported OpenAI model IDs without silently substituting another model; provider availability and deprecation still apply.\n`;
@@ -359,7 +359,7 @@ export function buildAiUsageSection() {
359
359
  md += `| Image-to-text / OCR-style extraction | \`llm/balanced\` |\n`;
360
360
  md += `| Image generation | \`gpt-image-2\` or \`gpt-image-1-mini\` |\n\n`;
361
361
  md += `Use \`createGencowAI()\` or the \`ai.*\` facade from \`./ai\` rather than calling provider APIs directly.\n\n`;
362
- md += `The \`ai.rerank()\` facade requires a deployed rerank route; local direct mode has no rerank provider. Its typed model choices are \`Cohere-rerank-v4.0-fast\` and \`Cohere-rerank-v4.0-pro\`; choose \`providerPreference: "auto"\` or \`"azure_cohere"\`. Pass no more than 100 documents after applying app ACLs. Ranking uses the query and document text; document metadata is not authorization. \`"gpt_fallback"\` returns HTTP 400 with \`AI_RERANK_PROVIDER_UNSUPPORTED\` and does not substitute a chat model. A provider mismatch returns HTTP 503 with \`AI_RERANK_PROVIDER_UNAVAILABLE\`; route/admission failures retain their own returned status and code.\n\n`;
362
+ md += `The \`ai.rerank()\` facade requires a deployed rerank route; local direct mode has no rerank provider. Its typed model choices are \`Cohere-rerank-v5.0-fast\` and \`Cohere-rerank-v5.0-pro\`; choose \`providerPreference: "auto"\` or \`"cohere"\`. Pass no more than 100 documents after applying app ACLs. Ranking uses the query and document text; document metadata is not authorization. \`"gpt_fallback"\` returns HTTP 400 with \`AI_RERANK_PROVIDER_UNSUPPORTED\` and does not substitute a chat model. A provider mismatch returns HTTP 503 with \`AI_RERANK_PROVIDER_UNAVAILABLE\`; route/admission failures retain their own returned status and code.\n\n`;
363
363
  md += `Speech availability depends on the operation: OpenAI transcription models and Azure Speech Fast support transcription; Azure Speech neural TTS is not an eligible route. OpenAI TTS such as \`gpt-4o-mini-tts\` uses active output-usage pricing for settlement. An unavailable capability returns \`AI_CAPABILITY_UNAVAILABLE\`.\n\n`;
364
364
  md += `Transcription pricing errors can return \`price_meter_missing\`, \`price_meter_stale\`, or \`price_meter_invalid\` at \`pricing_admission\`; the asynchronous job is then \`failed_refunded\` (\`state_changed: true\`, \`retryable: false\`). Pricing is managed by the service: choose a currently supported transcription model/capability, or wait until the required transcription usage price is available and start a new job. Do not edit service pricing or blindly retry the failed job.\n\n`;
365
365
  md += `OpenAI TTS uses service pricing at admission and for usage settlement. At \`pricing_admission\`, errors can return \`price_meter_missing\`, \`price_meter_stale\`, or \`price_meter_invalid\` before provider work. Separately, invalid provider usage or unavailable usage pricing can fail the job after synthesis as \`failed_refunded\` with \`AI_MODEL_PRICING_UNAVAILABLE\`; provider work may already have occurred. Choose a currently supported TTS model/capability, or wait until the required TTS usage price is available, then start a new job. Do not edit service pricing or blindly retry the failed job.\n\n`;