gencow 0.1.299 → 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/package.json +1 -1
- package/docs/packaging.md +14 -4
- package/lib/cli-artifact-guard.mjs +53 -3
- 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/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/dev-cloud-command.mjs +1 -1
- package/lib/dev-local-command.mjs +19 -56
- package/lib/document-local-converter.mjs +11 -0
- 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/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/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 +10399 -8951
- 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/sso/sso-auth-callback.tsx +37 -5
- package/templateFeature/tools/manifest.json +2 -1
- package/templateFeature/tools/tools.ts +3 -3
- package/runtime/server.mjs +0 -14389
- 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
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RuntimeDiagnosticError
|
|
3
|
+
} from "./chunk-AEBW7XZJ.mjs";
|
|
4
|
+
|
|
5
|
+
// ../runtime/dist/rag/job-errors.js
|
|
6
|
+
function ragJobError(code) {
|
|
7
|
+
return new RuntimeDiagnosticError({
|
|
8
|
+
code,
|
|
9
|
+
stage: "request",
|
|
10
|
+
capability: "application",
|
|
11
|
+
servingStarted: "unchanged",
|
|
12
|
+
dataImpact: "none",
|
|
13
|
+
retryable: false,
|
|
14
|
+
retryPrecondition: code === "RAG_JOB_INPUT_INVALID" ? "Correct the job ID or list filters before repeating this read." : "The same job's canonical workflow and scoped source must be readable and consistent before repeating this read.",
|
|
15
|
+
nextAction: code === "RAG_JOB_INPUT_INVALID" ? "Supply a nonempty job ID, or a known job status, string corpus and finite numeric limit. Limits are floored and clamped to 1\u2013100. No data changed." : "Preserve this job and source. Inspect workflows.get for the same workflow ID and selected database readiness. Do not edit internal rows or start replacement conversion work; this inspection changed no data."
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// ../runtime/dist/adapters/rag/pgvector/job-query.js
|
|
20
|
+
import { sql as sql2 } from "drizzle-orm";
|
|
21
|
+
|
|
22
|
+
// ../runtime/dist/adapters/rag/pgvector/workflow-state.js
|
|
23
|
+
import { sql } from "drizzle-orm";
|
|
24
|
+
function ragWorkflowTerminal(version, status, completedAt) {
|
|
25
|
+
return sql`(${completedAt} IS NOT NULL AND ${status} IN ${version === "v2" ? sql`('completed','failed','cancelled')` : sql`('completed','failed')`})`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ../runtime/dist/adapters/rag/pgvector/job-query.js
|
|
29
|
+
var ragJobStatuses = [
|
|
30
|
+
"queued",
|
|
31
|
+
"converting",
|
|
32
|
+
"chunking",
|
|
33
|
+
"embedding",
|
|
34
|
+
"upserting",
|
|
35
|
+
"completed",
|
|
36
|
+
"failed",
|
|
37
|
+
"canceled"
|
|
38
|
+
];
|
|
39
|
+
var ragJobStages = [
|
|
40
|
+
...ragJobStatuses,
|
|
41
|
+
"validateInput",
|
|
42
|
+
"loadStoredFile",
|
|
43
|
+
"convertAndPersistSource",
|
|
44
|
+
"embedChunkBatch",
|
|
45
|
+
"recordUsageAndFinalize"
|
|
46
|
+
];
|
|
47
|
+
function ragJobRows(result) {
|
|
48
|
+
if (Array.isArray(result))
|
|
49
|
+
return result;
|
|
50
|
+
if (result && typeof result === "object" && "rows" in result && Array.isArray(result.rows))
|
|
51
|
+
return result.rows;
|
|
52
|
+
throw ragJobError("RAG_JOB_OBSERVATION_UNAVAILABLE");
|
|
53
|
+
}
|
|
54
|
+
async function ragObservedJobProjection(db, userId, filters, assertScope) {
|
|
55
|
+
const presence = ragJobRows(await db.execute(sql2`SELECT
|
|
56
|
+
to_regclass('public._gencow_workflow_runs_v2') IS NOT NULL AS modern,
|
|
57
|
+
to_regclass('public._gencow_workflows') IS NOT NULL AS legacy`))[0];
|
|
58
|
+
if (!presence)
|
|
59
|
+
throw ragJobError("RAG_JOB_OBSERVATION_UNAVAILABLE");
|
|
60
|
+
assertScope();
|
|
61
|
+
const branches = [];
|
|
62
|
+
if (presence.modern)
|
|
63
|
+
branches.push(sql2`SELECT id,user_id,args_json AS args,status,'v2'::text AS dialect,completed_at,
|
|
64
|
+
error_code,CASE WHEN octet_length(error_json::text)<=16384 THEN error_json->>'message' END AS error_message,
|
|
65
|
+
left(error_json->>'producerCode',129) AS producer_code,
|
|
66
|
+
${ragWorkflowTerminal("v2", sql2`status`, sql2`completed_at`)} AS terminal,
|
|
67
|
+
status IN ('queued','running','sleeping','waiting','completed','failed','cancelled') AS known_status FROM public._gencow_workflow_runs_v2`);
|
|
68
|
+
if (presence.legacy)
|
|
69
|
+
branches.push(sql2`SELECT id,user_id,args,status,'v1'::text AS dialect,completed_at,error_code,
|
|
70
|
+
CASE WHEN octet_length(error)<=16384 THEN error END AS error_message,NULL::text AS producer_code,
|
|
71
|
+
${ragWorkflowTerminal("v1", sql2`status`, sql2`completed_at`)} AS terminal,
|
|
72
|
+
status IN ('pending','running','completed','failed') AS known_status FROM public._gencow_workflows legacy
|
|
73
|
+
${presence.modern ? sql2`WHERE NOT EXISTS(SELECT 1 FROM public._gencow_workflow_runs_v2 modern WHERE modern.id=legacy.id)` : sql2``}`);
|
|
74
|
+
const canonical = branches.length ? sql2.join(branches, sql2` UNION ALL `) : sql2`SELECT NULL::text AS id,NULL::text AS user_id,
|
|
75
|
+
NULL::jsonb AS args,NULL::text AS status,NULL::text AS dialect,NULL::timestamptz AS completed_at,NULL::text AS error_code,
|
|
76
|
+
NULL::text AS error_message,NULL::text AS producer_code,false AS terminal,false AS known_status WHERE false`;
|
|
77
|
+
return sql2`WITH canonical_raw AS (${canonical}), canonical AS (
|
|
78
|
+
SELECT *,CASE WHEN args ? 'value' THEN args->'value' ELSE args END AS input FROM canonical_raw
|
|
79
|
+
), scoped AS (
|
|
80
|
+
SELECT j.id,j.workflow_id,j.source_id,w.input->>'storageId' AS storage_id,j.corpus,j.visibility_scope,j.owner_user_id,j.status AS job_status,
|
|
81
|
+
CASE WHEN j.stage IN (${sql2.join(ragJobStages.map((stage) => sql2`${stage}`), sql2`,`)}) THEN j.stage END AS stage,
|
|
82
|
+
j.started_at::text,j.updated_at,w.completed_at,w.status AS workflow_status,w.dialect AS workflow_dialect,w.terminal,w.error_code,w.error_message,w.producer_code,
|
|
83
|
+
CASE WHEN octet_length(j.provider_trace::text)<=16384 THEN j.provider_trace END AS provider_trace,
|
|
84
|
+
CASE WHEN octet_length(j.metrics::text)<=65536 THEN j.metrics END AS metrics,
|
|
85
|
+
COALESCE(w.id IS NOT NULL AND w.known_status AND (w.completed_at IS NULL OR (w.terminal AND isfinite(w.completed_at)))
|
|
86
|
+
AND isfinite(j.started_at) AND isfinite(j.updated_at) AND octet_length(w.args::text)<=1048576
|
|
87
|
+
AND (w.status NOT IN ('completed','failed','cancelled') OR w.terminal)
|
|
88
|
+
AND s.id IS NOT NULL AND j.visibility_scope IN ('private','shared','public')
|
|
89
|
+
AND jsonb_typeof(w.input)='object' AND jsonb_typeof(w.input->'sourceId')='string' AND w.input->>'sourceId'=j.source_id
|
|
90
|
+
AND jsonb_typeof(w.input->'jobId')='string' AND w.input->>'jobId'=j.id
|
|
91
|
+
AND jsonb_typeof(w.input->'corpus')='string' AND btrim(w.input->>'corpus')=j.corpus
|
|
92
|
+
AND jsonb_typeof(w.input->'visibility')='string' AND w.input->>'visibility'=j.visibility_scope
|
|
93
|
+
AND jsonb_typeof(w.input->'storageId')='string'
|
|
94
|
+
AND (NOT (w.input ? 'ownerUserId') OR jsonb_typeof(w.input->'ownerUserId')='string')
|
|
95
|
+
AND COALESCE(NULLIF(btrim(w.input->>'ownerUserId'),''),CASE WHEN j.visibility_scope='private' THEN w.user_id END)
|
|
96
|
+
IS NOT DISTINCT FROM j.owner_user_id
|
|
97
|
+
AND (j.owner_user_id IS NULL OR w.user_id=j.owner_user_id)
|
|
98
|
+
AND jsonb_typeof(j.provider_trace)='object' AND octet_length(j.provider_trace::text)<=16384
|
|
99
|
+
AND jsonb_typeof(j.metrics)='object' AND octet_length(j.metrics::text)<=65536,false) AS valid
|
|
100
|
+
FROM public.rag_ingest_jobs j LEFT JOIN canonical w ON w.id=j.workflow_id
|
|
101
|
+
LEFT JOIN public.rag_sources s ON s.id=j.source_id AND s.corpus=j.corpus AND s.visibility_scope=j.visibility_scope
|
|
102
|
+
AND s.owner_user_id IS NOT DISTINCT FROM j.owner_user_id
|
|
103
|
+
WHERE (j.owner_user_id=${userId} OR (j.owner_user_id IS NULL AND j.visibility_scope IN ('shared','public')))
|
|
104
|
+
AND (j.owner_user_id IS NULL OR w.id IS NULL OR w.user_id IS NULL OR w.user_id=${userId})
|
|
105
|
+
-- Retired finalized V2 rows are not effective jobs. Their existing V2
|
|
106
|
+
-- row still shadows any legacy row with the same id in canonical_raw.
|
|
107
|
+
AND (j.retired_at IS NULL OR j.finalized_revision IS DISTINCT FROM j.retry_revision)
|
|
108
|
+
${filters.id ? sql2`AND j.id=${filters.id}` : sql2``}
|
|
109
|
+
${filters.corpus ? sql2`AND j.corpus=${filters.corpus}` : sql2``}
|
|
110
|
+
), observed AS (
|
|
111
|
+
SELECT *,CASE WHEN terminal THEN CASE
|
|
112
|
+
WHEN workflow_dialect='v2' AND workflow_status='completed' THEN 'completed'
|
|
113
|
+
WHEN workflow_dialect='v2' AND workflow_status='cancelled' THEN 'canceled'
|
|
114
|
+
WHEN workflow_dialect='v2' AND workflow_status='failed' THEN 'failed'
|
|
115
|
+
WHEN workflow_dialect='v1' AND workflow_status='completed' THEN 'completed'
|
|
116
|
+
WHEN workflow_dialect='v1' AND workflow_status='failed' AND error_code='cancelled' THEN 'canceled'
|
|
117
|
+
WHEN workflow_dialect='v1' AND workflow_status='failed' THEN 'failed' ELSE 'failed' END
|
|
118
|
+
WHEN job_status IN ('queued','converting','chunking','embedding','upserting') THEN job_status ELSE 'queued' END AS observed_status,
|
|
119
|
+
CASE WHEN terminal THEN completed_at::text END AS terminal_at FROM scoped
|
|
120
|
+
)`;
|
|
121
|
+
}
|
|
122
|
+
async function readRagJobs(db, userId, filters, assertScope) {
|
|
123
|
+
const projection = await ragObservedJobProjection(db, userId, filters, assertScope);
|
|
124
|
+
return ragJobRows(await db.execute(sql2`${projection} SELECT * FROM observed WHERE ${filters.id ? sql2`true` : sql2`valid`}
|
|
125
|
+
${filters.status ? sql2`AND observed_status=${filters.status}` : sql2``}
|
|
126
|
+
ORDER BY updated_at DESC,id ASC LIMIT ${filters.id ? 1 : filters.limit ?? 20}`));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export {
|
|
130
|
+
ragWorkflowTerminal,
|
|
131
|
+
ragJobError,
|
|
132
|
+
ragJobStatuses,
|
|
133
|
+
ragJobStages,
|
|
134
|
+
ragJobRows,
|
|
135
|
+
ragObservedJobProjection,
|
|
136
|
+
readRagJobs
|
|
137
|
+
};
|