@floless/app 0.134.4 → 0.135.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/dist/floless-server.cjs +319 -226
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +12 -15
- package/dist/web/aware.js +11 -3
- package/dist/web/index.html +1 -1
- package/dist/web/steel-filter.html +77 -31
- package/dist/web/steel-model-v2-client-validation.js +12 -1
- package/dist/web/workspaces.js +73 -17
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -43012,7 +43012,7 @@ var require_static = __commonJS({
|
|
|
43012
43012
|
"use strict";
|
|
43013
43013
|
var path = require("node:path");
|
|
43014
43014
|
var { fileURLToPath: fileURLToPath6 } = require("node:url");
|
|
43015
|
-
var { statSync:
|
|
43015
|
+
var { statSync: statSync33 } = require("node:fs");
|
|
43016
43016
|
var { glob } = require_commonjs6();
|
|
43017
43017
|
var fp = require_plugin2();
|
|
43018
43018
|
var send = require_send2();
|
|
@@ -43375,7 +43375,7 @@ var require_static = __commonJS({
|
|
|
43375
43375
|
}
|
|
43376
43376
|
let pathStat;
|
|
43377
43377
|
try {
|
|
43378
|
-
pathStat =
|
|
43378
|
+
pathStat = statSync33(rootPath);
|
|
43379
43379
|
} catch (e) {
|
|
43380
43380
|
if (e.code === "ENOENT") {
|
|
43381
43381
|
fastify.log.warn(`"root" path "${rootPath}" must exist`);
|
|
@@ -43399,7 +43399,7 @@ var require_static = __commonJS({
|
|
|
43399
43399
|
return indexFiles.find((filename) => {
|
|
43400
43400
|
const p = path.join(root6, pathname, filename);
|
|
43401
43401
|
try {
|
|
43402
|
-
const stats =
|
|
43402
|
+
const stats = statSync33(p);
|
|
43403
43403
|
return !stats.isDirectory();
|
|
43404
43404
|
} catch {
|
|
43405
43405
|
return false;
|
|
@@ -55050,7 +55050,7 @@ function appVersion() {
|
|
|
55050
55050
|
return resolveVersion({
|
|
55051
55051
|
isSea: isSea2(),
|
|
55052
55052
|
sqVersionXml: readSqVersionXml(),
|
|
55053
|
-
define: true ? "0.
|
|
55053
|
+
define: true ? "0.135.0" : void 0,
|
|
55054
55054
|
pkgVersion: readPkgVersion()
|
|
55055
55055
|
});
|
|
55056
55056
|
}
|
|
@@ -55066,7 +55066,7 @@ function resolveChannel(s) {
|
|
|
55066
55066
|
function appChannel() {
|
|
55067
55067
|
return resolveChannel({
|
|
55068
55068
|
isSea: isSea2(),
|
|
55069
|
-
define: true ? "0.
|
|
55069
|
+
define: true ? "0.135.0" : void 0,
|
|
55070
55070
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
55071
55071
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
55072
55072
|
modulePath: process.argv[1]
|
|
@@ -56475,7 +56475,7 @@ function checkModelReferences(doc) {
|
|
|
56475
56475
|
}
|
|
56476
56476
|
const compare = (dir, parsedCount) => {
|
|
56477
56477
|
const declared = axes.filter((a) => isObj(a) && a.dir === dir).length;
|
|
56478
|
-
if (declared !== parsedCount) add("$.grid.axes", "grid-axis-count",
|
|
56478
|
+
if (declared !== parsedCount) add("$.grid.axes", "grid-axis-count", `$.grid.${dir} parses to ${parsedCount} ${dir} ${parsedCount === 1 ? "entry" : "entries"} but $.grid.axes declares ${declared} ${dir} ${declared === 1 ? "axis" : "axes"} \u2014 one axis row per parsed entry, so edit $.grid.${dir} and $.grid.axes together until the counts match`);
|
|
56479
56479
|
};
|
|
56480
56480
|
for (const dir of ["x", "y"]) {
|
|
56481
56481
|
const text5 = str(grid[dir]);
|
|
@@ -63011,9 +63011,103 @@ function decodeSnapshots(inputs) {
|
|
|
63011
63011
|
var import_node_os21 = require("node:os");
|
|
63012
63012
|
var import_node_path31 = require("node:path");
|
|
63013
63013
|
|
|
63014
|
+
// instructor-request.ts
|
|
63015
|
+
var import_node_crypto20 = require("node:crypto");
|
|
63016
|
+
|
|
63017
|
+
// app-id.ts
|
|
63018
|
+
var APP_ID4 = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
63019
|
+
function isSafeAppId(value) {
|
|
63020
|
+
return typeof value === "string" && APP_ID4.test(value) && safeSegment(value);
|
|
63021
|
+
}
|
|
63022
|
+
|
|
63023
|
+
// instructor-request.ts
|
|
63024
|
+
function normalizeInstructorContext(raw) {
|
|
63025
|
+
if (!raw || typeof raw !== "object") return null;
|
|
63026
|
+
const context = raw;
|
|
63027
|
+
const { tone, facts } = context;
|
|
63028
|
+
if (typeof context.subject !== "string" || !context.subject.trim() || context.subject.length > 300) return null;
|
|
63029
|
+
if (tone !== "idle" && tone !== "armed" && tone !== "blocked") return null;
|
|
63030
|
+
if (!Array.isArray(facts) || facts.length > 12 || !facts.every((fact) => typeof fact === "string" && fact.length <= 500)) return null;
|
|
63031
|
+
if (typeof context.surface !== "string" || !context.surface || context.surface.length > 100) return null;
|
|
63032
|
+
if (context.commandId !== void 0 && (typeof context.commandId !== "string" || context.commandId.length > 200)) return null;
|
|
63033
|
+
if (context.instance !== void 0 && (typeof context.instance !== "string" || context.instance.length > 300)) return null;
|
|
63034
|
+
return {
|
|
63035
|
+
subject: context.subject.trim(),
|
|
63036
|
+
commandId: context.commandId,
|
|
63037
|
+
instance: context.instance,
|
|
63038
|
+
tone,
|
|
63039
|
+
facts,
|
|
63040
|
+
surface: context.surface
|
|
63041
|
+
};
|
|
63042
|
+
}
|
|
63043
|
+
function normalizeInstructorGuideRequest(rawBody) {
|
|
63044
|
+
const body = rawBody && typeof rawBody === "object" ? rawBody : {};
|
|
63045
|
+
const { appId, project, projectLabel, instructorContext: rawContext } = body;
|
|
63046
|
+
const normalizedProjectLabel = typeof projectLabel === "string" ? projectLabel.trim() : void 0;
|
|
63047
|
+
if (appId !== void 0 && !isSafeAppId(appId)) return { error: "appId is invalid" };
|
|
63048
|
+
if (project !== void 0 && !isProjectId(project)) return { error: "project is invalid" };
|
|
63049
|
+
if (projectLabel !== void 0 && !normalizedProjectLabel) {
|
|
63050
|
+
return { error: "projectLabel is invalid" };
|
|
63051
|
+
}
|
|
63052
|
+
if ((project || projectLabel) && (!project || !appId || rawContext === void 0)) {
|
|
63053
|
+
return { error: "complete project scope requires Instructor context" };
|
|
63054
|
+
}
|
|
63055
|
+
const instructorContext = rawContext === void 0 ? void 0 : normalizeInstructorContext(rawContext);
|
|
63056
|
+
if (rawContext !== void 0 && !instructorContext) return { error: "Instructor context is invalid" };
|
|
63057
|
+
if (!appId && !instructorContext) return { error: "a valid appId is required" };
|
|
63058
|
+
return {
|
|
63059
|
+
value: {
|
|
63060
|
+
...appId ? { appId } : {},
|
|
63061
|
+
...project ? { project } : {},
|
|
63062
|
+
// Project names have no authored length limit. This field is narration only, so retain a
|
|
63063
|
+
// bounded prefix instead of rejecting an otherwise valid project's Instructor request.
|
|
63064
|
+
...normalizedProjectLabel ? { projectLabel: normalizedProjectLabel.slice(0, 200) } : {},
|
|
63065
|
+
...instructorContext ? { instructorContext } : {}
|
|
63066
|
+
}
|
|
63067
|
+
};
|
|
63068
|
+
}
|
|
63069
|
+
function instructorRequestFingerprint(request) {
|
|
63070
|
+
if (request.type !== "guide" || !request.instructorContext) return null;
|
|
63071
|
+
const normalized = normalizeInstructorGuideRequest({
|
|
63072
|
+
appId: request.appId,
|
|
63073
|
+
project: request.project,
|
|
63074
|
+
projectLabel: request.projectLabel,
|
|
63075
|
+
instructorContext: request.instructorContext
|
|
63076
|
+
});
|
|
63077
|
+
if (!normalized.value?.instructorContext) return null;
|
|
63078
|
+
const value = normalized.value;
|
|
63079
|
+
const context = value.instructorContext;
|
|
63080
|
+
const canonical2 = JSON.stringify({
|
|
63081
|
+
type: "guide",
|
|
63082
|
+
appId: value.appId ?? null,
|
|
63083
|
+
project: value.project ?? null,
|
|
63084
|
+
projectLabel: value.projectLabel ?? null,
|
|
63085
|
+
instructorContext: {
|
|
63086
|
+
subject: context.subject,
|
|
63087
|
+
commandId: context.commandId ?? null,
|
|
63088
|
+
instance: context.instance ?? null,
|
|
63089
|
+
tone: context.tone,
|
|
63090
|
+
facts: context.facts,
|
|
63091
|
+
surface: context.surface
|
|
63092
|
+
}
|
|
63093
|
+
});
|
|
63094
|
+
return (0, import_node_crypto20.createHash)("sha256").update(canonical2).digest("hex");
|
|
63095
|
+
}
|
|
63096
|
+
function validatedInstructorAnswer(request) {
|
|
63097
|
+
const run2 = request.run;
|
|
63098
|
+
if (request.type !== "guide" || !request.instructorContext || run2?.state !== "answered") return null;
|
|
63099
|
+
const completion = validateCompletion({ outcome: "answered", answer: run2.answer });
|
|
63100
|
+
if (completion.kind !== "answered") return null;
|
|
63101
|
+
const fingerprint = instructorRequestFingerprint(request);
|
|
63102
|
+
if (!fingerprint || run2.inputFingerprint !== fingerprint) return null;
|
|
63103
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(run2.leaseId) || !Number.isFinite(Date.parse(run2.finishedAt ?? ""))) return null;
|
|
63104
|
+
if (run2.lastOutput || run2.question || run2.handoffReady || run2.recoveryReady) return null;
|
|
63105
|
+
return { answer: completion.answer, inputFingerprint: fingerprint, leaseId: run2.leaseId, finishedAt: run2.finishedAt };
|
|
63106
|
+
}
|
|
63107
|
+
|
|
63014
63108
|
// run-audit.ts
|
|
63015
63109
|
var import_node_fs32 = require("node:fs");
|
|
63016
|
-
var
|
|
63110
|
+
var import_node_crypto21 = require("node:crypto");
|
|
63017
63111
|
var import_node_os20 = require("node:os");
|
|
63018
63112
|
var import_node_path30 = require("node:path");
|
|
63019
63113
|
var MAX_BYTES5 = 5 * 1024 * 1024;
|
|
@@ -63027,7 +63121,7 @@ function auditEvent(input) {
|
|
|
63027
63121
|
return {
|
|
63028
63122
|
v: 1,
|
|
63029
63123
|
at: input.at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
63030
|
-
eventId: input.eventId ?? (0,
|
|
63124
|
+
eventId: input.eventId ?? (0, import_node_crypto21.randomUUID)(),
|
|
63031
63125
|
event: input.event,
|
|
63032
63126
|
leaseId: input.leaseId,
|
|
63033
63127
|
requestId: input.requestId,
|
|
@@ -63044,7 +63138,7 @@ function auditEvent(input) {
|
|
|
63044
63138
|
function preflightRunAudit() {
|
|
63045
63139
|
const root6 = ROOT5();
|
|
63046
63140
|
(0, import_node_fs32.mkdirSync)(root6, { recursive: true, mode: 448 });
|
|
63047
|
-
const probe = (0, import_node_path30.join)(root6, `.probe-${process.pid}-${(0,
|
|
63141
|
+
const probe = (0, import_node_path30.join)(root6, `.probe-${process.pid}-${(0, import_node_crypto21.randomUUID)()}`);
|
|
63048
63142
|
const fd2 = (0, import_node_fs32.openSync)(probe, "wx", 384);
|
|
63049
63143
|
try {
|
|
63050
63144
|
(0, import_node_fs32.writeFileSync)(fd2, "");
|
|
@@ -63152,7 +63246,7 @@ var RUN_POLICY = {
|
|
|
63152
63246
|
runnable: true,
|
|
63153
63247
|
calls: (l) => [
|
|
63154
63248
|
{ method: "GET", path: "/api/requests", why: "read the authoritative spec for this request" },
|
|
63155
|
-
...
|
|
63249
|
+
...isSafeAppId2(l.appId) ? [{ method: "POST", path: "/api/compile", body: { id: l.appId }, why: "compile the workflow after editing its .flo" }] : [],
|
|
63156
63250
|
{ method: "DELETE", path: `/api/requests/${l.requestId}`, why: "clear this request once applied" }
|
|
63157
63251
|
],
|
|
63158
63252
|
// The `.flo` lives in the app's own source directory, NOT in the nominated folder — which is
|
|
@@ -63205,7 +63299,7 @@ function steelPreparationTimeoutWhy(req) {
|
|
|
63205
63299
|
function runEligibilityFor(req) {
|
|
63206
63300
|
const policy = policyFor(req.type);
|
|
63207
63301
|
if (!policy.runnable) return policy;
|
|
63208
|
-
if (req.type === "guide" && !req.instructorContext) {
|
|
63302
|
+
if (req.type === "guide" && !normalizeInstructorContext(req.instructorContext)) {
|
|
63209
63303
|
return { runnable: false, why: "workflow tours are conversations \u2014 use Copy to continue in your terminal" };
|
|
63210
63304
|
}
|
|
63211
63305
|
if (req.type !== "revision-read") return { runnable: true, policy };
|
|
@@ -63230,7 +63324,7 @@ function runEligibilityFor(req) {
|
|
|
63230
63324
|
if (req.prepassReady === true) {
|
|
63231
63325
|
return {
|
|
63232
63326
|
runnable: false,
|
|
63233
|
-
why: req.
|
|
63327
|
+
why: req.filterCheckpointCurrent === true ? "this Drawing Filter is saved \u2014 continue the drawing read in the terminal AI that prepared it" : "this Drawing Filter is ready \u2014 review it and press Save filter, then continue in the terminal AI that prepared it"
|
|
63234
63328
|
};
|
|
63235
63329
|
}
|
|
63236
63330
|
if (!req.project || !req.appId || !Number.isInteger(req.baseVersion) || Number(req.baseVersion) <= 0) {
|
|
@@ -63254,9 +63348,9 @@ function runEligibilityFor(req) {
|
|
|
63254
63348
|
return { runnable: true, policy };
|
|
63255
63349
|
}
|
|
63256
63350
|
var SAFE_APP_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
63257
|
-
var
|
|
63351
|
+
var isSafeAppId2 = (id) => typeof id === "string" && SAFE_APP_ID.test(id);
|
|
63258
63352
|
function appSourceDir(appId) {
|
|
63259
|
-
if (!
|
|
63353
|
+
if (!isSafeAppId2(appId)) return null;
|
|
63260
63354
|
const root6 = process.env.AWARE_HOME || (0, import_node_path31.join)((0, import_node_os21.homedir)(), ".aware");
|
|
63261
63355
|
return (0, import_node_path31.join)(root6, "apps", appId);
|
|
63262
63356
|
}
|
|
@@ -63621,100 +63715,6 @@ function onlyThisRequest(body, requestId) {
|
|
|
63621
63715
|
return { ...b, requests: b.requests.filter((r) => r?.id === requestId) };
|
|
63622
63716
|
}
|
|
63623
63717
|
|
|
63624
|
-
// instructor-request.ts
|
|
63625
|
-
var import_node_crypto21 = require("node:crypto");
|
|
63626
|
-
|
|
63627
|
-
// app-id.ts
|
|
63628
|
-
var APP_ID4 = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
63629
|
-
function isSafeAppId2(value) {
|
|
63630
|
-
return typeof value === "string" && APP_ID4.test(value) && safeSegment(value);
|
|
63631
|
-
}
|
|
63632
|
-
|
|
63633
|
-
// instructor-request.ts
|
|
63634
|
-
function normalizeInstructorContext(raw) {
|
|
63635
|
-
if (!raw || typeof raw !== "object") return null;
|
|
63636
|
-
const context = raw;
|
|
63637
|
-
const { tone, facts } = context;
|
|
63638
|
-
if (typeof context.subject !== "string" || !context.subject.trim() || context.subject.length > 300) return null;
|
|
63639
|
-
if (tone !== "idle" && tone !== "armed" && tone !== "blocked") return null;
|
|
63640
|
-
if (!Array.isArray(facts) || facts.length > 12 || !facts.every((fact) => typeof fact === "string" && fact.length <= 500)) return null;
|
|
63641
|
-
if (typeof context.surface !== "string" || !context.surface || context.surface.length > 100) return null;
|
|
63642
|
-
if (context.commandId !== void 0 && (typeof context.commandId !== "string" || context.commandId.length > 200)) return null;
|
|
63643
|
-
if (context.instance !== void 0 && (typeof context.instance !== "string" || context.instance.length > 300)) return null;
|
|
63644
|
-
return {
|
|
63645
|
-
subject: context.subject.trim(),
|
|
63646
|
-
commandId: context.commandId,
|
|
63647
|
-
instance: context.instance,
|
|
63648
|
-
tone,
|
|
63649
|
-
facts,
|
|
63650
|
-
surface: context.surface
|
|
63651
|
-
};
|
|
63652
|
-
}
|
|
63653
|
-
function normalizeInstructorGuideRequest(rawBody) {
|
|
63654
|
-
const body = rawBody && typeof rawBody === "object" ? rawBody : {};
|
|
63655
|
-
const { appId, project, projectLabel, instructorContext: rawContext } = body;
|
|
63656
|
-
const normalizedProjectLabel = typeof projectLabel === "string" ? projectLabel.trim() : void 0;
|
|
63657
|
-
if (appId !== void 0 && !isSafeAppId2(appId)) return { error: "appId is invalid" };
|
|
63658
|
-
if (project !== void 0 && !isProjectId(project)) return { error: "project is invalid" };
|
|
63659
|
-
if (projectLabel !== void 0 && !normalizedProjectLabel) {
|
|
63660
|
-
return { error: "projectLabel is invalid" };
|
|
63661
|
-
}
|
|
63662
|
-
if ((project || projectLabel) && (!project || !appId || rawContext === void 0)) {
|
|
63663
|
-
return { error: "complete project scope requires Instructor context" };
|
|
63664
|
-
}
|
|
63665
|
-
const instructorContext = rawContext === void 0 ? void 0 : normalizeInstructorContext(rawContext);
|
|
63666
|
-
if (rawContext !== void 0 && !instructorContext) return { error: "Instructor context is invalid" };
|
|
63667
|
-
if (!appId && !instructorContext) return { error: "a valid appId is required" };
|
|
63668
|
-
return {
|
|
63669
|
-
value: {
|
|
63670
|
-
...appId ? { appId } : {},
|
|
63671
|
-
...project ? { project } : {},
|
|
63672
|
-
// Project names have no authored length limit. This field is narration only, so retain a
|
|
63673
|
-
// bounded prefix instead of rejecting an otherwise valid project's Instructor request.
|
|
63674
|
-
...normalizedProjectLabel ? { projectLabel: normalizedProjectLabel.slice(0, 200) } : {},
|
|
63675
|
-
...instructorContext ? { instructorContext } : {}
|
|
63676
|
-
}
|
|
63677
|
-
};
|
|
63678
|
-
}
|
|
63679
|
-
function instructorRequestFingerprint(request) {
|
|
63680
|
-
if (request.type !== "guide" || !request.instructorContext) return null;
|
|
63681
|
-
const normalized = normalizeInstructorGuideRequest({
|
|
63682
|
-
appId: request.appId,
|
|
63683
|
-
project: request.project,
|
|
63684
|
-
projectLabel: request.projectLabel,
|
|
63685
|
-
instructorContext: request.instructorContext
|
|
63686
|
-
});
|
|
63687
|
-
if (!normalized.value?.instructorContext) return null;
|
|
63688
|
-
const value = normalized.value;
|
|
63689
|
-
const context = value.instructorContext;
|
|
63690
|
-
const canonical2 = JSON.stringify({
|
|
63691
|
-
type: "guide",
|
|
63692
|
-
appId: value.appId ?? null,
|
|
63693
|
-
project: value.project ?? null,
|
|
63694
|
-
projectLabel: value.projectLabel ?? null,
|
|
63695
|
-
instructorContext: {
|
|
63696
|
-
subject: context.subject,
|
|
63697
|
-
commandId: context.commandId ?? null,
|
|
63698
|
-
instance: context.instance ?? null,
|
|
63699
|
-
tone: context.tone,
|
|
63700
|
-
facts: context.facts,
|
|
63701
|
-
surface: context.surface
|
|
63702
|
-
}
|
|
63703
|
-
});
|
|
63704
|
-
return (0, import_node_crypto21.createHash)("sha256").update(canonical2).digest("hex");
|
|
63705
|
-
}
|
|
63706
|
-
function validatedInstructorAnswer(request) {
|
|
63707
|
-
const run2 = request.run;
|
|
63708
|
-
if (request.type !== "guide" || !request.instructorContext || run2?.state !== "answered") return null;
|
|
63709
|
-
const completion = validateCompletion({ outcome: "answered", answer: run2.answer });
|
|
63710
|
-
if (completion.kind !== "answered") return null;
|
|
63711
|
-
const fingerprint = instructorRequestFingerprint(request);
|
|
63712
|
-
if (!fingerprint || run2.inputFingerprint !== fingerprint) return null;
|
|
63713
|
-
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(run2.leaseId) || !Number.isFinite(Date.parse(run2.finishedAt ?? ""))) return null;
|
|
63714
|
-
if (run2.lastOutput || run2.question || run2.handoffReady || run2.recoveryReady) return null;
|
|
63715
|
-
return { answer: completion.answer, inputFingerprint: fingerprint, leaseId: run2.leaseId, finishedAt: run2.finishedAt };
|
|
63716
|
-
}
|
|
63717
|
-
|
|
63718
63718
|
// terminal-runtime.ts
|
|
63719
63719
|
var import_node_fs34 = require("node:fs");
|
|
63720
63720
|
var import_node_os22 = require("node:os");
|
|
@@ -64140,7 +64140,7 @@ ${isInitialRead ? "Initial" : "Revised"} drawing${req.snapshots.length > 1 ? "s"
|
|
|
64140
64140
|
My note: ${req.instruction}` : "";
|
|
64141
64141
|
const messageHint = isInitialRead ? "<plain-English what was read>" : "<plain-English what changed>";
|
|
64142
64142
|
const vectorPost = `GET the current contract again and keep its ETag, then POST /api/projects/${req.project}/revision-read with { contract, message: "${messageHint}", requestId: "${req.id}" } and If-Match: <that current ETag>. The server derives the base version and source provenance from this queued request. The first completed vector drawing publishes History version 1; later reads stage a review and publish only after confirmation. Do NOT DELETE the request yourself. If you can't read the drawing, POST /api/projects/${req.project}/revision-requests/${req.id}/fail with { error }.`;
|
|
64143
|
-
const post = `After Filter Save, GET /api/projects/${req.project}/revision-requests/${req.id}/steel-manifest and GET the current contract with its ETag. Preserve every server-owned id. Account for every manifest page, layer, human-excluded line weight and colour, candidate line, reference/detail/connection marker, and every new or changed joint in a closed steel-read/v4 attestation. The manifest response carries derived fields you cannot compute yourself and must copy exactly: pageShards (one candidateShardHash per page \u2014 give every page exactly one { pageId, kind: "whole", candidateShardHash, note } pageReview, and never a second one), layerLineCounts (each layers[] row states its own { model, evidence } lineCounts, verified against the server's ledger), dismissibleFacetValues (every { dim, value } the human excluded \u2014 each thickness or color one needs exactly one facetExclusions[] row; layer ones are covered by layers[] instead),
|
|
64143
|
+
const post = `After Filter Save, GET /api/projects/${req.project}/revision-requests/${req.id}/steel-manifest and GET the current contract with its ETag. Preserve every server-owned id. Account for every manifest page, layer, human-excluded line weight and colour, candidate line, reference/detail/connection marker, and every new or changed joint in a closed steel-read/v4 attestation. The manifest response carries derived fields you cannot compute yourself and must copy exactly: pageShards (one candidateShardHash per page \u2014 give every page exactly one { pageId, kind: "whole", candidateShardHash, note } pageReview, and never a second one), layerLineCounts (each layers[] row states its own { model, evidence } lineCounts, verified against the server's ledger), dismissibleFacetValues (every { dim, value } the human excluded \u2014 each thickness or color one needs exactly one facetExclusions[] row; layer ones are covered by layers[] instead), facetLineCounts (copy the matching { model, evidence } into that row's lineCounts; a dismissible value with no row there carries zero lines, so state zeros rather than omitting it), and referenceCandidates (every element owing a references[] row \u2014 decided by its text, so detail/connection markers count too, never a candidate-kind filter). The response also carries exclusionBasis: when it is not "saved-filter" the human has not saved the Drawing Filter yet, dismissibleFacetValues and proofBudget are absent entirely, and there is nothing to build a proof against \u2014 wait for the Save. If the response's proofBudget says strained, one explicit row per line would not fit: this set only works if observations, the wholesale shorthand and grouping between them save enough bytes, so model what is genuinely a member, dismiss wholesale what the Filter authorises, group the rest by shared reason, and warn the human up front if none of that will be enough; impossible is a sound refusal but not a complete detector, so a set can pass it and still admit no proof that fits. If the response's proofBudget says impossible, stop: no proof over this Drawing Filter can fit the 8 MB cap however it is written, and the human has to switch more line weights off. Where many lines share one disposition and one reason, put them in a single lineDispositionGroups[] entry \u2014 { disposition, reason, elementIds: [...] }, plus one shared duplicateOf when the disposition is duplicate \u2014 instead of repeating the same sentence once per line. A line that needs a written disposition must appear EXACTLY ONCE, named literally, in either lineDispositions[] or one group, never in both (a line an observation accounts for, or one the rules below dismiss wholesale, belongs in neither): elementIds holds real ids and nothing else, there is no range, wildcard or "everything else", and a group's reason must be true of every line it names rather than of a typical one. Use a lineDispositions[] row when a reason is genuinely specific to one line, and keep THOSE concise because they are paid per line; a grouped reason is written once, so make it a full sentence worth reading. Prefer a modeling observation over any written disposition wherever a line is genuinely a member. A line the Filter does not select needs NO per-line disposition only when EVERY dimension it fails independently authorises that: the value is in dismissibleFacetValues AND you attested it annotation, existing or other (in layers[] for a layer, in facetExclusions[] for a line weight or colour). If even one failing dimension does not, that line needs its own row whatever the others say. POST /api/projects/${req.project}/revision-read/audit with { requestId: "${req.id}", contract, attestation }; a blocked report is a mandatory checklist, so fix every blocker and repeat until status is read-complete. Then POST the exact same contract and attestation to /api/projects/${req.project}/revision-read with { contract, attestation, message: "${messageHint}", requestId: "${req.id}" } and If-Match: <that exact ETag>. A later read returns 202 for human review; when replacing an existing staged generation, also send If-Match-Stage with its exact stageId. Do NOT DELETE the request yourself. If you can't read the set, POST /api/projects/${req.project}/revision-requests/${req.id}/fail with { error }.`;
|
|
64144
64144
|
const manifestPhase = `FIRST POST /api/projects/${req.project}/revision-requests/${req.id}/steel-manifest with {}; only it inventories pages and mints Filter ids. On sheet-identification-required, inspect listed pages, identify each sheet, then retry with { bindings: [{ pageId, sheet, title?, evidenceKind }] }; never guess from other pages or build Filter geometry. On steel-manifest-preparation-busy, wait at least retryAfterMs; retry this step. On steel-manifest-preparation-blocked, STOP and relay recovery; do not retry until an operator repairs/removes the stale claim. On steel-manifest-extraction-timeout, STOP; do not retry the same drawing set. Relay error and recovery, then phase, elapsed/limit, counts and diagnostic id; null page counts are unknown. Never relay commands, stderr, source, filenames, or paths. A smaller set is required. On steel-manifest-over-budget, STOP and relay recovery. Page scope: remove or split the named dense sheet. Total scope: use smaller revisions. Bytes scope is drawing-data weight, not element count: use the byte shares, heaviest first, to decide what to move or split; if one sheet alone exceeds the limit, putting it in its own revision cannot help. Null scope means extraction overflowed before measurement, so there is no breakdown and the set must be materially smaller. On steel-manifest-extraction-failed, STOP and relay the diagnostic; an identical retry will fail. Never rename Filter geometry or mint its element ids yourself.`;
|
|
64145
64145
|
if ((req.appTemplateId || req.appId) === "vectorize") {
|
|
64146
64146
|
if (isInitialRead) {
|
|
@@ -64244,7 +64244,7 @@ function desktopHandoffsForRequest(r, base, prompt, marker) {
|
|
|
64244
64244
|
if (r.type === "guide") return null;
|
|
64245
64245
|
if (r.type === "revision-read" && (r.status !== "pending" || r.settledVersion !== void 0)) return null;
|
|
64246
64246
|
const run2 = r.run;
|
|
64247
|
-
if (r.type === "revision-read" && r.prepassReady === true && r.
|
|
64247
|
+
if (r.type === "revision-read" && r.prepassReady === true && r.filterCheckpointCurrent !== true) return null;
|
|
64248
64248
|
if (!prompt.trim() || !marker.trim() || !run2 || run2.processContained !== true || run2.recoveryReady !== true) return null;
|
|
64249
64249
|
if (!run2.sessionId || !run2.leaseId || !DESKTOP_RESUMABLE_RUN_STATES.has(run2.state)) return null;
|
|
64250
64250
|
if (run2.runtime === "codex" && run2.handoffReady !== true) return null;
|
|
@@ -64277,7 +64277,7 @@ function resumeCommandForRequest(r) {
|
|
|
64277
64277
|
if (r.type === "revision-read" && (r.status !== "pending" || r.settledVersion !== void 0)) return null;
|
|
64278
64278
|
const run2 = r.run;
|
|
64279
64279
|
if (!run2 || run2.processContained !== true || !run2.sessionId) return null;
|
|
64280
|
-
if (r.type === "revision-read" && r.prepassReady === true && r.
|
|
64280
|
+
if (r.type === "revision-read" && r.prepassReady === true && r.filterCheckpointCurrent !== true) return null;
|
|
64281
64281
|
if (desktopClaimForLease(run2.leaseId)) return null;
|
|
64282
64282
|
if (r.type === "revision-read") {
|
|
64283
64283
|
const lease = getLease(run2.leaseId);
|
|
@@ -64404,7 +64404,12 @@ function withPrompt(r, base = selfOrigin()) {
|
|
|
64404
64404
|
};
|
|
64405
64405
|
}
|
|
64406
64406
|
}
|
|
64407
|
-
var NO_ENRICHMENTS = {
|
|
64407
|
+
var NO_ENRICHMENTS = {
|
|
64408
|
+
appTemplateId: void 0,
|
|
64409
|
+
nativeSteelReady: void 0,
|
|
64410
|
+
projectName: void 0,
|
|
64411
|
+
filterCheckpointCurrent: void 0
|
|
64412
|
+
};
|
|
64408
64413
|
function enrichedView(r, enrich, base = selfOrigin()) {
|
|
64409
64414
|
let extra = {};
|
|
64410
64415
|
try {
|
|
@@ -64606,7 +64611,7 @@ function strictLaunchBodyValidator() {
|
|
|
64606
64611
|
function handoffInstructionFor(request) {
|
|
64607
64612
|
const original = `${request.marker}
|
|
64608
64613
|
${request.prompt}`;
|
|
64609
|
-
if (request.type !== "revision-read" || request.
|
|
64614
|
+
if (request.type !== "revision-read" || request.filterCheckpointCurrent !== true || !request.project) return original;
|
|
64610
64615
|
const progressPath = steelProgressPath(request.project, request.id);
|
|
64611
64616
|
return [
|
|
64612
64617
|
original,
|
|
@@ -71551,7 +71556,12 @@ function evaluateSteelRead(context) {
|
|
|
71551
71556
|
if (!row || row.status === "resolved" && (!row.targetPageId || !pagesById.has(row.targetPageId))) badRefs.push(ref.id);
|
|
71552
71557
|
}
|
|
71553
71558
|
for (const id of refById.keys()) if (!refIds.has(id)) badRefs.push(id);
|
|
71554
|
-
add(
|
|
71559
|
+
add(
|
|
71560
|
+
"reference-graph",
|
|
71561
|
+
badRefs.length ? "block" : proof3.references.some((row) => row.status === "missing") ? "warning" : "pass",
|
|
71562
|
+
badRefs.length ? "reference candidates are unaccounted or target foreign pages \u2014 answer exactly the manifest GET's referenceCandidates list (decided by each element's text, so it covers detail/connection markers too, not only reference-marker candidates), and give every resolved row a targetPageId naming a page of THIS manifest" : `${refs.length} reference obligation(s) reach a fixed accounting point`,
|
|
71563
|
+
badRefs
|
|
71564
|
+
);
|
|
71555
71565
|
const markerCandidates = (inventory ?? storedManifest.manifest.pages.flatMap((page) => page.candidates ?? [])).filter((candidate2) => candidate2.kind === "detail-marker" || candidate2.kind === "connection-marker");
|
|
71556
71566
|
const markerIds = new Set(markerCandidates.map((marker) => marker.id));
|
|
71557
71567
|
const dispositionByCandidate = new Map(proof3.candidateDispositions.map((row) => [row.elementId, row]));
|
|
@@ -72265,6 +72275,46 @@ function appContractState(appId, app, resolve21 = (id, op, readAppFn) => resolve
|
|
|
72265
72275
|
function readAcceptedForRequest(appId, projectId, operation) {
|
|
72266
72276
|
return readAcceptedContract({ appId, projectId, operation });
|
|
72267
72277
|
}
|
|
72278
|
+
var acceptedContractIdentityCache = /* @__PURE__ */ new Map();
|
|
72279
|
+
function acceptedContractIdentity(appId, projectId) {
|
|
72280
|
+
const path = contractPath(appId, projectId);
|
|
72281
|
+
const key2 = JSON.stringify([appId, projectId]);
|
|
72282
|
+
const signature = () => {
|
|
72283
|
+
try {
|
|
72284
|
+
const stat4 = (0, import_node_fs41.statSync)(path, { bigint: true });
|
|
72285
|
+
return [stat4.dev, stat4.ino, stat4.size, stat4.mtimeNs, stat4.ctimeNs].join(":");
|
|
72286
|
+
} catch (error) {
|
|
72287
|
+
if (error?.code === "ENOENT") return "absent";
|
|
72288
|
+
throw error;
|
|
72289
|
+
}
|
|
72290
|
+
};
|
|
72291
|
+
assertServable(projectId);
|
|
72292
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
72293
|
+
const before = signature();
|
|
72294
|
+
const cached = acceptedContractIdentityCache.get(key2);
|
|
72295
|
+
if (cached?.signature === before) {
|
|
72296
|
+
if (cached.contractEtag !== null && cached.contractType) {
|
|
72297
|
+
assertAcceptableType(
|
|
72298
|
+
cached.contractType,
|
|
72299
|
+
ctxFor({ appId, projectId, operation: "read" }, cached.contractType)
|
|
72300
|
+
);
|
|
72301
|
+
}
|
|
72302
|
+
return { contractType: cached.contractType, contractEtag: cached.contractEtag };
|
|
72303
|
+
}
|
|
72304
|
+
const contract = readAcceptedForRequest(appId, projectId, "read");
|
|
72305
|
+
const identity = {
|
|
72306
|
+
contractType: contract == null ? void 0 : declaredTypeOf(contract),
|
|
72307
|
+
contractEtag: etagOf(contract)
|
|
72308
|
+
};
|
|
72309
|
+
const after = signature();
|
|
72310
|
+
if (before === after) {
|
|
72311
|
+
if (contract == null && before !== "absent") return identity;
|
|
72312
|
+
acceptedContractIdentityCache.set(key2, { signature: after, ...identity });
|
|
72313
|
+
return identity;
|
|
72314
|
+
}
|
|
72315
|
+
}
|
|
72316
|
+
return { contractType: void 0, contractEtag: null };
|
|
72317
|
+
}
|
|
72268
72318
|
function etagOf(doc) {
|
|
72269
72319
|
return doc == null ? null : `"${contractHash(doc)}"`;
|
|
72270
72320
|
}
|
|
@@ -75887,6 +75937,22 @@ function steelExclusionPreflight(ledger, filter) {
|
|
|
75887
75937
|
}
|
|
75888
75938
|
|
|
75889
75939
|
// revision-request-view.ts
|
|
75940
|
+
function filterCheckpointMatchesCurrent(request, currentEtag) {
|
|
75941
|
+
return request.type === "revision-read" && request.settledVersion === void 0 && request.prepassReady === true && request.filterSaved === true && typeof request.filterSavedEtag === "string" && request.filterSavedEtag.length > 0 && request.filterSavedEtag === currentEtag;
|
|
75942
|
+
}
|
|
75943
|
+
function filterCheckpointIsCurrent(request, currentEtag) {
|
|
75944
|
+
return request.status === "pending" && filterCheckpointMatchesCurrent(request, currentEtag);
|
|
75945
|
+
}
|
|
75946
|
+
function acceptedContractFacts(appId, projectId) {
|
|
75947
|
+
try {
|
|
75948
|
+
return acceptedContractIdentity(appId, projectId);
|
|
75949
|
+
} catch {
|
|
75950
|
+
return { contractType: void 0, contractEtag: null };
|
|
75951
|
+
}
|
|
75952
|
+
}
|
|
75953
|
+
function acceptedContractEtag(appId, projectId) {
|
|
75954
|
+
return acceptedContractFacts(appId, projectId).contractEtag;
|
|
75955
|
+
}
|
|
75890
75956
|
function revisionRequestStageId(request) {
|
|
75891
75957
|
if (request.type !== "revision-read" || request.status !== "staged" || !request.project) return void 0;
|
|
75892
75958
|
const stagingKey = getProjectStagingId(request.project);
|
|
@@ -75897,18 +75963,23 @@ function revisionRequestStageId(request) {
|
|
|
75897
75963
|
}
|
|
75898
75964
|
function revisionRequestViewFields(request, memo = {}) {
|
|
75899
75965
|
const discard = request.type === "revision-read" && request.status === "staged" ? revisionDiscardPolicyFor(request) : void 0;
|
|
75966
|
+
const contractFacts = request.type === "revision-read" && request.appId && request.project ? (memo.contractFacts ?? acceptedContractFacts)(request.appId, request.project) : void 0;
|
|
75900
75967
|
return {
|
|
75901
75968
|
appTemplateId: request.appId ? (memo.templateId ?? resolveTemplateId)(request.appId) : void 0,
|
|
75902
75969
|
nativeSteelReady: request.type === "revision-read" && request.appId && request.project ? (() => {
|
|
75903
75970
|
const project = getProject(request.project);
|
|
75904
|
-
return !!project && sameAppLineage(request.appId, project.app) &&
|
|
75971
|
+
return !!project && sameAppLineage(request.appId, project.app) && contractFacts?.contractType === STEEL_V2;
|
|
75905
75972
|
})() : void 0,
|
|
75906
75973
|
extractorAvailable: request.type === "revision-read" ? steelFilterExtractorAvailable() : void 0,
|
|
75907
75974
|
headVersion: request.type === "revision-read" && request.project ? (memo.headVersion ?? ((projectId) => listVersions(projectId)[0]?.n ?? 0))(request.project) : void 0,
|
|
75908
75975
|
stageId: revisionRequestStageId(request),
|
|
75909
75976
|
canDiscardRevision: discard?.canClear,
|
|
75910
75977
|
discardWhy: discard?.clearWhy,
|
|
75911
|
-
discardState: discard?.clearState
|
|
75978
|
+
discardState: discard?.clearState,
|
|
75979
|
+
filterCheckpointCurrent: request.type === "revision-read" && request.appId && request.project ? filterCheckpointIsCurrent(
|
|
75980
|
+
request,
|
|
75981
|
+
contractFacts?.contractEtag ?? null
|
|
75982
|
+
) : void 0
|
|
75912
75983
|
};
|
|
75913
75984
|
}
|
|
75914
75985
|
function enrichedRevisionRequestView(request, extra, memo = {}) {
|
|
@@ -76130,6 +76201,9 @@ function loadAuthoritativeSteelAuditState(project, requestId, attestation, allow
|
|
|
76130
76201
|
})) throw new SteelAuditStateError("steel-source-manifest-changed", "the verified project source bytes no longer match the manifest");
|
|
76131
76202
|
const parsedAttestation = parseSteelReadAttestation(attestation);
|
|
76132
76203
|
const current = readAcceptedForRequest(project.app, project.id, "read");
|
|
76204
|
+
if (!filterCheckpointMatchesCurrent(request, etagOf(current))) {
|
|
76205
|
+
throw new SteelAuditStateError("steel-filter-save-missing", "the request has no current exact Filter Save checkpoint");
|
|
76206
|
+
}
|
|
76133
76207
|
return {
|
|
76134
76208
|
request,
|
|
76135
76209
|
storedManifest,
|
|
@@ -76941,13 +77015,16 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
76941
77015
|
const effectiveFilter = savedFilterCurrent ? acceptedFilter : stored2.manifest.filter;
|
|
76942
77016
|
let layerLineCounts;
|
|
76943
77017
|
let preflight;
|
|
77018
|
+
let referenceCandidates;
|
|
76944
77019
|
try {
|
|
77020
|
+
const candidateInventory = stored2.manifest.candidatesRepr === "v2-compact" ? compactManifestInventory(stored2.manifest.pages) : null;
|
|
76945
77021
|
const ledger = sourceLineInventory({
|
|
76946
77022
|
pages: stored2.manifest.pages,
|
|
76947
77023
|
filter: effectiveFilter,
|
|
76948
|
-
inventory:
|
|
77024
|
+
inventory: candidateInventory
|
|
76949
77025
|
});
|
|
76950
77026
|
layerLineCounts = steelReadLayerLineCounts(ledger);
|
|
77027
|
+
referenceCandidates = referenceInventory(effectiveFilter, stored2, candidateInventory).map((row) => ({ elementId: row.id, text: row.text }));
|
|
76951
77028
|
preflight = steelExclusionPreflight(ledger, effectiveFilter);
|
|
76952
77029
|
} catch (error) {
|
|
76953
77030
|
if (!(error instanceof SteelLedgerUnboundError)) throw error;
|
|
@@ -76966,6 +77043,7 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
76966
77043
|
exclusionBasis,
|
|
76967
77044
|
facetLineCounts: preflight.facetLineCounts,
|
|
76968
77045
|
facetUncensused: preflight.facetUncensused,
|
|
77046
|
+
referenceCandidates,
|
|
76969
77047
|
...savedFilterCurrent ? {
|
|
76970
77048
|
dismissibleFacetValues: preflight.dismissed,
|
|
76971
77049
|
proofBudget: preflight.budget,
|
|
@@ -77114,7 +77192,8 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
77114
77192
|
async (req, reply) => withLifecycleLock("project", req.params.id, async () => {
|
|
77115
77193
|
const project = getProject(req.params.id);
|
|
77116
77194
|
const request = getRequest(req.params.reqId);
|
|
77117
|
-
|
|
77195
|
+
const currentEtag = project ? acceptedContractEtag(project.app, project.id) : null;
|
|
77196
|
+
if (!project || !request || request.type !== "revision-read" || request.project !== project.id || !filterCheckpointIsCurrent(request, currentEtag)) {
|
|
77118
77197
|
return reply.status(404).send({ ok: false, error: "unknown active drawing read" });
|
|
77119
77198
|
}
|
|
77120
77199
|
let progress;
|
|
@@ -77264,7 +77343,7 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
77264
77343
|
}
|
|
77265
77344
|
try {
|
|
77266
77345
|
const saved = recordSteelFilterSave({ requestId: request.id, filter, etag, expectedManifestHash: manifest.manifestHash, exclusionSignOff: signOff });
|
|
77267
|
-
const updated2 =
|
|
77346
|
+
const updated2 = patchRequestDurable(request.id, { filterSaved: true, filterSavedEtag: etag, steelSavedFilterHash: saved.savedFilterHash });
|
|
77268
77347
|
if (!updated2) return reply.status(409).send({ ok: false, error: "the revision request changed while recording the Filter Save" });
|
|
77269
77348
|
broadcast({ type: "request-added", request: requestView(updated2) });
|
|
77270
77349
|
return { ok: true, request: requestView(updated2) };
|
|
@@ -77292,7 +77371,7 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
77292
77371
|
error: "this request is not governed by the Steel Model completion policy, so an exclusion approval cannot be recorded against it"
|
|
77293
77372
|
});
|
|
77294
77373
|
}
|
|
77295
|
-
const updated =
|
|
77374
|
+
const updated = patchRequestDurable(request.id, { filterSaved: true, filterSavedEtag: etag });
|
|
77296
77375
|
if (!updated) return reply.status(409).send({ ok: false, error: "the revision request changed while recording the Filter Save" });
|
|
77297
77376
|
broadcast({ type: "request-added", request: requestView(updated) });
|
|
77298
77377
|
return { ok: true, request: requestView(updated) };
|
|
@@ -77481,7 +77560,7 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
77481
77560
|
}
|
|
77482
77561
|
const appTemplateId = resolveTemplateId(project.app);
|
|
77483
77562
|
const candidateType = declaredTypeOf(req.body.contract);
|
|
77484
|
-
if (appTemplateId === "steel-model" && request
|
|
77563
|
+
if (appTemplateId === "steel-model" && !filterCheckpointMatchesCurrent(request, etagOf(currentForEvidence))) {
|
|
77485
77564
|
return reply.status(409).send({
|
|
77486
77565
|
ok: false,
|
|
77487
77566
|
error: "complete this request's Steel Filter pre-read, then review and Save the Filter before committing the read"
|
|
@@ -87214,7 +87293,7 @@ function registerContractRequestRoute(app, deps) {
|
|
|
87214
87293
|
{ bodyLimit: 25 * 1024 * 1024 },
|
|
87215
87294
|
async (req, reply) => {
|
|
87216
87295
|
const { appId, project, instruction, intent, target, snapshots } = req.body ?? {};
|
|
87217
|
-
if (!
|
|
87296
|
+
if (!isSafeAppId(appId)) {
|
|
87218
87297
|
return reply.status(400).send({ ok: false, error: "invalid appId" });
|
|
87219
87298
|
}
|
|
87220
87299
|
if (typeof instruction !== "string" || !instruction) {
|
|
@@ -87248,6 +87327,112 @@ function registerContractRequestRoute(app, deps) {
|
|
|
87248
87327
|
);
|
|
87249
87328
|
}
|
|
87250
87329
|
|
|
87330
|
+
// contract-put-route.ts
|
|
87331
|
+
function projectAppMismatch(appId, project) {
|
|
87332
|
+
const found = getProject(project);
|
|
87333
|
+
if (!found) return `unknown project: ${project}`;
|
|
87334
|
+
if (found.app !== appId) return `project "${project}" belongs to app "${found.app}", not "${appId}"`;
|
|
87335
|
+
return null;
|
|
87336
|
+
}
|
|
87337
|
+
function registerContractPutRoute(app, deps) {
|
|
87338
|
+
app.put(
|
|
87339
|
+
"/api/contract/:appId",
|
|
87340
|
+
{ bodyLimit: STEEL_CONTRACT_BODY_LIMIT_BYTES },
|
|
87341
|
+
async (req, reply) => {
|
|
87342
|
+
const project = req.query.project || void 0;
|
|
87343
|
+
if (project) {
|
|
87344
|
+
const bad = projectAppMismatch(req.params.appId, project);
|
|
87345
|
+
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
87346
|
+
}
|
|
87347
|
+
const prepassRequestId = typeof req.headers["x-floless-prepass-request"] === "string" ? req.headers["x-floless-prepass-request"] : "";
|
|
87348
|
+
const filterRequestId = typeof req.headers["x-floless-filter-request"] === "string" ? req.headers["x-floless-filter-request"] : "";
|
|
87349
|
+
const prepassRequest = prepassRequestId ? getRequest(prepassRequestId) : null;
|
|
87350
|
+
const filterRequest = filterRequestId ? getRequest(filterRequestId) : null;
|
|
87351
|
+
const contractBody = prepassRequest || filterRequest ? withDeterministicFilterIds(req.body) : req.body;
|
|
87352
|
+
if (prepassRequestId && (!project || !prepassRequest || prepassRequest.type !== "revision-read" || prepassRequest.project !== project || prepassRequest.status !== "pending" || prepassRequest.settledVersion !== void 0 || prepassRequest.prepassBaseEtag !== null || !isExactFilterCheckpointShell(contractBody))) {
|
|
87353
|
+
return reply.status(400).send({ ok: false, error: "X-FloLess-Prepass-Request must name this pending initial read and a populated Steel Filter" });
|
|
87354
|
+
}
|
|
87355
|
+
if (filterRequestId && (!project || !filterRequest || filterRequest.type !== "revision-read" || filterRequest.project !== project || filterRequest.status !== "pending" || filterRequest.settledVersion !== void 0)) {
|
|
87356
|
+
return reply.status(400).send({ ok: false, error: "X-FloLess-Filter-Request must name this pending drawing read" });
|
|
87357
|
+
}
|
|
87358
|
+
const boundRequest = prepassRequest ?? filterRequest;
|
|
87359
|
+
if (boundRequest) {
|
|
87360
|
+
const checked = validateSteelFilterSourceCoverage(contractBody, (boundRequest.sourceRefs ?? []).map((file) => file.sha256.toLowerCase()));
|
|
87361
|
+
if (!checked.ok) return reply.status(409).send({ ok: false, code: "filter-source-mismatch", error: "This filter no longer matches the attached drawing set. Reload the Drawing Filter and review it again." });
|
|
87362
|
+
}
|
|
87363
|
+
if (filterRequest && project) {
|
|
87364
|
+
const current = readAcceptedForRequest(req.params.appId, project, "read");
|
|
87365
|
+
if (current == null || declaredTypeOf(current) !== STEEL_V2 || declaredTypeOf(contractBody) !== STEEL_V2) {
|
|
87366
|
+
return reply.status(409).send({ ok: false, code: "filter-checkpoint-missing", error: "Reload the Drawing Filter from this project and review it again." });
|
|
87367
|
+
}
|
|
87368
|
+
const withoutFilter = (value) => {
|
|
87369
|
+
const copy = structuredClone(value);
|
|
87370
|
+
delete copy.filter;
|
|
87371
|
+
return copy;
|
|
87372
|
+
};
|
|
87373
|
+
if (contractHash(withoutFilter(current)) !== contractHash(withoutFilter(contractBody))) {
|
|
87374
|
+
return reply.status(409).send({ ok: false, code: "filter-write-out-of-scope", error: "The model changed while the Drawing Filter was open. Reload it and review the filter again." });
|
|
87375
|
+
}
|
|
87376
|
+
}
|
|
87377
|
+
const ifMatch = typeof req.headers["if-match"] === "string" ? req.headers["if-match"] : void 0;
|
|
87378
|
+
const ifNoneMatch = typeof req.headers["if-none-match"] === "string" ? req.headers["if-none-match"] : void 0;
|
|
87379
|
+
const persist2 = async () => {
|
|
87380
|
+
const livePrepass = prepassRequestId ? getRequest(prepassRequestId) : null;
|
|
87381
|
+
const liveFilter = filterRequestId ? getRequest(filterRequestId) : null;
|
|
87382
|
+
if (prepassRequestId && (!project || !livePrepass || livePrepass.type !== "revision-read" || livePrepass.project !== project || livePrepass.status !== "pending" || livePrepass.settledVersion !== void 0 || livePrepass.prepassBaseEtag !== null || !isExactFilterCheckpointShell(contractBody))) {
|
|
87383
|
+
return reply.status(400).send({ ok: false, error: "X-FloLess-Prepass-Request must name this pending initial read and a populated Steel Filter" });
|
|
87384
|
+
}
|
|
87385
|
+
if (filterRequestId && (!project || !liveFilter || liveFilter.type !== "revision-read" || liveFilter.project !== project || liveFilter.status !== "pending" || liveFilter.settledVersion !== void 0)) {
|
|
87386
|
+
return reply.status(400).send({ ok: false, error: "X-FloLess-Filter-Request must name this pending drawing read" });
|
|
87387
|
+
}
|
|
87388
|
+
const liveBound = livePrepass ?? liveFilter;
|
|
87389
|
+
if (liveBound) {
|
|
87390
|
+
const checked = validateSteelFilterSourceCoverage(contractBody, (liveBound.sourceRefs ?? []).map((file) => file.sha256.toLowerCase()));
|
|
87391
|
+
if (!checked.ok) return reply.status(409).send({ ok: false, code: "filter-source-mismatch", error: "This filter no longer matches every file in the attached drawing set. Reload the Drawing Filter and review it again." });
|
|
87392
|
+
}
|
|
87393
|
+
const result = await writeContractChecked(req.params.appId, contractBody, project, { origin: "client", ifMatch, ifNoneMatch });
|
|
87394
|
+
reply.header("ETag", result.etag);
|
|
87395
|
+
if (project) clearApproval(project);
|
|
87396
|
+
if (livePrepass) {
|
|
87397
|
+
const updated = patchRequest(livePrepass.id, { prepassReady: true, prepassEtag: result.etag, filterSaved: false, filterSavedEtag: void 0 });
|
|
87398
|
+
if (updated) deps.broadcast({ type: "request-added", request: updated });
|
|
87399
|
+
}
|
|
87400
|
+
if (liveFilter) {
|
|
87401
|
+
const updated = patchRequestDurable(liveFilter.id, {
|
|
87402
|
+
filterSaved: false,
|
|
87403
|
+
filterSavedEtag: void 0,
|
|
87404
|
+
steelSavedFilterHash: void 0
|
|
87405
|
+
});
|
|
87406
|
+
if (!updated) throw new Error("the revision request changed while invalidating its previous Filter Save");
|
|
87407
|
+
deps.broadcast({ type: "request-added", request: deps.requestView(updated) });
|
|
87408
|
+
}
|
|
87409
|
+
deps.broadcast(contractChangedEvent(req.params.appId, project, result.etag, result.storeRevision, req.headers["x-floless-mutation-id"]));
|
|
87410
|
+
return {
|
|
87411
|
+
ok: true,
|
|
87412
|
+
etag: result.etag,
|
|
87413
|
+
storeRevision: result.storeRevision,
|
|
87414
|
+
...result.invalidatedWorkPointDecisions > 0 ? { contract: result.contract, invalidatedWorkPointDecisions: result.invalidatedWorkPointDecisions } : {},
|
|
87415
|
+
...result.revalidation ? { revalidation: result.revalidation } : {}
|
|
87416
|
+
};
|
|
87417
|
+
};
|
|
87418
|
+
try {
|
|
87419
|
+
return await (project && (prepassRequestId || filterRequestId) ? withLifecycleLock("project", project, persist2) : persist2());
|
|
87420
|
+
} catch (error) {
|
|
87421
|
+
if (error instanceof PreconditionRequiredError) {
|
|
87422
|
+
return reply.status(428).send({ ok: false, error: error.message, code: error.code });
|
|
87423
|
+
}
|
|
87424
|
+
if (error instanceof PreconditionFailedError) {
|
|
87425
|
+
return reply.status(412).send({ ok: false, error: error.message, code: error.code });
|
|
87426
|
+
}
|
|
87427
|
+
if (error instanceof ContractError) {
|
|
87428
|
+
return reply.status(400).send({ ok: false, error: error.message, ...error.code ? { code: error.code } : {} });
|
|
87429
|
+
}
|
|
87430
|
+
throw error;
|
|
87431
|
+
}
|
|
87432
|
+
}
|
|
87433
|
+
);
|
|
87434
|
+
}
|
|
87435
|
+
|
|
87251
87436
|
// instructor-guide-route.ts
|
|
87252
87437
|
function registerInstructorGuideRoute(app, deps) {
|
|
87253
87438
|
app.post(
|
|
@@ -95297,7 +95482,7 @@ function registerTerminalRunRoutes(app, deps) {
|
|
|
95297
95482
|
if (req.run?.state === "needs-you") {
|
|
95298
95483
|
return reply.status(409).send({
|
|
95299
95484
|
ok: false,
|
|
95300
|
-
error: req.type === "revision-read" && req.
|
|
95485
|
+
error: req.type === "revision-read" && req.filterCheckpointCurrent !== true ? "Review and Save this request's Steel Filter before continuing its original terminal session." : "This request is parked in its original terminal session. Continue that session instead of starting another run.",
|
|
95301
95486
|
code: "handoff-pending"
|
|
95302
95487
|
});
|
|
95303
95488
|
}
|
|
@@ -95308,7 +95493,7 @@ function registerTerminalRunRoutes(app, deps) {
|
|
|
95308
95493
|
code: "handoff-pending"
|
|
95309
95494
|
});
|
|
95310
95495
|
}
|
|
95311
|
-
if (req.appId !== void 0 && !
|
|
95496
|
+
if (req.appId !== void 0 && !isSafeAppId2(req.appId)) {
|
|
95312
95497
|
return reply.status(400).send({ ok: false, error: "This request names a workflow floless can\u2019t identify.", code: "bad-app-id" });
|
|
95313
95498
|
}
|
|
95314
95499
|
const asked = request.body?.runtime;
|
|
@@ -98935,7 +99120,7 @@ async function startServer() {
|
|
|
98935
99120
|
const root6 = templateIdResolver();
|
|
98936
99121
|
const nameMemo = /* @__PURE__ */ new Map();
|
|
98937
99122
|
const headMemo = /* @__PURE__ */ new Map();
|
|
98938
|
-
const
|
|
99123
|
+
const contractFactsMemo = /* @__PURE__ */ new Map();
|
|
98939
99124
|
const headVersion = (project) => {
|
|
98940
99125
|
const cached = headMemo.get(project);
|
|
98941
99126
|
if (cached !== void 0) return cached;
|
|
@@ -98949,7 +99134,11 @@ async function startServer() {
|
|
|
98949
99134
|
}), {
|
|
98950
99135
|
templateId: root6,
|
|
98951
99136
|
headVersion,
|
|
98952
|
-
|
|
99137
|
+
contractFacts: (appId, projectId) => {
|
|
99138
|
+
const key2 = JSON.stringify([appId, projectId]);
|
|
99139
|
+
if (!contractFactsMemo.has(key2)) contractFactsMemo.set(key2, acceptedContractFacts(appId, projectId));
|
|
99140
|
+
return contractFactsMemo.get(key2);
|
|
99141
|
+
}
|
|
98953
99142
|
}));
|
|
98954
99143
|
};
|
|
98955
99144
|
app.get("/api/projects", async () => ({ ok: true, projects: projectViews(listProjects()) }));
|
|
@@ -99505,12 +99694,6 @@ async function startServer() {
|
|
|
99505
99694
|
registerSteelPrepassRoute(app, { getProject, clearApproval, broadcast });
|
|
99506
99695
|
registerKnowledgeRoutes(app);
|
|
99507
99696
|
registerKbPinRoutes(app, { broadcast });
|
|
99508
|
-
function projectAppMismatch(appId, project) {
|
|
99509
|
-
const p = getProject(project);
|
|
99510
|
-
if (!p) return `unknown project: ${project}`;
|
|
99511
|
-
if (p.app !== appId) return `project "${project}" belongs to app "${p.app}", not "${appId}"`;
|
|
99512
|
-
return null;
|
|
99513
|
-
}
|
|
99514
99697
|
app.get(
|
|
99515
99698
|
"/api/projects/:id/contract-lifecycle",
|
|
99516
99699
|
async (req, reply) => {
|
|
@@ -99624,97 +99807,7 @@ async function startServer() {
|
|
|
99624
99807
|
return reply.type("image/svg+xml").send((0, import_node_fs80.readFileSync)(file, "utf8"));
|
|
99625
99808
|
}
|
|
99626
99809
|
);
|
|
99627
|
-
app
|
|
99628
|
-
"/api/contract/:appId",
|
|
99629
|
-
{ bodyLimit: STEEL_CONTRACT_BODY_LIMIT_BYTES },
|
|
99630
|
-
// the whole steel contract, rasters included — see steel-contract-body-limit.ts
|
|
99631
|
-
async (req, reply) => {
|
|
99632
|
-
const project = req.query.project || void 0;
|
|
99633
|
-
if (project) {
|
|
99634
|
-
const bad = projectAppMismatch(req.params.appId, project);
|
|
99635
|
-
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
99636
|
-
}
|
|
99637
|
-
const prepassRequestId = typeof req.headers["x-floless-prepass-request"] === "string" ? req.headers["x-floless-prepass-request"] : "";
|
|
99638
|
-
const filterRequestId = typeof req.headers["x-floless-filter-request"] === "string" ? req.headers["x-floless-filter-request"] : "";
|
|
99639
|
-
const prepassRequest = prepassRequestId ? getRequest(prepassRequestId) : null;
|
|
99640
|
-
const filterRequest = filterRequestId ? getRequest(filterRequestId) : null;
|
|
99641
|
-
let contractBody = prepassRequest || filterRequest ? withDeterministicFilterIds(req.body) : req.body;
|
|
99642
|
-
if (prepassRequestId && (!project || !prepassRequest || prepassRequest.type !== "revision-read" || prepassRequest.project !== project || prepassRequest.status !== "pending" || prepassRequest.settledVersion !== void 0 || prepassRequest.prepassBaseEtag !== null || !isExactFilterCheckpointShell(contractBody))) {
|
|
99643
|
-
return reply.status(400).send({ ok: false, error: "X-FloLess-Prepass-Request must name this pending initial read and a populated Steel Filter" });
|
|
99644
|
-
}
|
|
99645
|
-
if (filterRequestId && (!project || !filterRequest || filterRequest.type !== "revision-read" || filterRequest.project !== project || filterRequest.status !== "pending" || filterRequest.settledVersion !== void 0)) {
|
|
99646
|
-
return reply.status(400).send({ ok: false, error: "X-FloLess-Filter-Request must name this pending drawing read" });
|
|
99647
|
-
}
|
|
99648
|
-
const boundRequest = prepassRequest ?? filterRequest;
|
|
99649
|
-
if (boundRequest) {
|
|
99650
|
-
const checked = validateSteelFilterSourceCoverage(contractBody, (boundRequest.sourceRefs ?? []).map((file) => file.sha256.toLowerCase()));
|
|
99651
|
-
if (!checked.ok) return reply.status(409).send({ ok: false, code: "filter-source-mismatch", error: "This filter no longer matches the attached drawing set. Reload the Drawing Filter and review it again." });
|
|
99652
|
-
}
|
|
99653
|
-
if (filterRequest && project) {
|
|
99654
|
-
const current = readAcceptedForRequest(req.params.appId, project, "read");
|
|
99655
|
-
if (current == null || declaredTypeOf(current) !== STEEL_V2 || declaredTypeOf(contractBody) !== STEEL_V2) {
|
|
99656
|
-
return reply.status(409).send({ ok: false, code: "filter-checkpoint-missing", error: "Reload the Drawing Filter from this project and review it again." });
|
|
99657
|
-
}
|
|
99658
|
-
const withoutFilter = (value) => {
|
|
99659
|
-
const copy = structuredClone(value);
|
|
99660
|
-
delete copy.filter;
|
|
99661
|
-
return copy;
|
|
99662
|
-
};
|
|
99663
|
-
if (contractHash(withoutFilter(current)) !== contractHash(withoutFilter(contractBody))) {
|
|
99664
|
-
return reply.status(409).send({ ok: false, code: "filter-write-out-of-scope", error: "The model changed while the Drawing Filter was open. Reload it and review the filter again." });
|
|
99665
|
-
}
|
|
99666
|
-
}
|
|
99667
|
-
const ifMatch = typeof req.headers["if-match"] === "string" ? req.headers["if-match"] : void 0;
|
|
99668
|
-
const ifNoneMatch = typeof req.headers["if-none-match"] === "string" ? req.headers["if-none-match"] : void 0;
|
|
99669
|
-
const persist2 = async () => {
|
|
99670
|
-
const livePrepass = prepassRequestId ? getRequest(prepassRequestId) : null;
|
|
99671
|
-
const liveFilter = filterRequestId ? getRequest(filterRequestId) : null;
|
|
99672
|
-
if (prepassRequestId && (!project || !livePrepass || livePrepass.type !== "revision-read" || livePrepass.project !== project || livePrepass.status !== "pending" || livePrepass.settledVersion !== void 0 || livePrepass.prepassBaseEtag !== null || !isExactFilterCheckpointShell(contractBody))) {
|
|
99673
|
-
return reply.status(400).send({ ok: false, error: "X-FloLess-Prepass-Request must name this pending initial read and a populated Steel Filter" });
|
|
99674
|
-
}
|
|
99675
|
-
if (filterRequestId && (!project || !liveFilter || liveFilter.type !== "revision-read" || liveFilter.project !== project || liveFilter.status !== "pending" || liveFilter.settledVersion !== void 0)) {
|
|
99676
|
-
return reply.status(400).send({ ok: false, error: "X-FloLess-Filter-Request must name this pending drawing read" });
|
|
99677
|
-
}
|
|
99678
|
-
const liveBound = livePrepass ?? liveFilter;
|
|
99679
|
-
if (liveBound) {
|
|
99680
|
-
const checked = validateSteelFilterSourceCoverage(contractBody, (liveBound.sourceRefs ?? []).map((file) => file.sha256.toLowerCase()));
|
|
99681
|
-
if (!checked.ok) return reply.status(409).send({ ok: false, code: "filter-source-mismatch", error: "This filter no longer matches every file in the attached drawing set. Reload the Drawing Filter and review it again." });
|
|
99682
|
-
}
|
|
99683
|
-
const result = await writeContractChecked(req.params.appId, contractBody, project, { origin: "client", ifMatch, ifNoneMatch });
|
|
99684
|
-
reply.header("ETag", result.etag);
|
|
99685
|
-
if (project) clearApproval(project);
|
|
99686
|
-
if (livePrepass) {
|
|
99687
|
-
const updated = patchRequest(livePrepass.id, { prepassReady: true, prepassEtag: result.etag, filterSaved: false, filterSavedEtag: void 0 });
|
|
99688
|
-
if (updated) broadcast({ type: "request-added", request: updated });
|
|
99689
|
-
}
|
|
99690
|
-
broadcast(contractChangedEvent(req.params.appId, project, result.etag, result.storeRevision, req.headers["x-floless-mutation-id"]));
|
|
99691
|
-
return {
|
|
99692
|
-
ok: true,
|
|
99693
|
-
etag: result.etag,
|
|
99694
|
-
storeRevision: result.storeRevision,
|
|
99695
|
-
...result.invalidatedWorkPointDecisions > 0 ? { contract: result.contract, invalidatedWorkPointDecisions: result.invalidatedWorkPointDecisions } : {},
|
|
99696
|
-
// The write-boundary connection revalidation report (server/contract-gateway.ts). Present only
|
|
99697
|
-
// when a client steel move actually ran revalidation; the client threads it into ONE plain-English
|
|
99698
|
-
// toast. It is NOT accompanied by the transformed contract on a plain move — the removed/repointed
|
|
99699
|
-
// joints already live in the stored contract, and re-installing here would wipe the browser's undo
|
|
99700
|
-
// stack (installMemberEndContract clears it), stranding the one-Ctrl+Z-restores-the-joint gesture.
|
|
99701
|
-
...result.revalidation ? { revalidation: result.revalidation } : {}
|
|
99702
|
-
};
|
|
99703
|
-
};
|
|
99704
|
-
try {
|
|
99705
|
-
return await (project && (prepassRequestId || filterRequestId) ? withLifecycleLock("project", project, persist2) : persist2());
|
|
99706
|
-
} catch (e) {
|
|
99707
|
-
if (e instanceof PreconditionRequiredError) {
|
|
99708
|
-
return reply.status(428).send({ ok: false, error: e.message, code: e.code });
|
|
99709
|
-
}
|
|
99710
|
-
if (e instanceof PreconditionFailedError) {
|
|
99711
|
-
return reply.status(412).send({ ok: false, error: e.message, code: e.code });
|
|
99712
|
-
}
|
|
99713
|
-
if (e instanceof ContractError) return reply.status(400).send({ ok: false, error: e.message, ...e.code ? { code: e.code } : {} });
|
|
99714
|
-
throw e;
|
|
99715
|
-
}
|
|
99716
|
-
}
|
|
99717
|
-
);
|
|
99810
|
+
registerContractPutRoute(app, { broadcast, requestView: requestView2 });
|
|
99718
99811
|
app.get("/api/projects/:id/approval-review", async (req, reply) => {
|
|
99719
99812
|
try {
|
|
99720
99813
|
return await withLifecycleLock("project", req.params.id, () => {
|
|
@@ -101583,7 +101676,7 @@ async function startServer() {
|
|
|
101583
101676
|
{ bodyLimit: 25 * 1024 * 1024 },
|
|
101584
101677
|
async (req, reply) => {
|
|
101585
101678
|
const { appId, nodeId, instruction, snapshots } = req.body ?? {};
|
|
101586
|
-
if (!
|
|
101679
|
+
if (!isSafeAppId(appId) || !nodeId || !instruction) {
|
|
101587
101680
|
return reply.status(400).send({ ok: false, error: "appId, nodeId, instruction required" });
|
|
101588
101681
|
}
|
|
101589
101682
|
let decoded;
|
|
@@ -101607,7 +101700,7 @@ async function startServer() {
|
|
|
101607
101700
|
async (req, reply) => {
|
|
101608
101701
|
const { appId, inputName, instruction, snapshots } = req.body ?? {};
|
|
101609
101702
|
const sourceName = typeof req.body?.sourceName === "string" ? req.body.sourceName : void 0;
|
|
101610
|
-
if (!
|
|
101703
|
+
if (!isSafeAppId(appId)) return reply.status(400).send({ ok: false, error: "a valid appId is required" });
|
|
101611
101704
|
let decoded;
|
|
101612
101705
|
try {
|
|
101613
101706
|
decoded = decodeSnapshots(snapshots);
|
|
@@ -101699,7 +101792,7 @@ async function startServer() {
|
|
|
101699
101792
|
);
|
|
101700
101793
|
app.post("/api/use-template", async (req, reply) => {
|
|
101701
101794
|
const { appId, templateId } = req.body ?? {};
|
|
101702
|
-
if (!
|
|
101795
|
+
if (!isSafeAppId(appId) || !templateId) return reply.status(400).send({ ok: false, error: "a valid appId and templateId are required" });
|
|
101703
101796
|
const template = getTemplate(templateId);
|
|
101704
101797
|
if (!template) return reply.status(404).send({ ok: false, error: "template not found" });
|
|
101705
101798
|
const request = addRequest({ type: "use-template", appId, templateId, template });
|