@floless/app 0.126.3 → 0.126.4
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 +443 -402
- package/dist/web/app.css +127 -0
- package/dist/web/aware.js +345 -2
- package/dist/web/index.html +32 -1
- package/dist/web/steel-3d-view.js +14 -2
- package/dist/web/steel-editor.html +7 -6
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -54612,7 +54612,7 @@ function appVersion() {
|
|
|
54612
54612
|
return resolveVersion({
|
|
54613
54613
|
isSea: isSea2(),
|
|
54614
54614
|
sqVersionXml: readSqVersionXml(),
|
|
54615
|
-
define: true ? "0.126.
|
|
54615
|
+
define: true ? "0.126.4" : void 0,
|
|
54616
54616
|
pkgVersion: readPkgVersion()
|
|
54617
54617
|
});
|
|
54618
54618
|
}
|
|
@@ -54628,7 +54628,7 @@ function resolveChannel(s) {
|
|
|
54628
54628
|
function appChannel() {
|
|
54629
54629
|
return resolveChannel({
|
|
54630
54630
|
isSea: isSea2(),
|
|
54631
|
-
define: true ? "0.126.
|
|
54631
|
+
define: true ? "0.126.4" : void 0,
|
|
54632
54632
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
54633
54633
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
54634
54634
|
modulePath: process.argv[1]
|
|
@@ -59941,6 +59941,190 @@ function decodeSnapshots(inputs) {
|
|
|
59941
59941
|
});
|
|
59942
59942
|
}
|
|
59943
59943
|
|
|
59944
|
+
// run-relay.ts
|
|
59945
|
+
var import_node_os17 = require("node:os");
|
|
59946
|
+
var import_node_path25 = require("node:path");
|
|
59947
|
+
var RUN_POLICY = {
|
|
59948
|
+
/**
|
|
59949
|
+
* The first slice's one enabled type: small, mechanical, well-scoped.
|
|
59950
|
+
*
|
|
59951
|
+
* Three calls, and nothing else. Note what is NOT here: no `PUT /api/contract`, no `/approve`, no
|
|
59952
|
+
* project route — a `tweak` edits a node in a `.flo` and compiles it, and the approval gate stays
|
|
59953
|
+
* human. `POST /api/compile` is what replaces the skill's `aware app compile` shell-out, which is
|
|
59954
|
+
* the other half of the shell being denied.
|
|
59955
|
+
*/
|
|
59956
|
+
tweak: {
|
|
59957
|
+
runnable: true,
|
|
59958
|
+
calls: (l) => [
|
|
59959
|
+
{ method: "GET", path: "/api/requests", why: "read the authoritative spec for this request" },
|
|
59960
|
+
...isSafeAppId(l.appId) ? [{ method: "POST", path: "/api/compile", body: { id: l.appId }, why: "compile the workflow after editing its .flo" }] : [],
|
|
59961
|
+
{ method: "DELETE", path: `/api/requests/${l.requestId}`, why: "clear this request once applied" }
|
|
59962
|
+
],
|
|
59963
|
+
// The `.flo` lives in the app's own source directory, NOT in the nominated folder — which is
|
|
59964
|
+
// exactly why §D1 insists the nominated folder is an address rather than a sandbox. Without this
|
|
59965
|
+
// grant the agent can read its instruction and edit nothing.
|
|
59966
|
+
//
|
|
59967
|
+
// `.filter(Boolean)`, so an id `appSourceDir` refuses grants NOTHING rather than falling back to
|
|
59968
|
+
// something broader. A run whose app id is unusable should be refused before it starts (the route
|
|
59969
|
+
// does that), and if one ever reaches here it gets no filesystem capability at all.
|
|
59970
|
+
addDirs: (l) => l.appId ? [appSourceDir(l.appId)].filter((d) => d !== null) : []
|
|
59971
|
+
},
|
|
59972
|
+
// ── enabled by E1, but not built in this slice ──────────────────────────────
|
|
59973
|
+
// Each is mechanical and well-scoped enough to run headless; each needs its own call list worked
|
|
59974
|
+
// out from its skill and its own end-to-end proof, and the plan slices the first spawn to ONE type
|
|
59975
|
+
// on purpose. A reason, not a null, so the picker can say why the button is absent.
|
|
59976
|
+
"use-template": { runnable: false, why: "not yet available headless \u2014 run it from your terminal for now" },
|
|
59977
|
+
"ui-customize": { runnable: false, why: "not yet available headless \u2014 run it from your terminal for now" },
|
|
59978
|
+
rebake: { runnable: false, why: "not yet available headless \u2014 run it from your terminal for now" },
|
|
59979
|
+
"tweak-contract": { runnable: false, why: "not yet available headless \u2014 run it from your terminal for now" },
|
|
59980
|
+
// ── E1 says no, and these are the reasons ───────────────────────────────────
|
|
59981
|
+
"revision-read": {
|
|
59982
|
+
runnable: false,
|
|
59983
|
+
// The flagship type, and the judgment-heaviest: every arm of its instruction ends "STOP and tell
|
|
59984
|
+
// me to open Drawings → Steel Filter … do NOT read members until I explicitly come back". It is a
|
|
59985
|
+
// two-phase workflow whose first phase ends in a mandatory human checkpoint, so headless the best
|
|
59986
|
+
// outcome is "prepass runs, agent says go review, exits 0, request still pending" — a row that
|
|
59987
|
+
// lies. It waits until `needs-you` is a first-class, actionable row.
|
|
59988
|
+
why: "reading a drawing set stops at a review checkpoint \u2014 do this one in your terminal"
|
|
59989
|
+
},
|
|
59990
|
+
"knowledge-organize": {
|
|
59991
|
+
runnable: false,
|
|
59992
|
+
// Both take the server organize lock, and the plan's stated mitigation ("mark the request failed
|
|
59993
|
+
// so the lock is released") is a NO-OP: `patchRequest` writes a request file, while the lock is
|
|
59994
|
+
// released by `failOrganize` in the knowledge store. A hard-killed headless organize past
|
|
59995
|
+
// `/start` wedges the Organize button for ten minutes, on a row that renders no ✕.
|
|
59996
|
+
why: "organizing holds a lock a killed run can\u2019t release \u2014 do this one in your terminal"
|
|
59997
|
+
},
|
|
59998
|
+
"knowledge-adjust": { runnable: false, why: "organizing holds a lock a killed run can\u2019t release \u2014 do this one in your terminal" },
|
|
59999
|
+
guide: { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" },
|
|
60000
|
+
"new-workflow": { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" }
|
|
60001
|
+
};
|
|
60002
|
+
var SAFE_APP_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
60003
|
+
var isSafeAppId = (id) => typeof id === "string" && SAFE_APP_ID.test(id);
|
|
60004
|
+
function appSourceDir(appId) {
|
|
60005
|
+
if (!isSafeAppId(appId)) return null;
|
|
60006
|
+
const root5 = process.env.AWARE_HOME || (0, import_node_path25.join)((0, import_node_os17.homedir)(), ".aware");
|
|
60007
|
+
return (0, import_node_path25.join)(root5, "apps", appId);
|
|
60008
|
+
}
|
|
60009
|
+
function policyFor(type) {
|
|
60010
|
+
if (!isRequestType(type)) {
|
|
60011
|
+
return { runnable: false, why: "floless doesn\u2019t recognise this request \u2014 it may have been made by a newer version" };
|
|
60012
|
+
}
|
|
60013
|
+
return RUN_POLICY[type];
|
|
60014
|
+
}
|
|
60015
|
+
var TOOL_NAME = "floless_api";
|
|
60016
|
+
function mcpConfigFor(token2, origin) {
|
|
60017
|
+
return { mcpServers: { floless: { type: "http", url: `${origin}/api/mcp/run/${token2}` } } };
|
|
60018
|
+
}
|
|
60019
|
+
function jsonRpc(id, result) {
|
|
60020
|
+
return { jsonrpc: "2.0", id, result };
|
|
60021
|
+
}
|
|
60022
|
+
function toolRefusal(text3) {
|
|
60023
|
+
return { content: [{ type: "text", text: text3 }], isError: true };
|
|
60024
|
+
}
|
|
60025
|
+
function sameBody(want, got) {
|
|
60026
|
+
if (want === void 0 && got !== null && typeof got === "object" && Object.keys(got).length === 0) return true;
|
|
60027
|
+
return JSON.stringify(sortKeys(want)) === JSON.stringify(sortKeys(got ?? void 0));
|
|
60028
|
+
}
|
|
60029
|
+
function sortKeys(v) {
|
|
60030
|
+
if (Array.isArray(v)) return v.map(sortKeys);
|
|
60031
|
+
if (v && typeof v === "object") {
|
|
60032
|
+
return Object.fromEntries(Object.keys(v).sort().map((k) => [k, sortKeys(v[k])]));
|
|
60033
|
+
}
|
|
60034
|
+
return v;
|
|
60035
|
+
}
|
|
60036
|
+
function normalizePath(raw, origin) {
|
|
60037
|
+
if (typeof raw !== "string" || !raw) return null;
|
|
60038
|
+
let u;
|
|
60039
|
+
try {
|
|
60040
|
+
u = new URL(raw, origin);
|
|
60041
|
+
} catch {
|
|
60042
|
+
return null;
|
|
60043
|
+
}
|
|
60044
|
+
if (new URL(origin).origin !== u.origin) return null;
|
|
60045
|
+
const p = u.pathname.length > 1 && u.pathname.endsWith("/") ? u.pathname.slice(0, -1) : u.pathname;
|
|
60046
|
+
return `${p}${u.search}`;
|
|
60047
|
+
}
|
|
60048
|
+
function registerRunRelay(app, deps, origin) {
|
|
60049
|
+
app.post(
|
|
60050
|
+
"/api/mcp/run/:token",
|
|
60051
|
+
async (req, reply) => {
|
|
60052
|
+
const msg = req.body ?? {};
|
|
60053
|
+
if (msg.id === void 0) return reply.status(202).send();
|
|
60054
|
+
const lease = deps.leaseForToken(req.params.token);
|
|
60055
|
+
if (!lease) {
|
|
60056
|
+
return reply.status(200).send({
|
|
60057
|
+
jsonrpc: "2.0",
|
|
60058
|
+
id: msg.id,
|
|
60059
|
+
error: { code: -32001, message: "this run is no longer active" }
|
|
60060
|
+
});
|
|
60061
|
+
}
|
|
60062
|
+
const policy = policyFor(lease.requestType);
|
|
60063
|
+
const allowed = policy.runnable ? policy.calls(lease) : [];
|
|
60064
|
+
if (msg.method === "initialize") {
|
|
60065
|
+
const requested = msg.params?.protocolVersion;
|
|
60066
|
+
return reply.send(jsonRpc(msg.id, {
|
|
60067
|
+
protocolVersion: requested ?? "2025-06-18",
|
|
60068
|
+
capabilities: { tools: {} },
|
|
60069
|
+
serverInfo: { name: "floless", version: "1" }
|
|
60070
|
+
}));
|
|
60071
|
+
}
|
|
60072
|
+
if (msg.method === "tools/list") {
|
|
60073
|
+
return reply.send(jsonRpc(msg.id, {
|
|
60074
|
+
tools: [{
|
|
60075
|
+
name: TOOL_NAME,
|
|
60076
|
+
description: "Call the floless.app API for THIS request. This is your only channel to floless \u2014 there is no shell in this session. Exactly these calls are permitted:\n" + allowed.map((c) => ` ${c.method} ${c.path}${c.body ? ` body ${JSON.stringify(c.body)}` : ""} \u2014 ${c.why}`).join("\n") + '\nAnything else is refused. If you need something not listed, stop and finish with outcome "needs-you" explaining what you need.',
|
|
60077
|
+
inputSchema: {
|
|
60078
|
+
type: "object",
|
|
60079
|
+
properties: {
|
|
60080
|
+
method: { type: "string", enum: ["GET", "POST", "PUT", "DELETE"] },
|
|
60081
|
+
path: { type: "string" },
|
|
60082
|
+
body: { type: "object" }
|
|
60083
|
+
},
|
|
60084
|
+
required: ["method", "path"]
|
|
60085
|
+
}
|
|
60086
|
+
}]
|
|
60087
|
+
}));
|
|
60088
|
+
}
|
|
60089
|
+
if (msg.method !== "tools/call") {
|
|
60090
|
+
return reply.send({ jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: "method not found" } });
|
|
60091
|
+
}
|
|
60092
|
+
const params = msg.params;
|
|
60093
|
+
if (params?.name !== TOOL_NAME) {
|
|
60094
|
+
return reply.send(jsonRpc(msg.id, toolRefusal(`no such tool: ${String(params?.name)}`)));
|
|
60095
|
+
}
|
|
60096
|
+
if (!policy.runnable) {
|
|
60097
|
+
return reply.send(jsonRpc(msg.id, toolRefusal(`refused: ${policy.why}`)));
|
|
60098
|
+
}
|
|
60099
|
+
const argMethod = String(params.arguments?.["method"] ?? "").toUpperCase();
|
|
60100
|
+
const argPath = normalizePath(params.arguments?.["path"], origin);
|
|
60101
|
+
const argBody = params.arguments?.["body"];
|
|
60102
|
+
const match = argPath === null ? void 0 : allowed.find((c) => c.method === argMethod && c.path === argPath && sameBody(c.body, argBody));
|
|
60103
|
+
if (!match) {
|
|
60104
|
+
return reply.send(jsonRpc(msg.id, toolRefusal(
|
|
60105
|
+
`refused: ${argMethod} ${String(params.arguments?.["path"])} is not permitted for this run.
|
|
60106
|
+
Permitted:
|
|
60107
|
+
${allowed.map((c) => ` ${c.method} ${c.path}${c.body ? ` body ${JSON.stringify(c.body)}` : ""}`).join("\n")}`
|
|
60108
|
+
)));
|
|
60109
|
+
}
|
|
60110
|
+
const res = await deps.dispatch({ method: match.method, path: match.path, ...match.body !== void 0 ? { body: match.body } : {} });
|
|
60111
|
+
if (match.method === "DELETE" && match.path === `/api/requests/${lease.requestId}` && res.status < 300) {
|
|
60112
|
+
deps.markResolved(lease);
|
|
60113
|
+
}
|
|
60114
|
+
const body = match.path === "/api/requests" ? onlyThisRequest(res.body, lease.requestId) : res.body;
|
|
60115
|
+
return reply.send(jsonRpc(msg.id, {
|
|
60116
|
+
content: [{ type: "text", text: JSON.stringify({ status: res.status, body }) }],
|
|
60117
|
+
...res.status >= 400 ? { isError: true } : {}
|
|
60118
|
+
}));
|
|
60119
|
+
}
|
|
60120
|
+
);
|
|
60121
|
+
}
|
|
60122
|
+
function onlyThisRequest(body, requestId) {
|
|
60123
|
+
const b = body;
|
|
60124
|
+
if (!b || !Array.isArray(b.requests)) return body;
|
|
60125
|
+
return { ...b, requests: b.requests.filter((r) => r?.id === requestId) };
|
|
60126
|
+
}
|
|
60127
|
+
|
|
59944
60128
|
// request-instruction.ts
|
|
59945
60129
|
function kbClause(project, appId) {
|
|
59946
60130
|
if (!project) return "";
|
|
@@ -60042,10 +60226,17 @@ var selfOrigin = () => `http://127.0.0.1:${Number(process.env.PORT ?? 4317)}`;
|
|
|
60042
60226
|
function withPrompt(r, base = selfOrigin()) {
|
|
60043
60227
|
try {
|
|
60044
60228
|
const prompt = instructionFor(r);
|
|
60045
|
-
|
|
60229
|
+
const policy = policyFor(r.type);
|
|
60230
|
+
return {
|
|
60231
|
+
...r,
|
|
60232
|
+
prompt,
|
|
60233
|
+
marker: markerFor(r, base, prompt),
|
|
60234
|
+
canRun: policy.runnable,
|
|
60235
|
+
runWhy: policy.runnable ? null : policy.why
|
|
60236
|
+
};
|
|
60046
60237
|
} catch (err2) {
|
|
60047
60238
|
console.error(`[request-instruction] could not compose request ${r.id} (${r.type}):`, err2);
|
|
60048
|
-
return { ...r, prompt: r.instruction ? String(r.instruction).trim() : "", marker: "" };
|
|
60239
|
+
return { ...r, prompt: r.instruction ? String(r.instruction).trim() : "", marker: "", canRun: false, runWhy: null };
|
|
60049
60240
|
}
|
|
60050
60241
|
}
|
|
60051
60242
|
var NO_ENRICHMENTS = { appTemplateId: void 0, contractType: void 0, projectName: void 0 };
|
|
@@ -60061,7 +60252,7 @@ function enrichedView(r, enrich, base = selfOrigin()) {
|
|
|
60061
60252
|
|
|
60062
60253
|
// connection-import.ts
|
|
60063
60254
|
var import_node_fs27 = require("node:fs");
|
|
60064
|
-
var
|
|
60255
|
+
var import_node_path26 = require("node:path");
|
|
60065
60256
|
|
|
60066
60257
|
// ifc-frame.ts
|
|
60067
60258
|
var FILE_Z_UP = "z-up";
|
|
@@ -60094,7 +60285,7 @@ async function ensureConnectionReader() {
|
|
|
60094
60285
|
function writeReaderApp(companionId, command, ifcPath, id) {
|
|
60095
60286
|
const dir = appPath(companionId);
|
|
60096
60287
|
(0, import_node_fs27.mkdirSync)(dir, { recursive: true });
|
|
60097
|
-
const flo = (0,
|
|
60288
|
+
const flo = (0, import_node_path26.join)(dir, `${companionId}.flo`);
|
|
60098
60289
|
const lines = [
|
|
60099
60290
|
`app: ${companionId}`,
|
|
60100
60291
|
"version: 0.1.0",
|
|
@@ -60321,8 +60512,8 @@ async function extractConnection(companionId, ifcPath, id, opts = {}) {
|
|
|
60321
60512
|
|
|
60322
60513
|
// contract-store.ts
|
|
60323
60514
|
var import_node_fs28 = require("node:fs");
|
|
60324
|
-
var
|
|
60325
|
-
var
|
|
60515
|
+
var import_node_path27 = require("node:path");
|
|
60516
|
+
var import_node_os18 = require("node:os");
|
|
60326
60517
|
var ContractError = class extends Error {
|
|
60327
60518
|
/** Carries the acceptance policy's reason forward. "This store must be migrated first" and "your
|
|
60328
60519
|
* contract is corrupt" are different actionable states, and a client that cannot tell them apart
|
|
@@ -60334,8 +60525,8 @@ var ContractError = class extends Error {
|
|
|
60334
60525
|
this.code = code;
|
|
60335
60526
|
}
|
|
60336
60527
|
};
|
|
60337
|
-
var ROOT3 = process.env.FLOLESS_HOME ?? (0,
|
|
60338
|
-
var DIR = (0,
|
|
60528
|
+
var ROOT3 = process.env.FLOLESS_HOME ?? (0, import_node_path27.join)((0, import_node_os18.homedir)(), ".floless");
|
|
60529
|
+
var DIR = (0, import_node_path27.join)(ROOT3, "contracts");
|
|
60339
60530
|
function safeId(appId) {
|
|
60340
60531
|
if (!/^[a-z0-9][a-z0-9._-]*$/i.test(appId)) throw new ContractError(`invalid appId: ${appId}`);
|
|
60341
60532
|
return appId;
|
|
@@ -60345,14 +60536,14 @@ function safeProjectSeg(projectId) {
|
|
|
60345
60536
|
return projectId;
|
|
60346
60537
|
}
|
|
60347
60538
|
function contractPath(appId, projectId) {
|
|
60348
|
-
if (projectId) return (0,
|
|
60349
|
-
return (0,
|
|
60539
|
+
if (projectId) return (0, import_node_path27.join)(ROOT3, "projects", safeProjectSeg(projectId), "contract.json");
|
|
60540
|
+
return (0, import_node_path27.join)(DIR, `${safeId(appId)}.json`);
|
|
60350
60541
|
}
|
|
60351
60542
|
function moveAppContractBytes(fromAppId, toAppId) {
|
|
60352
60543
|
const from = contractPath(fromAppId);
|
|
60353
60544
|
const to = contractPath(toAppId);
|
|
60354
60545
|
if (from === to || !(0, import_node_fs28.existsSync)(from)) return false;
|
|
60355
|
-
(0, import_node_fs28.mkdirSync)((0,
|
|
60546
|
+
(0, import_node_fs28.mkdirSync)((0, import_node_path27.dirname)(to), { recursive: true });
|
|
60356
60547
|
(0, import_node_fs28.renameSync)(from, to);
|
|
60357
60548
|
return true;
|
|
60358
60549
|
}
|
|
@@ -60360,7 +60551,7 @@ function copyAppContractBytes(fromAppId, toAppId) {
|
|
|
60360
60551
|
const from = contractPath(fromAppId);
|
|
60361
60552
|
const to = contractPath(toAppId);
|
|
60362
60553
|
if (from === to || !(0, import_node_fs28.existsSync)(from)) return false;
|
|
60363
|
-
(0, import_node_fs28.mkdirSync)((0,
|
|
60554
|
+
(0, import_node_fs28.mkdirSync)((0, import_node_path27.dirname)(to), { recursive: true });
|
|
60364
60555
|
(0, import_node_fs28.copyFileSync)(from, to);
|
|
60365
60556
|
return true;
|
|
60366
60557
|
}
|
|
@@ -60393,7 +60584,7 @@ function writeContract(appId, doc, projectId, privileged) {
|
|
|
60393
60584
|
throw e;
|
|
60394
60585
|
}
|
|
60395
60586
|
if (projectId) {
|
|
60396
|
-
if (!(0, import_node_fs28.existsSync)((0,
|
|
60587
|
+
if (!(0, import_node_fs28.existsSync)((0, import_node_path27.dirname)(p))) throw new ContractError(`unknown project: ${projectId}`);
|
|
60397
60588
|
} else if (!(0, import_node_fs28.existsSync)(DIR)) {
|
|
60398
60589
|
(0, import_node_fs28.mkdirSync)(DIR, { recursive: true });
|
|
60399
60590
|
}
|
|
@@ -60437,14 +60628,14 @@ function readContractForApp(appId, readAppFn = readApp) {
|
|
|
60437
60628
|
var import_node_crypto15 = require("node:crypto");
|
|
60438
60629
|
var import_node_fs29 = require("node:fs");
|
|
60439
60630
|
var import_promises3 = require("node:fs/promises");
|
|
60440
|
-
var
|
|
60631
|
+
var import_node_path28 = require("node:path");
|
|
60441
60632
|
var BLOB_MIN = 8192;
|
|
60442
60633
|
var BLOB_KEY = "__blobRef__";
|
|
60443
60634
|
var HASH_RE = /^[0-9a-f]{64}$/;
|
|
60444
60635
|
var LOG_CLAIM_TOKEN = (0, import_node_crypto15.randomUUID)();
|
|
60445
|
-
var versionsDir = (id) => (0,
|
|
60446
|
-
var objectsDir = (id) => (0,
|
|
60447
|
-
var logPath = (id) => (0,
|
|
60636
|
+
var versionsDir = (id) => (0, import_node_path28.join)(projectDir(id), "versions");
|
|
60637
|
+
var objectsDir = (id) => (0, import_node_path28.join)(projectDir(id), "objects");
|
|
60638
|
+
var logPath = (id) => (0, import_node_path28.join)(versionsDir(id), "log.json");
|
|
60448
60639
|
function writeAtomic(path, text3) {
|
|
60449
60640
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
60450
60641
|
(0, import_node_fs29.writeFileSync)(tmp, text3);
|
|
@@ -60520,7 +60711,7 @@ function versionBlobHash(node) {
|
|
|
60520
60711
|
function readVersionBlob(id, hash2) {
|
|
60521
60712
|
if (!HASH_RE.test(hash2)) return null;
|
|
60522
60713
|
try {
|
|
60523
|
-
const value = (0, import_node_fs29.readFileSync)((0,
|
|
60714
|
+
const value = (0, import_node_fs29.readFileSync)((0, import_node_path28.join)(objectsDir(id), hash2), "utf8");
|
|
60524
60715
|
return (0, import_node_crypto15.createHash)("sha256").update(value).digest("hex") === hash2 ? value : null;
|
|
60525
60716
|
} catch {
|
|
60526
60717
|
return null;
|
|
@@ -60529,7 +60720,7 @@ function readVersionBlob(id, hash2) {
|
|
|
60529
60720
|
async function readVersionBlobAsync(id, hash2) {
|
|
60530
60721
|
if (!HASH_RE.test(hash2)) return null;
|
|
60531
60722
|
try {
|
|
60532
|
-
const value = await (0, import_promises3.readFile)((0,
|
|
60723
|
+
const value = await (0, import_promises3.readFile)((0, import_node_path28.join)(objectsDir(id), hash2), "utf8");
|
|
60533
60724
|
return (0, import_node_crypto15.createHash)("sha256").update(value).digest("hex") === hash2 ? value : null;
|
|
60534
60725
|
} catch {
|
|
60535
60726
|
return null;
|
|
@@ -60582,26 +60773,26 @@ function claimVersionNumber(id, from) {
|
|
|
60582
60773
|
const dir = versionsDir(id);
|
|
60583
60774
|
const CAP = 1e5;
|
|
60584
60775
|
for (let n = Math.max(1, from); n < from + CAP; n++) {
|
|
60585
|
-
if ((0, import_node_fs29.existsSync)((0,
|
|
60776
|
+
if ((0, import_node_fs29.existsSync)((0, import_node_path28.join)(dir, `${n}.json`))) continue;
|
|
60586
60777
|
try {
|
|
60587
|
-
(0, import_node_fs29.mkdirSync)((0,
|
|
60778
|
+
(0, import_node_fs29.mkdirSync)((0, import_node_path28.join)(dir, `.claim-${n}`));
|
|
60588
60779
|
} catch (e) {
|
|
60589
60780
|
if (e.code === "EEXIST") continue;
|
|
60590
60781
|
throw e;
|
|
60591
60782
|
}
|
|
60592
|
-
if (!(0, import_node_fs29.existsSync)((0,
|
|
60783
|
+
if (!(0, import_node_fs29.existsSync)((0, import_node_path28.join)(dir, `${n}.json`))) return n;
|
|
60593
60784
|
releaseVersionClaim(id, n);
|
|
60594
60785
|
}
|
|
60595
60786
|
throw new Error(`project ${id}: no free version number after ${CAP} attempts from ${from}`);
|
|
60596
60787
|
}
|
|
60597
60788
|
function releaseVersionClaim(id, n) {
|
|
60598
60789
|
try {
|
|
60599
|
-
(0, import_node_fs29.rmSync)((0,
|
|
60790
|
+
(0, import_node_fs29.rmSync)((0, import_node_path28.join)(versionsDir(id), `.claim-${n}`), { recursive: true, force: true });
|
|
60600
60791
|
} catch {
|
|
60601
60792
|
}
|
|
60602
60793
|
}
|
|
60603
60794
|
function withLogClaim(id, fn) {
|
|
60604
|
-
const claim = (0,
|
|
60795
|
+
const claim = (0, import_node_path28.join)(versionsDir(id), ".claim-log");
|
|
60605
60796
|
const me = `${process.pid}:${LOG_CLAIM_TOKEN}`;
|
|
60606
60797
|
const STALE_MS3 = 3e4;
|
|
60607
60798
|
const deadline = Date.now() + 250;
|
|
@@ -60639,7 +60830,7 @@ function createVersion(id, contract, meta) {
|
|
|
60639
60830
|
const blobs = /* @__PURE__ */ new Map();
|
|
60640
60831
|
const skeleton = dehydrate(contract, blobs);
|
|
60641
60832
|
for (const [hash2, text3] of blobs) {
|
|
60642
|
-
const p = (0,
|
|
60833
|
+
const p = (0, import_node_path28.join)(objectsDir(id), hash2);
|
|
60643
60834
|
if (!(0, import_node_fs29.existsSync)(p)) writeAtomic(p, text3);
|
|
60644
60835
|
}
|
|
60645
60836
|
const log2 = loadLog(id);
|
|
@@ -60658,7 +60849,7 @@ function createVersion(id, contract, meta) {
|
|
|
60658
60849
|
...meta.approval ? { approval: meta.approval } : {},
|
|
60659
60850
|
...meta.discard ? { discard: meta.discard } : {}
|
|
60660
60851
|
};
|
|
60661
|
-
const snapshotPath = (0,
|
|
60852
|
+
const snapshotPath = (0, import_node_path28.join)(versionsDir(id), `${n}.json`);
|
|
60662
60853
|
try {
|
|
60663
60854
|
writeAtomic(snapshotPath, JSON.stringify({ meta: row, contract: skeleton }, null, 2));
|
|
60664
60855
|
withLogClaim(id, () => {
|
|
@@ -60685,7 +60876,7 @@ function listVersions(id) {
|
|
|
60685
60876
|
}
|
|
60686
60877
|
function readVersion(id, n) {
|
|
60687
60878
|
try {
|
|
60688
|
-
const snap = JSON.parse((0, import_node_fs29.readFileSync)((0,
|
|
60879
|
+
const snap = JSON.parse((0, import_node_fs29.readFileSync)((0, import_node_path28.join)(versionsDir(id), `${n}.json`), "utf8"));
|
|
60689
60880
|
return rehydrate(snap.contract, id);
|
|
60690
60881
|
} catch {
|
|
60691
60882
|
return null;
|
|
@@ -60693,7 +60884,7 @@ function readVersion(id, n) {
|
|
|
60693
60884
|
}
|
|
60694
60885
|
async function readVersionAsync(id, n) {
|
|
60695
60886
|
try {
|
|
60696
|
-
const snap = JSON.parse(await (0, import_promises3.readFile)((0,
|
|
60887
|
+
const snap = JSON.parse(await (0, import_promises3.readFile)((0, import_node_path28.join)(versionsDir(id), `${n}.json`), "utf8"));
|
|
60697
60888
|
const refs = /* @__PURE__ */ new Set();
|
|
60698
60889
|
collectBlobRefs(snap.contract, refs);
|
|
60699
60890
|
if (refs.size === 0) return snap.contract;
|
|
@@ -60710,7 +60901,7 @@ async function readVersionAsync(id, n) {
|
|
|
60710
60901
|
}
|
|
60711
60902
|
function readVersionSkeleton(id, n) {
|
|
60712
60903
|
try {
|
|
60713
|
-
const snap = JSON.parse((0, import_node_fs29.readFileSync)((0,
|
|
60904
|
+
const snap = JSON.parse((0, import_node_fs29.readFileSync)((0, import_node_path28.join)(versionsDir(id), `${n}.json`), "utf8"));
|
|
60714
60905
|
return snap.contract;
|
|
60715
60906
|
} catch {
|
|
60716
60907
|
return null;
|
|
@@ -60718,7 +60909,7 @@ function readVersionSkeleton(id, n) {
|
|
|
60718
60909
|
}
|
|
60719
60910
|
async function readVersionSkeletonAsync(id, n) {
|
|
60720
60911
|
try {
|
|
60721
|
-
const snap = JSON.parse(await (0, import_promises3.readFile)((0,
|
|
60912
|
+
const snap = JSON.parse(await (0, import_promises3.readFile)((0, import_node_path28.join)(versionsDir(id), `${n}.json`), "utf8"));
|
|
60722
60913
|
return snap.contract;
|
|
60723
60914
|
} catch {
|
|
60724
60915
|
return null;
|
|
@@ -60727,9 +60918,9 @@ async function readVersionSkeletonAsync(id, n) {
|
|
|
60727
60918
|
|
|
60728
60919
|
// activation-store.ts
|
|
60729
60920
|
var import_node_fs30 = require("node:fs");
|
|
60730
|
-
var
|
|
60921
|
+
var import_node_path29 = require("node:path");
|
|
60731
60922
|
var FILENAME = ".floless-activation-record.json";
|
|
60732
|
-
var recordPath = (projectId) => (0,
|
|
60923
|
+
var recordPath = (projectId) => (0, import_node_path29.join)(projectDir(projectId), FILENAME);
|
|
60733
60924
|
function isStoredActivation(v) {
|
|
60734
60925
|
if (!v || typeof v !== "object") return false;
|
|
60735
60926
|
const r = v;
|
|
@@ -60792,7 +60983,7 @@ function incarnationOf(projectId) {
|
|
|
60792
60983
|
// contract-transaction.ts
|
|
60793
60984
|
var import_node_fs31 = require("node:fs");
|
|
60794
60985
|
var import_node_crypto17 = require("node:crypto");
|
|
60795
|
-
var
|
|
60986
|
+
var import_node_path30 = require("node:path");
|
|
60796
60987
|
|
|
60797
60988
|
// project-contract-hash.ts
|
|
60798
60989
|
function contractHash(contract) {
|
|
@@ -62796,8 +62987,8 @@ var RecoveryPendingError = class extends Error {
|
|
|
62796
62987
|
};
|
|
62797
62988
|
var PHASES2 = ["000-begin", "001-before", "002-staged", "003-commit", "004-done"];
|
|
62798
62989
|
var TXN_PREFIX = ".floless-txn-";
|
|
62799
|
-
var txnDir = (projectId, txnId) => (0,
|
|
62800
|
-
var phasePath = (dir, phase) => (0,
|
|
62990
|
+
var txnDir = (projectId, txnId) => (0, import_node_path30.join)(projectDir(projectId), `${TXN_PREFIX}${txnId}`);
|
|
62991
|
+
var phasePath = (dir, phase) => (0, import_node_path30.join)(dir, `${phase}.json`);
|
|
62801
62992
|
function writePhase2(dir, phase, body) {
|
|
62802
62993
|
(0, import_node_fs31.writeFileSync)(phasePath(dir, phase), `${JSON.stringify(body, null, 2)}
|
|
62803
62994
|
`, { flag: "wx" });
|
|
@@ -62821,7 +63012,7 @@ function txnDirs(projectId) {
|
|
|
62821
63012
|
} catch {
|
|
62822
63013
|
return [];
|
|
62823
63014
|
}
|
|
62824
|
-
return entries2.filter((e) => e.startsWith(TXN_PREFIX)).sort().map((e) => (0,
|
|
63015
|
+
return entries2.filter((e) => e.startsWith(TXN_PREFIX)).sort().map((e) => (0, import_node_path30.join)(projectDir(projectId), e));
|
|
62825
63016
|
}
|
|
62826
63017
|
function assertNoPendingRecovery(projectId) {
|
|
62827
63018
|
for (const dir of txnDirs(projectId)) {
|
|
@@ -63193,7 +63384,7 @@ async function runRollbackToV1(opts) {
|
|
|
63193
63384
|
}
|
|
63194
63385
|
function ledgerHead(projectId) {
|
|
63195
63386
|
try {
|
|
63196
|
-
const log2 = JSON.parse((0, import_node_fs31.readFileSync)((0,
|
|
63387
|
+
const log2 = JSON.parse((0, import_node_fs31.readFileSync)((0, import_node_path30.join)(projectDir(projectId), "versions", "log.json"), "utf8"));
|
|
63197
63388
|
return log2.versions.at(-1)?.n ?? 0;
|
|
63198
63389
|
} catch {
|
|
63199
63390
|
return 0;
|
|
@@ -63477,7 +63668,7 @@ function clientCount() {
|
|
|
63477
63668
|
// knowledge-store.ts
|
|
63478
63669
|
var import_node_crypto18 = require("node:crypto");
|
|
63479
63670
|
var import_node_fs33 = require("node:fs");
|
|
63480
|
-
var
|
|
63671
|
+
var import_node_path31 = require("node:path");
|
|
63481
63672
|
var import_yaml6 = __toESM(require_dist6(), 1);
|
|
63482
63673
|
var KnowledgeError = class extends Error {
|
|
63483
63674
|
code;
|
|
@@ -63487,8 +63678,8 @@ var KnowledgeError = class extends Error {
|
|
|
63487
63678
|
}
|
|
63488
63679
|
};
|
|
63489
63680
|
var EMPTY_MANIFEST = { revision: 0, currentGeneration: null, sources: [] };
|
|
63490
|
-
var manifestPath = (id) => (0,
|
|
63491
|
-
var blobsDir = (id) => (0,
|
|
63681
|
+
var manifestPath = (id) => (0, import_node_path31.join)(projectKnowledgeDir(id), "manifest.json");
|
|
63682
|
+
var blobsDir = (id) => (0, import_node_path31.join)(projectKnowledgeDir(id), "blobs");
|
|
63492
63683
|
var BLOB_SHA256_RE = /^[0-9a-f]{64}$/;
|
|
63493
63684
|
function isSourceRow(row) {
|
|
63494
63685
|
if (!row || typeof row !== "object") return false;
|
|
@@ -63525,7 +63716,7 @@ function writeManifest(id, manifest) {
|
|
|
63525
63716
|
const dir = projectKnowledgeDir(id);
|
|
63526
63717
|
(0, import_node_fs33.mkdirSync)(dir, { recursive: true });
|
|
63527
63718
|
const dest = manifestPath(id);
|
|
63528
|
-
const tmp = (0,
|
|
63719
|
+
const tmp = (0, import_node_path31.join)(dir, `.manifest.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63529
63720
|
(0, import_node_fs33.writeFileSync)(tmp, JSON.stringify(manifest, null, 2));
|
|
63530
63721
|
(0, import_node_fs33.renameSync)(tmp, dest);
|
|
63531
63722
|
}
|
|
@@ -63546,9 +63737,9 @@ function blobPathFor(id, blobSha256) {
|
|
|
63546
63737
|
if (typeof blobSha256 !== "string" || !BLOB_SHA256_RE.test(blobSha256)) {
|
|
63547
63738
|
throw new KnowledgeError(`invalid blob address: ${blobSha256}`);
|
|
63548
63739
|
}
|
|
63549
|
-
const full = (0,
|
|
63550
|
-
const root5 = (0,
|
|
63551
|
-
if (full !== (0,
|
|
63740
|
+
const full = (0, import_node_path31.resolve)((0, import_node_path31.join)(dir, blobSha256));
|
|
63741
|
+
const root5 = (0, import_node_path31.resolve)(dir);
|
|
63742
|
+
if (full !== (0, import_node_path31.join)(root5, blobSha256) || !full.startsWith(root5 + import_node_path31.sep)) {
|
|
63552
63743
|
throw new KnowledgeError(`blob path escapes the blobs directory: ${blobSha256}`);
|
|
63553
63744
|
}
|
|
63554
63745
|
return full;
|
|
@@ -63659,12 +63850,12 @@ function removeSource(id, sourceId) {
|
|
|
63659
63850
|
}
|
|
63660
63851
|
}
|
|
63661
63852
|
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
63662
|
-
var lockPath = (id) => (0,
|
|
63853
|
+
var lockPath = (id) => (0, import_node_path31.join)(projectKnowledgeDir(id), "lock.json");
|
|
63663
63854
|
function writeLockFile(id, lock) {
|
|
63664
63855
|
const dir = projectKnowledgeDir(id);
|
|
63665
63856
|
(0, import_node_fs33.mkdirSync)(dir, { recursive: true });
|
|
63666
63857
|
const dest = lockPath(id);
|
|
63667
|
-
const tmp = (0,
|
|
63858
|
+
const tmp = (0, import_node_path31.join)(dir, `.lock.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63668
63859
|
(0, import_node_fs33.writeFileSync)(tmp, JSON.stringify(lock, null, 2));
|
|
63669
63860
|
(0, import_node_fs33.renameSync)(tmp, dest);
|
|
63670
63861
|
}
|
|
@@ -63716,9 +63907,9 @@ function releaseLock(id, requestId) {
|
|
|
63716
63907
|
}
|
|
63717
63908
|
var GENERATION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
63718
63909
|
var GEN_KEEP = 3;
|
|
63719
|
-
var vaultDir = (id) => (0,
|
|
63720
|
-
var generationsDir = (id) => (0,
|
|
63721
|
-
var currentGenerationPath = (id) => (0,
|
|
63910
|
+
var vaultDir = (id) => (0, import_node_path31.join)(projectKnowledgeDir(id), "vault");
|
|
63911
|
+
var generationsDir = (id) => (0, import_node_path31.join)(vaultDir(id), "generations");
|
|
63912
|
+
var currentGenerationPath = (id) => (0, import_node_path31.join)(vaultDir(id), "current-generation.json");
|
|
63722
63913
|
function assertGenerationId(generationId) {
|
|
63723
63914
|
if (typeof generationId !== "string" || !GENERATION_ID_RE.test(generationId)) {
|
|
63724
63915
|
throw new KnowledgeError("invalid generation id");
|
|
@@ -63729,7 +63920,7 @@ function mintGenerationId() {
|
|
|
63729
63920
|
}
|
|
63730
63921
|
function generationWikiDir(id, generationId) {
|
|
63731
63922
|
assertGenerationId(generationId);
|
|
63732
|
-
return (0,
|
|
63923
|
+
return (0, import_node_path31.join)(generationsDir(id), generationId, "wiki");
|
|
63733
63924
|
}
|
|
63734
63925
|
function publishGeneration(id, generationId) {
|
|
63735
63926
|
assertGenerationId(generationId);
|
|
@@ -63738,7 +63929,7 @@ function publishGeneration(id, generationId) {
|
|
|
63738
63929
|
const dir = vaultDir(id);
|
|
63739
63930
|
(0, import_node_fs33.mkdirSync)(dir, { recursive: true });
|
|
63740
63931
|
const dest = currentGenerationPath(id);
|
|
63741
|
-
const tmp = (0,
|
|
63932
|
+
const tmp = (0, import_node_path31.join)(dir, `.current-generation.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63742
63933
|
(0, import_node_fs33.writeFileSync)(tmp, JSON.stringify(pointer, null, 2));
|
|
63743
63934
|
(0, import_node_fs33.renameSync)(tmp, dest);
|
|
63744
63935
|
const manifest = readManifest(id);
|
|
@@ -63806,14 +63997,14 @@ function eachPage(wikiDir, io, onPage) {
|
|
|
63806
63997
|
return "stop";
|
|
63807
63998
|
}
|
|
63808
63999
|
if (ent.isDirectory()) {
|
|
63809
|
-
if (walk2((0,
|
|
64000
|
+
if (walk2((0, import_node_path31.join)(dir, ent.name)) === "stop") return "stop";
|
|
63810
64001
|
} else if (ent.isFile() && ent.name.endsWith(".md")) {
|
|
63811
64002
|
const slug = ent.name.slice(0, -3);
|
|
63812
64003
|
if (!WIKI_SLUG_RE.test(slug)) {
|
|
63813
|
-
console.warn(`knowledge-store: skipping non-canonical wiki basename "${slug}" (${(0,
|
|
64004
|
+
console.warn(`knowledge-store: skipping non-canonical wiki basename "${slug}" (${(0, import_node_path31.join)(dir, ent.name)})`);
|
|
63814
64005
|
continue;
|
|
63815
64006
|
}
|
|
63816
|
-
if (onPage(slug, (0,
|
|
64007
|
+
if (onPage(slug, (0, import_node_path31.join)(dir, ent.name))) {
|
|
63817
64008
|
found = true;
|
|
63818
64009
|
return "stop";
|
|
63819
64010
|
}
|
|
@@ -63990,8 +64181,8 @@ function readPage(wikiDir, slug, io = REAL_IO) {
|
|
|
63990
64181
|
if (status === "io-error") throw new KnowledgeError("failed to read the knowledge base", "io-error");
|
|
63991
64182
|
return null;
|
|
63992
64183
|
}
|
|
63993
|
-
const full = (0,
|
|
63994
|
-
if (full !== root5 && !full.startsWith(root5 +
|
|
64184
|
+
const full = (0, import_node_path31.resolve)(found), root5 = (0, import_node_path31.resolve)(wikiDir);
|
|
64185
|
+
if (full !== root5 && !full.startsWith(root5 + import_node_path31.sep)) return null;
|
|
63995
64186
|
const pp = splitPage(full, io);
|
|
63996
64187
|
if (!pp.ok) {
|
|
63997
64188
|
if (pp.reason === "oversize") throw new KnowledgeError("knowledge page too large to serve", "too-large");
|
|
@@ -64073,12 +64264,12 @@ function readKnowledgeSummaries(wikiDir, opts = {}, io = REAL_IO) {
|
|
|
64073
64264
|
truncated
|
|
64074
64265
|
};
|
|
64075
64266
|
}
|
|
64076
|
-
var organizePath = (id) => (0,
|
|
64267
|
+
var organizePath = (id) => (0, import_node_path31.join)(projectKnowledgeDir(id), "organize.json");
|
|
64077
64268
|
function writeOrganizeFile(id, org) {
|
|
64078
64269
|
const dir = projectKnowledgeDir(id);
|
|
64079
64270
|
(0, import_node_fs33.mkdirSync)(dir, { recursive: true });
|
|
64080
64271
|
const dest = organizePath(id);
|
|
64081
|
-
const tmp = (0,
|
|
64272
|
+
const tmp = (0, import_node_path31.join)(dir, `.organize.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
64082
64273
|
(0, import_node_fs33.writeFileSync)(tmp, JSON.stringify(org, null, 2));
|
|
64083
64274
|
(0, import_node_fs33.renameSync)(tmp, dest);
|
|
64084
64275
|
}
|
|
@@ -64187,13 +64378,13 @@ function failOrganize(id, requestId, opts) {
|
|
|
64187
64378
|
function gcOldGenerations(id, currentGenerationId) {
|
|
64188
64379
|
const dir = generationsDir(id);
|
|
64189
64380
|
if (!(0, import_node_fs33.existsSync)(dir)) return;
|
|
64190
|
-
const entries2 = (0, import_node_fs33.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ name: e.name, mtimeMs: (0, import_node_fs33.statSync)((0,
|
|
64381
|
+
const entries2 = (0, import_node_fs33.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ name: e.name, mtimeMs: (0, import_node_fs33.statSync)((0, import_node_path31.join)(dir, e.name)).mtimeMs })).sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
64191
64382
|
const keep = new Set(entries2.slice(0, GEN_KEEP).map((e) => e.name));
|
|
64192
64383
|
keep.add(currentGenerationId);
|
|
64193
64384
|
for (const e of entries2) {
|
|
64194
64385
|
if (keep.has(e.name)) continue;
|
|
64195
64386
|
try {
|
|
64196
|
-
(0, import_node_fs33.rmSync)((0,
|
|
64387
|
+
(0, import_node_fs33.rmSync)((0, import_node_path31.join)(dir, e.name), { recursive: true, force: true });
|
|
64197
64388
|
} catch (err2) {
|
|
64198
64389
|
console.warn(`knowledge-store: could not GC stale generation dir ${e.name}: ${err2 instanceof Error ? err2.message : err2}`);
|
|
64199
64390
|
}
|
|
@@ -65297,8 +65488,8 @@ function viewOf(p, facts) {
|
|
|
65297
65488
|
// project-sources-store.ts
|
|
65298
65489
|
var import_node_crypto19 = require("node:crypto");
|
|
65299
65490
|
var import_node_fs35 = require("node:fs");
|
|
65300
|
-
var
|
|
65301
|
-
var sourcesDir = (id) => (0,
|
|
65491
|
+
var import_node_path32 = require("node:path");
|
|
65492
|
+
var sourcesDir = (id) => (0, import_node_path32.join)(projectDir(id), "sources");
|
|
65302
65493
|
var safeExt = (ext) => typeof ext === "string" && /^[a-z0-9]{1,8}$/i.test(ext) ? ext.toLowerCase() : "bin";
|
|
65303
65494
|
function writeAtomic2(path, buf) {
|
|
65304
65495
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
@@ -65309,7 +65500,7 @@ function saveSource(id, file) {
|
|
|
65309
65500
|
(0, import_node_fs35.mkdirSync)(sourcesDir(id), { recursive: true });
|
|
65310
65501
|
const sha2563 = (0, import_node_crypto19.createHash)("sha256").update(file.buf).digest("hex");
|
|
65311
65502
|
const ext = safeExt(file.ext);
|
|
65312
|
-
const p = (0,
|
|
65503
|
+
const p = (0, import_node_path32.join)(sourcesDir(id), `${sha2563}.${ext}`);
|
|
65313
65504
|
if (!(0, import_node_fs35.existsSync)(p)) writeAtomic2(p, file.buf);
|
|
65314
65505
|
return { name: String(file.name), sha256: sha2563, ext, bytes: file.buf.length };
|
|
65315
65506
|
}
|
|
@@ -67698,10 +67889,15 @@ function lateralHalfExtent(dims, rotDeg, round) {
|
|
|
67698
67889
|
const th = (typeof rotDeg === "number" && isFinite(rotDeg) ? rotDeg : 0) * Math.PI / 180;
|
|
67699
67890
|
return Math.abs(dims.w / 2 * Math.cos(th)) + Math.abs(dims.d / 2 * Math.sin(th));
|
|
67700
67891
|
}
|
|
67892
|
+
function verticalHalfExtent(dims, rotDeg, round) {
|
|
67893
|
+
if (round) return dims.w / 2;
|
|
67894
|
+
const th = (typeof rotDeg === "number" && isFinite(rotDeg) ? rotDeg : 0) * Math.PI / 180;
|
|
67895
|
+
return Math.abs(dims.d / 2 * Math.cos(th)) + Math.abs(dims.w / 2 * Math.sin(th));
|
|
67896
|
+
}
|
|
67701
67897
|
var NO_PLANE_OFFSET = { dx: 0, dy: 0, signed: 0 };
|
|
67702
|
-
function planeOffset(positionH, ax, ay, bx, by, dims, rotDeg
|
|
67898
|
+
function planeOffset(positionH, ax, ay, bx, by, dims, rotDeg) {
|
|
67703
67899
|
const pos2 = planePosition(positionH);
|
|
67704
|
-
if (pos2 === "middle"
|
|
67900
|
+
if (pos2 === "middle") return NO_PLANE_OFFSET;
|
|
67705
67901
|
const planLen = Math.hypot(bx - ax, by - ay);
|
|
67706
67902
|
if (!(planLen >= DEGENERATE_MM)) return NO_PLANE_OFFSET;
|
|
67707
67903
|
const half = lateralHalfExtent(dims, rotDeg, dims.round === true);
|
|
@@ -67909,7 +68105,7 @@ function contractToScene(contractInput) {
|
|
|
67909
68105
|
const ptPerFt = plan.pt_per_ft && plan.pt_per_ft > 0 ? plan.pt_per_ft : 1;
|
|
67910
68106
|
const defaultTosMm = (plan.default_tos ?? 0) * IN_TO_MM2;
|
|
67911
68107
|
for (const m of plan.members ?? []) {
|
|
67912
|
-
const explicit = m.section && typeof m.section.w === "number" && m.section.w > 0 && typeof m.section.d === "number" && m.section.d > 0 ? { w: m.section.w, d: m.section.d, approx: false } : null;
|
|
68108
|
+
const explicit = m.section && typeof m.section.w === "number" && m.section.w > 0 && typeof m.section.d === "number" && m.section.d > 0 ? { w: m.section.w, d: m.section.d, approx: false, round: false } : null;
|
|
67913
68109
|
const stdDims = profileDims(m.profile);
|
|
67914
68110
|
const dims = stdDims ?? explicit;
|
|
67915
68111
|
if (!dims || !Array.isArray(m.wp) || m.wp.length < 2) {
|
|
@@ -67942,9 +68138,10 @@ function contractToScene(contractInput) {
|
|
|
67942
68138
|
const z0 = m.ends?.[0]?.tos != null ? m.ends[0].tos * IN_TO_MM2 : defaultTosMm;
|
|
67943
68139
|
const z1 = m.ends?.[1]?.tos != null ? m.ends[1].tos * IN_TO_MM2 : defaultTosMm;
|
|
67944
68140
|
const pos2 = depthPosition(m.position, Math.abs(z1 - z0), Math.hypot(bx - ax, by - ay), mIsBrace && m.brace?.type === "vertical");
|
|
67945
|
-
const
|
|
68141
|
+
const halfVertical = verticalHalfExtent(dims, m.rot, dims.round === true);
|
|
68142
|
+
const zoff = pos2 === "top" ? -halfVertical : pos2 === "bottom" ? halfVertical : 0;
|
|
67946
68143
|
posOffset = zoff;
|
|
67947
|
-
lat = planeOffset(m.positionH, ax, ay, bx, by, dims, m.rot
|
|
68144
|
+
lat = planeOffset(m.positionH, ax, ay, bx, by, dims, m.rot);
|
|
67948
68145
|
workFrom = [ax + lat.dx, ay + lat.dy, z0];
|
|
67949
68146
|
workTo = [bx + lat.dx, by + lat.dy, z1];
|
|
67950
68147
|
from = [ax + lat.dx, ay + lat.dy, z0 + zoff];
|
|
@@ -68305,7 +68502,7 @@ function sceneFromModel(view) {
|
|
|
68305
68502
|
const beamClears = beamClearances(view.doc.joints);
|
|
68306
68503
|
for (const vm of view.members) {
|
|
68307
68504
|
const m = vm.raw;
|
|
68308
|
-
const explicit = m.section && typeof m.section.w === "number" && m.section.w > 0 && typeof m.section.d === "number" && m.section.d > 0 ? { w: m.section.w, d: m.section.d, approx: false } : null;
|
|
68505
|
+
const explicit = m.section && typeof m.section.w === "number" && m.section.w > 0 && typeof m.section.d === "number" && m.section.d > 0 ? { w: m.section.w, d: m.section.d, approx: false, round: false } : null;
|
|
68309
68506
|
const stdDims = profileDims(m.profile);
|
|
68310
68507
|
const dims = stdDims ?? explicit;
|
|
68311
68508
|
if (!dims) {
|
|
@@ -68338,9 +68535,10 @@ function sceneFromModel(view) {
|
|
|
68338
68535
|
workTo = to;
|
|
68339
68536
|
} else {
|
|
68340
68537
|
const pos2 = depthPosition(m.position, Math.abs(z1 - z0), Math.hypot(bx - ax, by - ay), mIsBrace && braceType === "vertical");
|
|
68341
|
-
const
|
|
68538
|
+
const halfVertical = verticalHalfExtent(dims, m.rot, dims.round === true);
|
|
68539
|
+
const zoff = pos2 === "top" ? -halfVertical : pos2 === "bottom" ? halfVertical : 0;
|
|
68342
68540
|
posOffset = zoff;
|
|
68343
|
-
lat = planeOffset(m.positionH, ax, ay, bx, by, dims, m.rot
|
|
68541
|
+
lat = planeOffset(m.positionH, ax, ay, bx, by, dims, m.rot);
|
|
68344
68542
|
workFrom = [ax + lat.dx, ay + lat.dy, z0];
|
|
68345
68543
|
workTo = [bx + lat.dx, by + lat.dy, z1];
|
|
68346
68544
|
from = [ax + lat.dx, ay + lat.dy, z0 + zoff];
|
|
@@ -69565,7 +69763,7 @@ var import_node_crypto22 = require("node:crypto");
|
|
|
69565
69763
|
|
|
69566
69764
|
// reference-import.ts
|
|
69567
69765
|
var import_node_fs36 = require("node:fs");
|
|
69568
|
-
var
|
|
69766
|
+
var import_node_path33 = require("node:path");
|
|
69569
69767
|
var AGENT2 = "ifc-reference-reader";
|
|
69570
69768
|
var WARN_BYTES = 50 * 1024 * 1024;
|
|
69571
69769
|
var MAX_BYTES5 = 150 * 1024 * 1024;
|
|
@@ -69832,7 +70030,7 @@ var readerChain2 = Promise.resolve();
|
|
|
69832
70030
|
function writeReaderApp2(companionId, command, ifcPath, filter) {
|
|
69833
70031
|
const dir = appPath(companionId);
|
|
69834
70032
|
(0, import_node_fs36.mkdirSync)(dir, { recursive: true });
|
|
69835
|
-
const flo = (0,
|
|
70033
|
+
const flo = (0, import_node_path33.join)(dir, `${companionId}.flo`);
|
|
69836
70034
|
const lines = [
|
|
69837
70035
|
`app: ${companionId}`,
|
|
69838
70036
|
"version: 0.1.0",
|
|
@@ -69942,7 +70140,7 @@ async function readReferenceModel(companionId, ifcPath, opts = {}) {
|
|
|
69942
70140
|
var import_node_crypto21 = require("node:crypto");
|
|
69943
70141
|
var import_node_fs37 = require("node:fs");
|
|
69944
70142
|
var import_promises4 = require("node:stream/promises");
|
|
69945
|
-
var
|
|
70143
|
+
var import_node_path34 = require("node:path");
|
|
69946
70144
|
function insideProject(projectId, relPath) {
|
|
69947
70145
|
const raw = String(relPath ?? "");
|
|
69948
70146
|
const m = raw.match(/^references\/([^/\\]+)$/);
|
|
@@ -69951,24 +70149,24 @@ function insideProject(projectId, relPath) {
|
|
|
69951
70149
|
throw new ReferenceImportError("that reference does not name one of its own files, so it cannot be read or removed");
|
|
69952
70150
|
}
|
|
69953
70151
|
const root5 = realish(projectDir(projectId));
|
|
69954
|
-
const abs = (0,
|
|
69955
|
-
if (realish((0,
|
|
70152
|
+
const abs = (0, import_node_path34.resolve)(root5, REFERENCE_DIR, name);
|
|
70153
|
+
if (realish((0, import_node_path34.join)(root5, REFERENCE_DIR)) !== (0, import_node_path34.resolve)(root5, REFERENCE_DIR)) {
|
|
69956
70154
|
throw new ReferenceImportError("this project\u2019s references folder is a link to somewhere else, so it will not be written to");
|
|
69957
70155
|
}
|
|
69958
|
-
if (!abs.startsWith(root5 +
|
|
70156
|
+
if (!abs.startsWith(root5 + import_node_path34.sep)) {
|
|
69959
70157
|
throw new ReferenceImportError("that reference points outside its project, so it cannot be read or removed");
|
|
69960
70158
|
}
|
|
69961
70159
|
return abs;
|
|
69962
70160
|
}
|
|
69963
70161
|
function realish(p) {
|
|
69964
70162
|
try {
|
|
69965
|
-
return import_node_fs37.realpathSync.native((0,
|
|
70163
|
+
return import_node_fs37.realpathSync.native((0, import_node_path34.resolve)(p));
|
|
69966
70164
|
} catch {
|
|
69967
|
-
return (0,
|
|
70165
|
+
return (0, import_node_path34.resolve)(p);
|
|
69968
70166
|
}
|
|
69969
70167
|
}
|
|
69970
70168
|
var REFERENCE_CACHE_VERSION = 5;
|
|
69971
|
-
var cachePath2 = (projectId, refId2) => (0,
|
|
70169
|
+
var cachePath2 = (projectId, refId2) => (0, import_node_path34.join)(projectDir(projectId), `.floless-refcache-${safeId2(refId2)}.json`);
|
|
69972
70170
|
function safeId2(refId2) {
|
|
69973
70171
|
const s = String(refId2 ?? "").replace(/[^A-Za-z0-9._-]+/g, "_");
|
|
69974
70172
|
if (!s || s === "." || s === "..") throw new ReferenceImportError("that reference has an unusable id");
|
|
@@ -69981,7 +70179,7 @@ async function hashFile(path) {
|
|
|
69981
70179
|
}
|
|
69982
70180
|
function copyOriginal(projectId, relPath, sourceAbs, tag) {
|
|
69983
70181
|
const abs = insideProject(projectId, relPath);
|
|
69984
|
-
(0, import_node_fs37.mkdirSync)((0,
|
|
70182
|
+
(0, import_node_fs37.mkdirSync)((0, import_node_path34.dirname)(abs), { recursive: true });
|
|
69985
70183
|
const tmp = `${abs}.${safeId2(tag)}.part`;
|
|
69986
70184
|
(0, import_node_fs37.copyFileSync)(sourceAbs, tmp);
|
|
69987
70185
|
(0, import_node_fs37.renameSync)(tmp, abs);
|
|
@@ -69989,7 +70187,7 @@ function copyOriginal(projectId, relPath, sourceAbs, tag) {
|
|
|
69989
70187
|
}
|
|
69990
70188
|
function referenceFilesOnDisk(projectId) {
|
|
69991
70189
|
try {
|
|
69992
|
-
return (0, import_node_fs37.readdirSync)((0,
|
|
70190
|
+
return (0, import_node_fs37.readdirSync)((0, import_node_path34.join)(projectDir(projectId), REFERENCE_DIR)).map((f) => `${REFERENCE_DIR}/${f}`);
|
|
69993
70191
|
} catch (e) {
|
|
69994
70192
|
if (e.code === "ENOENT") return [];
|
|
69995
70193
|
throw new ReferenceImportError(
|
|
@@ -70468,8 +70666,8 @@ function registerReferenceRoutes(app, deps) {
|
|
|
70468
70666
|
}
|
|
70469
70667
|
|
|
70470
70668
|
// bom-export.ts
|
|
70471
|
-
var
|
|
70472
|
-
var
|
|
70669
|
+
var import_node_os19 = require("node:os");
|
|
70670
|
+
var import_node_path35 = require("node:path");
|
|
70473
70671
|
|
|
70474
70672
|
// node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
|
|
70475
70673
|
var import_node_fs38 = __toESM(require("node:fs"), 1);
|
|
@@ -73869,8 +74067,8 @@ var BOM_EXPORT_KIND = {
|
|
|
73869
74067
|
html: "bom-html"
|
|
73870
74068
|
};
|
|
73871
74069
|
function bomExportPath(appId, format) {
|
|
73872
|
-
const root5 = process.env.FLOLESS_HOME ?? (0,
|
|
73873
|
-
return (0,
|
|
74070
|
+
const root5 = process.env.FLOLESS_HOME ?? (0, import_node_path35.join)((0, import_node_os19.homedir)(), ".floless");
|
|
74071
|
+
return (0, import_node_path35.join)(root5, "exports", appId, `${appId}-bom.${format}`);
|
|
73874
74072
|
}
|
|
73875
74073
|
function csvField(v) {
|
|
73876
74074
|
let s = String(v);
|
|
@@ -74233,7 +74431,7 @@ function replyLifecycleLockBusyError(error, logger, reply) {
|
|
|
74233
74431
|
|
|
74234
74432
|
// project-export-files.ts
|
|
74235
74433
|
var import_node_fs39 = require("node:fs");
|
|
74236
|
-
var
|
|
74434
|
+
var import_node_path36 = require("node:path");
|
|
74237
74435
|
function projectExportFiles(appId, kindOf2 = appId) {
|
|
74238
74436
|
if (kindOf2 === "vectorize") {
|
|
74239
74437
|
return [{ kind: "svg", filename: `${appId}.svg` }];
|
|
@@ -74262,12 +74460,12 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
|
|
|
74262
74460
|
}
|
|
74263
74461
|
function uniqueProjectExportFilename(projectId, preferred) {
|
|
74264
74462
|
const dir = projectExportsDir(projectId);
|
|
74265
|
-
if (!(0, import_node_fs39.existsSync)((0,
|
|
74266
|
-
const extension = (0,
|
|
74463
|
+
if (!(0, import_node_fs39.existsSync)((0, import_node_path36.join)(dir, preferred))) return preferred;
|
|
74464
|
+
const extension = (0, import_node_path36.extname)(preferred);
|
|
74267
74465
|
const stem = preferred.slice(0, preferred.length - extension.length);
|
|
74268
74466
|
for (let suffix = 2; suffix <= 9999; suffix += 1) {
|
|
74269
74467
|
const candidate = `${stem}-${suffix}${extension}`;
|
|
74270
|
-
if (!(0, import_node_fs39.existsSync)((0,
|
|
74468
|
+
if (!(0, import_node_fs39.existsSync)((0, import_node_path36.join)(dir, candidate))) return candidate;
|
|
74271
74469
|
}
|
|
74272
74470
|
throw new Error("could not allocate a unique project export filename");
|
|
74273
74471
|
}
|
|
@@ -75018,7 +75216,7 @@ function buildApprovalReview(input) {
|
|
|
75018
75216
|
// working-revision-manifest.ts
|
|
75019
75217
|
var import_node_crypto24 = require("node:crypto");
|
|
75020
75218
|
var import_node_fs41 = require("node:fs");
|
|
75021
|
-
var
|
|
75219
|
+
var import_node_path37 = require("node:path");
|
|
75022
75220
|
|
|
75023
75221
|
// write-json-atomic.ts
|
|
75024
75222
|
var import_node_crypto23 = require("node:crypto");
|
|
@@ -75030,7 +75228,7 @@ function writeJsonAtomic(path, value) {
|
|
|
75030
75228
|
}
|
|
75031
75229
|
|
|
75032
75230
|
// working-revision-manifest.ts
|
|
75033
|
-
var pathOf = (projectId) => (0,
|
|
75231
|
+
var pathOf = (projectId) => (0, import_node_path37.join)(projectDir(projectId), ".floless-working-revision-state-v1.json");
|
|
75034
75232
|
var checksumOf = (body) => hashOf(body);
|
|
75035
75233
|
function bodyOf(value) {
|
|
75036
75234
|
const { checksum: _checksum, ...body } = value;
|
|
@@ -75331,13 +75529,13 @@ function projectApprovalCandidateAccepted(appId, projectId, candidate) {
|
|
|
75331
75529
|
// project-checkpoints-store.ts
|
|
75332
75530
|
var import_node_crypto25 = require("node:crypto");
|
|
75333
75531
|
var import_node_fs42 = require("node:fs");
|
|
75334
|
-
var
|
|
75532
|
+
var import_node_path38 = require("node:path");
|
|
75335
75533
|
var HASH_RE2 = /^[0-9a-f]{64}$/;
|
|
75336
75534
|
function root4(projectId) {
|
|
75337
|
-
return (0,
|
|
75535
|
+
return (0, import_node_path38.join)(projectDir(projectId), ".floless-checkpoints-store-v1");
|
|
75338
75536
|
}
|
|
75339
|
-
var objectsDir2 = (projectId) => (0,
|
|
75340
|
-
var eventsPath = (projectId) => (0,
|
|
75537
|
+
var objectsDir2 = (projectId) => (0, import_node_path38.join)(root4(projectId), "objects");
|
|
75538
|
+
var eventsPath = (projectId) => (0, import_node_path38.join)(root4(projectId), "events.json");
|
|
75341
75539
|
function readEvents(projectId) {
|
|
75342
75540
|
try {
|
|
75343
75541
|
const parsed = JSON.parse((0, import_node_fs42.readFileSync)(eventsPath(projectId), "utf8"));
|
|
@@ -75355,7 +75553,7 @@ function validEvent(value) {
|
|
|
75355
75553
|
function readContent(projectId, id) {
|
|
75356
75554
|
if (!HASH_RE2.test(id)) return null;
|
|
75357
75555
|
try {
|
|
75358
|
-
const value = JSON.parse((0, import_node_fs42.readFileSync)((0,
|
|
75556
|
+
const value = JSON.parse((0, import_node_fs42.readFileSync)((0, import_node_path38.join)(objectsDir2(projectId), `${id}.json`), "utf8"));
|
|
75359
75557
|
if (value?.schema !== 1 || value.id !== id || hashCheckpoint(value) !== id) return null;
|
|
75360
75558
|
return value;
|
|
75361
75559
|
} catch {
|
|
@@ -75390,7 +75588,7 @@ function captureProjectCheckpoint(input) {
|
|
|
75390
75588
|
};
|
|
75391
75589
|
const id = hashCheckpoint(withoutId);
|
|
75392
75590
|
(0, import_node_fs42.mkdirSync)(objectsDir2(input.project.id), { recursive: true });
|
|
75393
|
-
const path = (0,
|
|
75591
|
+
const path = (0, import_node_path38.join)(objectsDir2(input.project.id), `${id}.json`);
|
|
75394
75592
|
if (!(0, import_node_fs42.existsSync)(path)) writeJsonAtomic(path, { ...withoutId, id });
|
|
75395
75593
|
const event = appendEvent(input.project.id, {
|
|
75396
75594
|
checkpointId: id,
|
|
@@ -75435,15 +75633,15 @@ function markProjectCheckpoint(project, checkpointId, kind, expectedEventId) {
|
|
|
75435
75633
|
// export-source.ts
|
|
75436
75634
|
var import_node_crypto26 = require("node:crypto");
|
|
75437
75635
|
var import_node_fs43 = require("node:fs");
|
|
75438
|
-
var
|
|
75439
|
-
var
|
|
75636
|
+
var import_node_os20 = require("node:os");
|
|
75637
|
+
var import_node_path39 = require("node:path");
|
|
75440
75638
|
var HANDLE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
75441
75639
|
var MAX_STORED_HANDLES = 512;
|
|
75442
75640
|
function storeRoot() {
|
|
75443
|
-
const root5 = process.env.FLOLESS_HOME ?? (0,
|
|
75444
|
-
return (0,
|
|
75641
|
+
const root5 = process.env.FLOLESS_HOME ?? (0, import_node_path39.join)((0, import_node_os20.homedir)(), ".floless");
|
|
75642
|
+
return (0, import_node_path39.join)(root5, ".floless-export-handles-v1");
|
|
75445
75643
|
}
|
|
75446
|
-
var handlePath = (id) => (0,
|
|
75644
|
+
var handlePath = (id) => (0, import_node_path39.join)(storeRoot(), `${id}.json`);
|
|
75447
75645
|
function withoutChecksum(value) {
|
|
75448
75646
|
const { checksum: _checksum, ...body } = value;
|
|
75449
75647
|
return body;
|
|
@@ -75635,7 +75833,7 @@ function collectExpiredExportHandles(now = Date.now()) {
|
|
|
75635
75833
|
// file-publication.ts
|
|
75636
75834
|
var import_node_crypto27 = require("node:crypto");
|
|
75637
75835
|
var import_node_fs44 = require("node:fs");
|
|
75638
|
-
var
|
|
75836
|
+
var import_node_path40 = require("node:path");
|
|
75639
75837
|
var FilePublicationError = class extends Error {
|
|
75640
75838
|
constructor(message, code, paths = []) {
|
|
75641
75839
|
super(message);
|
|
@@ -75662,9 +75860,9 @@ function fileProofEquals2(a, b) {
|
|
|
75662
75860
|
return a === null || b === null ? a === b : a.bytes === b.bytes && a.sha256 === b.sha256;
|
|
75663
75861
|
}
|
|
75664
75862
|
function durableCanonicalJson(path, value) {
|
|
75665
|
-
const dir = (0,
|
|
75863
|
+
const dir = (0, import_node_path40.dirname)(path);
|
|
75666
75864
|
(0, import_node_fs44.mkdirSync)(dir, { recursive: true });
|
|
75667
|
-
const temp = (0,
|
|
75865
|
+
const temp = (0, import_node_path40.join)(dir, `.${(0, import_node_path40.basename)(path)}.${process.pid}.${(0, import_node_crypto27.randomUUID)()}.tmp`);
|
|
75668
75866
|
try {
|
|
75669
75867
|
(0, import_node_fs44.writeFileSync)(temp, `${canonicalJson(value)}
|
|
75670
75868
|
`, { encoding: "utf8", flag: "wx" });
|
|
@@ -75711,11 +75909,11 @@ function assertSameVolume(a, b) {
|
|
|
75711
75909
|
}
|
|
75712
75910
|
function uniqueArtifact(dir, label2, livePath) {
|
|
75713
75911
|
(0, import_node_fs44.mkdirSync)(dir, { recursive: true });
|
|
75714
|
-
return (0,
|
|
75912
|
+
return (0, import_node_path40.join)(dir, `.floless-${label2}-${(0, import_node_crypto27.randomUUID)()}-${(0, import_node_path40.basename)(livePath)}`);
|
|
75715
75913
|
}
|
|
75716
75914
|
function publishFileExclusive(input) {
|
|
75717
75915
|
const { livePath, stagedPath, expectedLive, artifactDir } = input;
|
|
75718
|
-
assertSameVolume(stagedPath, (0, import_node_fs44.existsSync)(livePath) ? livePath : (0,
|
|
75916
|
+
assertSameVolume(stagedPath, (0, import_node_fs44.existsSync)(livePath) ? livePath : (0, import_node_path40.dirname)(livePath));
|
|
75719
75917
|
const stagedProof = readFileProof2(stagedPath);
|
|
75720
75918
|
if (!stagedProof) throw new FilePublicationError("staged publication file is missing", "io-failure", [stagedPath]);
|
|
75721
75919
|
let beforeImage = null;
|
|
@@ -75744,7 +75942,7 @@ function publishFileExclusive(input) {
|
|
|
75744
75942
|
(0, import_node_fs44.unlinkSync)(stagedPath);
|
|
75745
75943
|
input.onFaultPoint?.("after-staged-unlink", { livePath, stagedPath, beforeImage });
|
|
75746
75944
|
syncFile(livePath);
|
|
75747
|
-
syncDirectoryBestEffort((0,
|
|
75945
|
+
syncDirectoryBestEffort((0, import_node_path40.dirname)(livePath));
|
|
75748
75946
|
} catch (error) {
|
|
75749
75947
|
if (beforeImage && !(0, import_node_fs44.existsSync)(livePath)) {
|
|
75750
75948
|
try {
|
|
@@ -75766,12 +75964,12 @@ function publishFileExclusive(input) {
|
|
|
75766
75964
|
}
|
|
75767
75965
|
|
|
75768
75966
|
// app-publication-guard.ts
|
|
75769
|
-
var
|
|
75967
|
+
var import_node_path42 = require("node:path");
|
|
75770
75968
|
|
|
75771
75969
|
// app-source-lock.ts
|
|
75772
75970
|
var import_node_fs45 = require("node:fs");
|
|
75773
|
-
var
|
|
75774
|
-
var
|
|
75971
|
+
var import_node_os21 = require("node:os");
|
|
75972
|
+
var import_node_path41 = require("node:path");
|
|
75775
75973
|
var AppSourcePublicationBusyError = class extends Error {
|
|
75776
75974
|
status = 409;
|
|
75777
75975
|
constructor() {
|
|
@@ -75780,8 +75978,8 @@ var AppSourcePublicationBusyError = class extends Error {
|
|
|
75780
75978
|
}
|
|
75781
75979
|
};
|
|
75782
75980
|
function activeApprovalTransaction(appId) {
|
|
75783
|
-
const home = process.env.AWARE_HOME || (0,
|
|
75784
|
-
const path = (0,
|
|
75981
|
+
const home = process.env.AWARE_HOME || (0, import_node_path41.join)((0, import_node_os21.homedir)(), ".aware");
|
|
75982
|
+
const path = (0, import_node_path41.join)(home, "apps", appId, ".floless-approval-publication-journal-v1.json");
|
|
75785
75983
|
if (!(0, import_node_fs45.existsSync)(path)) return null;
|
|
75786
75984
|
try {
|
|
75787
75985
|
const stored2 = JSON.parse((0, import_node_fs45.readFileSync)(path, "utf8"));
|
|
@@ -75962,7 +76160,7 @@ var AppPublicationGuardError = class extends Error {
|
|
|
75962
76160
|
function assertTarget(target) {
|
|
75963
76161
|
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(target.appId)) throw new Error(`invalid app publication id: ${target.appId}`);
|
|
75964
76162
|
for (const path of [target.sourcePath, target.lockPath, target.manifestPath]) {
|
|
75965
|
-
if (!(0,
|
|
76163
|
+
if (!(0, import_node_path42.isAbsolute)(path) || !(0, import_node_path42.resolve)(path)) throw new Error("app publication paths must be absolute/resolvable");
|
|
75966
76164
|
}
|
|
75967
76165
|
}
|
|
75968
76166
|
async function underAppLock(input) {
|
|
@@ -76039,17 +76237,17 @@ function withAppPublicationWhileProjectLocked(input) {
|
|
|
76039
76237
|
// approval-app-publication.ts
|
|
76040
76238
|
var import_node_crypto29 = require("node:crypto");
|
|
76041
76239
|
var import_node_fs47 = require("node:fs");
|
|
76042
|
-
var
|
|
76240
|
+
var import_node_path43 = require("node:path");
|
|
76043
76241
|
var JOURNAL = ".floless-approval-publication-journal-v1.json";
|
|
76044
76242
|
var MANIFEST = ".floless-app-publication-state-v1.json";
|
|
76045
|
-
var approvalPublicationJournalPath = (sourcePath) => (0,
|
|
76046
|
-
var approvalPublicationManifestPath = (sourcePath) => (0,
|
|
76243
|
+
var approvalPublicationJournalPath = (sourcePath) => (0, import_node_path43.join)((0, import_node_path43.dirname)(sourcePath), JOURNAL);
|
|
76244
|
+
var approvalPublicationManifestPath = (sourcePath) => (0, import_node_path43.join)((0, import_node_path43.dirname)(sourcePath), MANIFEST);
|
|
76047
76245
|
function stagingRoot2(sourcePath) {
|
|
76048
|
-
return (0,
|
|
76246
|
+
return (0, import_node_path43.join)((0, import_node_path43.dirname)((0, import_node_path43.dirname)((0, import_node_path43.dirname)(sourcePath))), ".floless-approval-publications-v1");
|
|
76049
76247
|
}
|
|
76050
76248
|
function assertContained(root5, path) {
|
|
76051
|
-
const rel = (0,
|
|
76052
|
-
if (!rel || rel.startsWith("..") || (0,
|
|
76249
|
+
const rel = (0, import_node_path43.relative)((0, import_node_path43.resolve)(root5), (0, import_node_path43.resolve)(path));
|
|
76250
|
+
if (!rel || rel.startsWith("..") || (0, import_node_path43.isAbsolute)(rel)) throw new Error("approval publication path escaped its staging root");
|
|
76053
76251
|
}
|
|
76054
76252
|
function validProof2(value) {
|
|
76055
76253
|
if (value === null) return true;
|
|
@@ -76068,8 +76266,8 @@ function readApprovalPublicationJournal(sourcePath) {
|
|
|
76068
76266
|
const stored2 = JSON.parse((0, import_node_fs47.readFileSync)(approvalPublicationJournalPath(sourcePath), "utf8"));
|
|
76069
76267
|
const value = stored2?.journal;
|
|
76070
76268
|
const expectedLiveLock = sourcePath.replace(/\.[^.]+$/, ".lock");
|
|
76071
|
-
const expectedStageDir = (0,
|
|
76072
|
-
if (!value || stored2.checksum !== hashOf(value) || value.schema !== 1 || (0,
|
|
76269
|
+
const expectedStageDir = (0, import_node_path43.join)(stagingRoot2(sourcePath), `${value?.appId ?? ""}-${value?.id ?? ""}`);
|
|
76270
|
+
if (!value || stored2.checksum !== hashOf(value) || value.schema !== 1 || (0, import_node_path43.resolve)(value.liveSourcePath) !== (0, import_node_path43.resolve)(sourcePath) || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(value.appId) || !/^[a-f0-9-]{36}$/i.test(value.id) || !value.projectId || value.phase !== "staged" && value.phase !== "authorized" && value.phase !== "published" || (0, import_node_path43.resolve)(value.liveLockPath) !== (0, import_node_path43.resolve)(expectedLiveLock) || (0, import_node_path43.resolve)(value.stageDir) !== (0, import_node_path43.resolve)(expectedStageDir) || (0, import_node_path43.resolve)(value.stagedSourcePath) !== (0, import_node_path43.resolve)(value.stageDir, "app", (0, import_node_path43.basename)(sourcePath)) || (0, import_node_path43.resolve)(value.stagedLockPath) !== (0, import_node_path43.resolve)(value.stageDir, "app", (0, import_node_path43.basename)(expectedLiveLock)) || (0, import_node_path43.resolve)(value.artifactDir) !== (0, import_node_path43.resolve)(value.stageDir, "artifacts") || !validProof2(value.beforeSource) || !validProof2(value.beforeLock) || !validProof2(value.stagedSource) || value.stagedSource === null || !validProof2(value.stagedLock) || value.stagedLock === null) return null;
|
|
76073
76271
|
assertContained(stagingRoot2(sourcePath), value.stageDir);
|
|
76074
76272
|
assertContained(value.stageDir, value.stagedSourcePath);
|
|
76075
76273
|
assertContained(value.stageDir, value.stagedLockPath);
|
|
@@ -76080,10 +76278,10 @@ function readApprovalPublicationJournal(sourcePath) {
|
|
|
76080
76278
|
}
|
|
76081
76279
|
}
|
|
76082
76280
|
async function stageApprovalPublication(input) {
|
|
76083
|
-
const appRoot = (0,
|
|
76281
|
+
const appRoot = (0, import_node_path43.dirname)(input.sourcePath);
|
|
76084
76282
|
const id = (0, import_node_crypto29.randomUUID)();
|
|
76085
|
-
const stageDir = (0,
|
|
76086
|
-
const stagedAppRoot = (0,
|
|
76283
|
+
const stageDir = (0, import_node_path43.join)(stagingRoot2(input.sourcePath), `${input.appId}-${id}`);
|
|
76284
|
+
const stagedAppRoot = (0, import_node_path43.join)(stageDir, "app");
|
|
76087
76285
|
let stagedSourcePath = "";
|
|
76088
76286
|
let stagedLockPath = "";
|
|
76089
76287
|
let stagedSource = null;
|
|
@@ -76094,9 +76292,9 @@ async function stageApprovalPublication(input) {
|
|
|
76094
76292
|
(0, import_node_fs47.mkdirSync)(stageDir, { recursive: true });
|
|
76095
76293
|
(0, import_node_fs47.cpSync)(appRoot, stagedAppRoot, {
|
|
76096
76294
|
recursive: true,
|
|
76097
|
-
filter: (path) => ![JOURNAL, MANIFEST].includes((0,
|
|
76295
|
+
filter: (path) => ![JOURNAL, MANIFEST].includes((0, import_node_path43.basename)(path))
|
|
76098
76296
|
});
|
|
76099
|
-
stagedSourcePath = (0,
|
|
76297
|
+
stagedSourcePath = (0, import_node_path43.join)(stagedAppRoot, (0, import_node_path43.relative)(appRoot, input.sourcePath));
|
|
76100
76298
|
stagedLockPath = await input.build(stagedSourcePath);
|
|
76101
76299
|
stagedSource = readFileProof2(stagedSourcePath);
|
|
76102
76300
|
stagedLock = readFileProof2(stagedLockPath);
|
|
@@ -76118,7 +76316,7 @@ async function stageApprovalPublication(input) {
|
|
|
76118
76316
|
stagedSourcePath,
|
|
76119
76317
|
stagedLockPath,
|
|
76120
76318
|
stageDir,
|
|
76121
|
-
artifactDir: (0,
|
|
76319
|
+
artifactDir: (0, import_node_path43.join)(stageDir, "artifacts"),
|
|
76122
76320
|
beforeSource,
|
|
76123
76321
|
beforeLock,
|
|
76124
76322
|
stagedSource,
|
|
@@ -76537,13 +76735,13 @@ function registerMigrationCommitRoute(app, deps) {
|
|
|
76537
76735
|
|
|
76538
76736
|
// workspace-agent-manifest.ts
|
|
76539
76737
|
var import_node_fs49 = require("node:fs");
|
|
76540
|
-
var
|
|
76541
|
-
var
|
|
76738
|
+
var import_node_os22 = require("node:os");
|
|
76739
|
+
var import_node_path44 = require("node:path");
|
|
76542
76740
|
function awareHome() {
|
|
76543
|
-
return process.env.AWARE_HOME || (0,
|
|
76741
|
+
return process.env.AWARE_HOME || (0, import_node_path44.join)((0, import_node_os22.homedir)(), ".aware");
|
|
76544
76742
|
}
|
|
76545
76743
|
function workspaceAgentDir() {
|
|
76546
|
-
return (0,
|
|
76744
|
+
return (0, import_node_path44.join)(awareHome(), "agents", "floless-workspace");
|
|
76547
76745
|
}
|
|
76548
76746
|
function syncWorkspaceAgentManifest(port) {
|
|
76549
76747
|
const dir = workspaceAgentDir();
|
|
@@ -76691,7 +76889,7 @@ commands:
|
|
|
76691
76889
|
headers: object
|
|
76692
76890
|
body: object
|
|
76693
76891
|
`;
|
|
76694
|
-
const path = (0,
|
|
76892
|
+
const path = (0, import_node_path44.join)(dir, "manifest.yaml");
|
|
76695
76893
|
if (!(0, import_node_fs49.existsSync)(path) || manifest !== "") (0, import_node_fs49.writeFileSync)(path, manifest, "utf8");
|
|
76696
76894
|
return path;
|
|
76697
76895
|
}
|
|
@@ -78303,7 +78501,7 @@ function awareFailureMessage(e, fallback2) {
|
|
|
78303
78501
|
|
|
78304
78502
|
// scene-bake.ts
|
|
78305
78503
|
var import_node_fs51 = require("node:fs");
|
|
78306
|
-
var
|
|
78504
|
+
var import_node_path45 = require("node:path");
|
|
78307
78505
|
var import_yaml9 = __toESM(require_dist6(), 1);
|
|
78308
78506
|
function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
78309
78507
|
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs51.readFileSync)(sourcePath, "utf8"));
|
|
@@ -78331,7 +78529,7 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
|
78331
78529
|
}
|
|
78332
78530
|
function writeViewer3dApp(dir, appId, scene) {
|
|
78333
78531
|
(0, import_node_fs51.mkdirSync)(dir, { recursive: true });
|
|
78334
|
-
const flo = (0,
|
|
78532
|
+
const flo = (0, import_node_path45.join)(dir, `${appId}.flo`);
|
|
78335
78533
|
(0, import_node_fs51.writeFileSync)(flo, [
|
|
78336
78534
|
`app: ${appId}`,
|
|
78337
78535
|
"version: 0.1.0",
|
|
@@ -78362,7 +78560,7 @@ function isCompanionApp(flo) {
|
|
|
78362
78560
|
}
|
|
78363
78561
|
function writeBomReportApp(dir, appId, table) {
|
|
78364
78562
|
(0, import_node_fs51.mkdirSync)(dir, { recursive: true });
|
|
78365
|
-
const flo = (0,
|
|
78563
|
+
const flo = (0, import_node_path45.join)(dir, `${appId}.flo`);
|
|
78366
78564
|
if (!isCompanionApp(flo)) {
|
|
78367
78565
|
throw new Error(`refusing to overwrite "${appId}": an app of that name exists and FloLess did not write it`);
|
|
78368
78566
|
}
|
|
@@ -78394,7 +78592,7 @@ function writeBomReportApp(dir, appId, table) {
|
|
|
78394
78592
|
}
|
|
78395
78593
|
function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
78396
78594
|
(0, import_node_fs51.mkdirSync)(dir, { recursive: true });
|
|
78397
|
-
const flo = (0,
|
|
78595
|
+
const flo = (0, import_node_path45.join)(dir, `${appId}.flo`);
|
|
78398
78596
|
(0, import_node_fs51.writeFileSync)(flo, [
|
|
78399
78597
|
`app: ${appId}`,
|
|
78400
78598
|
"version: 0.1.0",
|
|
@@ -78430,7 +78628,7 @@ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
|
78430
78628
|
}
|
|
78431
78629
|
function writeSketchupApp(dir, appId, scene) {
|
|
78432
78630
|
(0, import_node_fs51.mkdirSync)(dir, { recursive: true });
|
|
78433
|
-
const flo = (0,
|
|
78631
|
+
const flo = (0, import_node_path45.join)(dir, `${appId}.flo`);
|
|
78434
78632
|
(0, import_node_fs51.writeFileSync)(flo, [
|
|
78435
78633
|
`app: ${appId}`,
|
|
78436
78634
|
"version: 0.1.0",
|
|
@@ -78459,7 +78657,7 @@ function writeSketchupApp(dir, appId, scene) {
|
|
|
78459
78657
|
}
|
|
78460
78658
|
function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
78461
78659
|
(0, import_node_fs51.mkdirSync)(dir, { recursive: true });
|
|
78462
|
-
const flo = (0,
|
|
78660
|
+
const flo = (0, import_node_path45.join)(dir, `${appId}.flo`);
|
|
78463
78661
|
const exactRhinoId = typeof rhinoId === "string" && rhinoId.trim() ? rhinoId.trim() : null;
|
|
78464
78662
|
(0, import_node_fs51.writeFileSync)(flo, [
|
|
78465
78663
|
`app: ${appId}`,
|
|
@@ -78489,7 +78687,7 @@ function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
|
78489
78687
|
}
|
|
78490
78688
|
function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
|
|
78491
78689
|
(0, import_node_fs51.mkdirSync)(dir, { recursive: true });
|
|
78492
|
-
const flo = (0,
|
|
78690
|
+
const flo = (0, import_node_path45.join)(dir, `${appId}.flo`);
|
|
78493
78691
|
(0, import_node_fs51.writeFileSync)(flo, [
|
|
78494
78692
|
`app: ${appId}`,
|
|
78495
78693
|
"version: 0.1.0",
|
|
@@ -78655,7 +78853,7 @@ async function teklaVersionToBake() {
|
|
|
78655
78853
|
// export-companion.ts
|
|
78656
78854
|
var import_node_crypto30 = require("node:crypto");
|
|
78657
78855
|
var import_node_fs52 = require("node:fs");
|
|
78658
|
-
var
|
|
78856
|
+
var import_node_path46 = require("node:path");
|
|
78659
78857
|
var PREFIX = "floless-export-tmp-";
|
|
78660
78858
|
var LEASE = ".floless-export-lease.json";
|
|
78661
78859
|
var STALE_MS2 = 30 * 6e4;
|
|
@@ -78669,12 +78867,12 @@ function processAlive2(pid) {
|
|
|
78669
78867
|
}
|
|
78670
78868
|
}
|
|
78671
78869
|
function defaultAppsRoot() {
|
|
78672
|
-
return (0,
|
|
78870
|
+
return (0, import_node_path46.dirname)(appPath("placeholder"));
|
|
78673
78871
|
}
|
|
78674
78872
|
function assertScratchPath(path, appsRoot) {
|
|
78675
|
-
const root5 = (0,
|
|
78676
|
-
const target = (0,
|
|
78677
|
-
if ((0,
|
|
78873
|
+
const root5 = (0, import_node_path46.resolve)(appsRoot);
|
|
78874
|
+
const target = (0, import_node_path46.resolve)(path);
|
|
78875
|
+
if ((0, import_node_path46.dirname)(target) !== root5 || !(0, import_node_path46.basename)(target).startsWith(PREFIX)) {
|
|
78678
78876
|
throw new Error(`refusing to remove a non-export companion path: ${target}`);
|
|
78679
78877
|
}
|
|
78680
78878
|
}
|
|
@@ -78686,8 +78884,8 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
78686
78884
|
const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
|
|
78687
78885
|
const token2 = (0, import_node_crypto30.randomUUID)();
|
|
78688
78886
|
const id = `${PREFIX}${safeOwner}-${sink}-${token2}`;
|
|
78689
|
-
const root5 = (0,
|
|
78690
|
-
const path = (0,
|
|
78887
|
+
const root5 = (0, import_node_path46.resolve)(appsRoot);
|
|
78888
|
+
const path = (0, import_node_path46.resolve)(root5, id);
|
|
78691
78889
|
return {
|
|
78692
78890
|
id,
|
|
78693
78891
|
path,
|
|
@@ -78696,7 +78894,7 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
78696
78894
|
if (!(0, import_node_fs52.existsSync)(path)) return;
|
|
78697
78895
|
let current = null;
|
|
78698
78896
|
try {
|
|
78699
|
-
current = JSON.parse((0, import_node_fs52.readFileSync)((0,
|
|
78897
|
+
current = JSON.parse((0, import_node_fs52.readFileSync)((0, import_node_path46.resolve)(path, LEASE), "utf8"));
|
|
78700
78898
|
} catch {
|
|
78701
78899
|
}
|
|
78702
78900
|
if (current && current.token !== token2) throw new Error(`export companion lease changed for ${id}`);
|
|
@@ -78705,22 +78903,22 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
78705
78903
|
};
|
|
78706
78904
|
}
|
|
78707
78905
|
function stampExportCompanionLease(companion2) {
|
|
78708
|
-
(0, import_node_fs52.writeFileSync)((0,
|
|
78906
|
+
(0, import_node_fs52.writeFileSync)((0, import_node_path46.resolve)(companion2.path, LEASE), JSON.stringify({
|
|
78709
78907
|
pid: process.pid,
|
|
78710
78908
|
token: companion2.token,
|
|
78711
78909
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
78712
78910
|
}));
|
|
78713
78911
|
}
|
|
78714
78912
|
function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
|
|
78715
|
-
const root5 = (0,
|
|
78913
|
+
const root5 = (0, import_node_path46.resolve)(appsRoot);
|
|
78716
78914
|
if (!(0, import_node_fs52.existsSync)(root5)) return [];
|
|
78717
78915
|
const removed = [];
|
|
78718
78916
|
for (const entry2 of (0, import_node_fs52.readdirSync)(root5, { withFileTypes: true })) {
|
|
78719
78917
|
if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
|
|
78720
|
-
const path = (0,
|
|
78918
|
+
const path = (0, import_node_path46.resolve)(root5, entry2.name);
|
|
78721
78919
|
let lease = null;
|
|
78722
78920
|
try {
|
|
78723
|
-
lease = JSON.parse((0, import_node_fs52.readFileSync)((0,
|
|
78921
|
+
lease = JSON.parse((0, import_node_fs52.readFileSync)((0, import_node_path46.resolve)(path, LEASE), "utf8"));
|
|
78724
78922
|
} catch {
|
|
78725
78923
|
}
|
|
78726
78924
|
let created;
|
|
@@ -79300,8 +79498,8 @@ function looksLikeHostUnavailable(host, ...messages) {
|
|
|
79300
79498
|
|
|
79301
79499
|
// render-readiness.ts
|
|
79302
79500
|
var import_node_fs53 = require("node:fs");
|
|
79303
|
-
var
|
|
79304
|
-
var
|
|
79501
|
+
var import_node_path47 = require("node:path");
|
|
79502
|
+
var import_node_os23 = require("node:os");
|
|
79305
79503
|
var RENDER_AWARE_FLOOR = "0.103.0";
|
|
79306
79504
|
var RENDER_AGENT_ID = "blender";
|
|
79307
79505
|
function isFile(path) {
|
|
@@ -79314,9 +79512,9 @@ function isFile(path) {
|
|
|
79314
79512
|
function lookupOnPath(command, env2) {
|
|
79315
79513
|
const path = env2.PATH ?? env2.Path;
|
|
79316
79514
|
if (!path) return null;
|
|
79317
|
-
for (const dir of path.split(
|
|
79515
|
+
for (const dir of path.split(import_node_path47.delimiter)) {
|
|
79318
79516
|
if (!dir) continue;
|
|
79319
|
-
const candidate = (0,
|
|
79517
|
+
const candidate = (0, import_node_path47.join)(dir, command);
|
|
79320
79518
|
if (isFile(candidate)) return candidate;
|
|
79321
79519
|
}
|
|
79322
79520
|
return null;
|
|
@@ -79333,7 +79531,7 @@ function windowsCandidates(env2) {
|
|
|
79333
79531
|
for (const variable of ["ProgramFiles", "ProgramW6432", "ProgramFiles(x86)"]) {
|
|
79334
79532
|
const value = env2[variable];
|
|
79335
79533
|
if (!value) continue;
|
|
79336
|
-
const root5 = (0,
|
|
79534
|
+
const root5 = (0, import_node_path47.join)(value, "Blender Foundation");
|
|
79337
79535
|
if (!roots.includes(root5)) roots.push(root5);
|
|
79338
79536
|
}
|
|
79339
79537
|
const found = [];
|
|
@@ -79347,7 +79545,7 @@ function windowsCandidates(env2) {
|
|
|
79347
79545
|
for (const name of entries2) {
|
|
79348
79546
|
const match = /^Blender\s+(\d+(?:\.\d+)*)$/i.exec(name);
|
|
79349
79547
|
if (!match) continue;
|
|
79350
|
-
const binary = (0,
|
|
79548
|
+
const binary = (0, import_node_path47.join)(root5, name, "blender.exe");
|
|
79351
79549
|
if (isFile(binary)) {
|
|
79352
79550
|
found.push({ version: match[1].split(".").map(Number), name, binary });
|
|
79353
79551
|
}
|
|
@@ -79361,7 +79559,7 @@ function platformDefaults(env2, isWin3) {
|
|
|
79361
79559
|
if (process.platform === "darwin") {
|
|
79362
79560
|
return [
|
|
79363
79561
|
"/Applications/Blender.app/Contents/MacOS/Blender",
|
|
79364
|
-
(0,
|
|
79562
|
+
(0, import_node_path47.join)((0, import_node_os23.homedir)(), "Applications/Blender.app/Contents/MacOS/Blender")
|
|
79365
79563
|
];
|
|
79366
79564
|
}
|
|
79367
79565
|
return ["/usr/bin/blender", "/usr/local/bin/blender", "/snap/bin/blender"];
|
|
@@ -79520,19 +79718,19 @@ function nothingToApprove(contract) {
|
|
|
79520
79718
|
|
|
79521
79719
|
// app-lifecycle.ts
|
|
79522
79720
|
var import_node_fs56 = require("node:fs");
|
|
79523
|
-
var
|
|
79524
|
-
var
|
|
79721
|
+
var import_node_os25 = require("node:os");
|
|
79722
|
+
var import_node_path50 = require("node:path");
|
|
79525
79723
|
|
|
79526
79724
|
// routines.ts
|
|
79527
79725
|
var import_node_fs55 = require("node:fs");
|
|
79528
|
-
var
|
|
79726
|
+
var import_node_path49 = require("node:path");
|
|
79529
79727
|
|
|
79530
79728
|
// trigger-sessions.ts
|
|
79531
79729
|
var import_node_fs54 = require("node:fs");
|
|
79532
|
-
var
|
|
79533
|
-
var
|
|
79730
|
+
var import_node_os24 = require("node:os");
|
|
79731
|
+
var import_node_path48 = require("node:path");
|
|
79534
79732
|
var import_yaml10 = __toESM(require_dist6(), 1);
|
|
79535
|
-
var AGENTS_DIR2 = process.env.AWARE_HOME ? (0,
|
|
79733
|
+
var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path48.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path48.join)((0, import_node_os24.homedir)(), ".aware", "agents");
|
|
79536
79734
|
function summarizeFire(data) {
|
|
79537
79735
|
if (!data) return "event";
|
|
79538
79736
|
const type = typeof data.type === "string" ? data.type : "";
|
|
@@ -79549,7 +79747,7 @@ function mapTriggerState(phase) {
|
|
|
79549
79747
|
function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
79550
79748
|
const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
79551
79749
|
if (!safe2(agent)) return false;
|
|
79552
|
-
const manifestPath2 = (0,
|
|
79750
|
+
const manifestPath2 = (0, import_node_path48.join)(agentsDir, agent, "manifest.yaml");
|
|
79553
79751
|
if (!(0, import_node_fs54.existsSync)(manifestPath2)) return false;
|
|
79554
79752
|
try {
|
|
79555
79753
|
const doc = (0, import_yaml10.parse)((0, import_node_fs54.readFileSync)(manifestPath2, "utf8"));
|
|
@@ -79860,7 +80058,7 @@ var RoutineError = class extends Error {
|
|
|
79860
80058
|
}
|
|
79861
80059
|
status;
|
|
79862
80060
|
};
|
|
79863
|
-
var ROUTINES_FILE = (0,
|
|
80061
|
+
var ROUTINES_FILE = (0, import_node_path49.join)(flolessRoot, "routines.json");
|
|
79864
80062
|
var routines = [];
|
|
79865
80063
|
var loaded = false;
|
|
79866
80064
|
function ensureLoaded() {
|
|
@@ -80338,10 +80536,10 @@ var AppLifecycleError = class extends Error {
|
|
|
80338
80536
|
}
|
|
80339
80537
|
};
|
|
80340
80538
|
function appsDir() {
|
|
80341
|
-
return process.env.AWARE_HOME ? (0,
|
|
80539
|
+
return process.env.AWARE_HOME ? (0, import_node_path50.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path50.join)((0, import_node_os25.homedir)(), ".aware", "apps");
|
|
80342
80540
|
}
|
|
80343
80541
|
function appDirPath(id) {
|
|
80344
|
-
return (0,
|
|
80542
|
+
return (0, import_node_path50.join)(appsDir(), id);
|
|
80345
80543
|
}
|
|
80346
80544
|
function appInstalled(id) {
|
|
80347
80545
|
return APP_ID4.test(id) && (0, import_node_fs56.existsSync)(appDirPath(id));
|
|
@@ -80583,8 +80781,8 @@ function isGatedAwareRoute(url, method) {
|
|
|
80583
80781
|
// autostart.mjs
|
|
80584
80782
|
var import_node_child_process8 = require("node:child_process");
|
|
80585
80783
|
var import_node_fs57 = require("node:fs");
|
|
80586
|
-
var
|
|
80587
|
-
var
|
|
80784
|
+
var import_node_os26 = require("node:os");
|
|
80785
|
+
var import_node_path51 = require("node:path");
|
|
80588
80786
|
|
|
80589
80787
|
// teardown.mjs
|
|
80590
80788
|
var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
@@ -80705,7 +80903,7 @@ function logLine(msg) {
|
|
|
80705
80903
|
function registerAutostart(exePath) {
|
|
80706
80904
|
if (!isWin) return;
|
|
80707
80905
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
80708
|
-
const tmp = (0,
|
|
80906
|
+
const tmp = (0, import_node_path51.join)((0, import_node_os26.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
80709
80907
|
(0, import_node_fs57.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
80710
80908
|
try {
|
|
80711
80909
|
(0, import_node_child_process8.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
@@ -80755,23 +80953,23 @@ var import_node_crypto31 = require("node:crypto");
|
|
|
80755
80953
|
var import_node_fs59 = require("node:fs");
|
|
80756
80954
|
var import_node_stream3 = require("node:stream");
|
|
80757
80955
|
var import_promises5 = require("node:stream/promises");
|
|
80758
|
-
var
|
|
80956
|
+
var import_node_path53 = require("node:path");
|
|
80759
80957
|
|
|
80760
80958
|
// post-update-marker.mjs
|
|
80761
80959
|
var import_node_fs58 = require("node:fs");
|
|
80762
|
-
var
|
|
80763
|
-
var
|
|
80960
|
+
var import_node_os27 = require("node:os");
|
|
80961
|
+
var import_node_path52 = require("node:path");
|
|
80764
80962
|
var FRESH_MS = 12e4;
|
|
80765
80963
|
function markerPath() {
|
|
80766
80964
|
const override = (process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim();
|
|
80767
80965
|
if (override) return override;
|
|
80768
|
-
const root5 = process.env.FLOLESS_HOME ?? (0,
|
|
80769
|
-
return (0,
|
|
80966
|
+
const root5 = process.env.FLOLESS_HOME ?? (0, import_node_path52.join)((0, import_node_os27.homedir)(), ".floless");
|
|
80967
|
+
return (0, import_node_path52.join)(root5, ".post-update");
|
|
80770
80968
|
}
|
|
80771
80969
|
function legacyMarkerPath() {
|
|
80772
80970
|
if ((process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim()) return null;
|
|
80773
80971
|
try {
|
|
80774
|
-
return (0,
|
|
80972
|
+
return (0, import_node_path52.join)((0, import_node_path52.dirname)((0, import_node_path52.dirname)(process.execPath)), ".floless-post-update");
|
|
80775
80973
|
} catch {
|
|
80776
80974
|
return null;
|
|
80777
80975
|
}
|
|
@@ -80812,13 +81010,13 @@ function currentVersion() {
|
|
|
80812
81010
|
return appVersion();
|
|
80813
81011
|
}
|
|
80814
81012
|
function installRoot() {
|
|
80815
|
-
return (0,
|
|
81013
|
+
return (0, import_node_path53.dirname)((0, import_node_path53.dirname)(process.execPath));
|
|
80816
81014
|
}
|
|
80817
81015
|
function updateExePath() {
|
|
80818
|
-
return (0,
|
|
81016
|
+
return (0, import_node_path53.join)(installRoot(), "Update.exe");
|
|
80819
81017
|
}
|
|
80820
81018
|
function packagesDir() {
|
|
80821
|
-
return (0,
|
|
81019
|
+
return (0, import_node_path53.join)(installRoot(), "packages");
|
|
80822
81020
|
}
|
|
80823
81021
|
function feedUrl() {
|
|
80824
81022
|
const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
|
|
@@ -80917,7 +81115,7 @@ async function downloadPackage(asset) {
|
|
|
80917
81115
|
const want = asset.SHA1.toUpperCase();
|
|
80918
81116
|
const dir = packagesDir();
|
|
80919
81117
|
(0, import_node_fs59.mkdirSync)(dir, { recursive: true });
|
|
80920
|
-
const dest = (0,
|
|
81118
|
+
const dest = (0, import_node_path53.join)(dir, asset.FileName);
|
|
80921
81119
|
if ((0, import_node_fs59.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
80922
81120
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
80923
81121
|
redirect: "follow",
|
|
@@ -81173,12 +81371,12 @@ function isTraceCorrupt(events) {
|
|
|
81173
81371
|
|
|
81174
81372
|
// launch.mjs
|
|
81175
81373
|
var import_node_child_process10 = require("node:child_process");
|
|
81176
|
-
var
|
|
81374
|
+
var import_node_path54 = require("node:path");
|
|
81177
81375
|
var import_node_url3 = require("node:url");
|
|
81178
81376
|
var import_node_fs60 = require("node:fs");
|
|
81179
81377
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
81180
81378
|
var import_node_readline = require("node:readline");
|
|
81181
|
-
var __dirname2 = (0,
|
|
81379
|
+
var __dirname2 = (0, import_node_path54.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
81182
81380
|
var PORT = Number(process.env.PORT ?? 4317);
|
|
81183
81381
|
var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
|
|
81184
81382
|
var BROWSER_URL = `http://floless.localhost:${PORT}`;
|
|
@@ -81256,7 +81454,7 @@ async function waitHealthy(timeoutMs = 3e4) {
|
|
|
81256
81454
|
function resolveServerStart() {
|
|
81257
81455
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
81258
81456
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
81259
|
-
const bundle = (0,
|
|
81457
|
+
const bundle = (0, import_node_path54.join)(__dirname2, "dist", "floless-server.cjs");
|
|
81260
81458
|
if ((0, import_node_fs60.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
81261
81459
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
81262
81460
|
}
|
|
@@ -81410,8 +81608,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
|
|
|
81410
81608
|
}
|
|
81411
81609
|
function killSupervisor({ tree = true } = {}) {
|
|
81412
81610
|
if (!isWin2) return;
|
|
81413
|
-
const isNpmChannel = /^node(\.exe)?$/i.test((0,
|
|
81414
|
-
const scriptMatch = isNpmChannel ? (0,
|
|
81611
|
+
const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path54.basename)(process.execPath));
|
|
81612
|
+
const scriptMatch = isNpmChannel ? (0, import_node_path54.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
|
|
81415
81613
|
const realExe = resolveRealInstallExe(process.execPath);
|
|
81416
81614
|
const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
|
|
81417
81615
|
const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
|
|
@@ -81582,7 +81780,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null, selfChannel = n
|
|
|
81582
81780
|
}
|
|
81583
81781
|
await action(parseTeardownFlags(flagArgv));
|
|
81584
81782
|
}
|
|
81585
|
-
var entry = (0,
|
|
81783
|
+
var entry = (0, import_node_path54.basename)(process.argv[1] ?? "").toLowerCase();
|
|
81586
81784
|
if (entry === "launch.mjs") {
|
|
81587
81785
|
runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
|
|
81588
81786
|
log(`error: ${e?.message ?? e}`);
|
|
@@ -81593,7 +81791,7 @@ if (entry === "launch.mjs") {
|
|
|
81593
81791
|
// aware-update.ts
|
|
81594
81792
|
var import_promises6 = require("node:fs/promises");
|
|
81595
81793
|
var import_node_crypto32 = require("node:crypto");
|
|
81596
|
-
var
|
|
81794
|
+
var import_node_path55 = require("node:path");
|
|
81597
81795
|
var REGISTRY_LATEST = "https://registry.npmjs.org/@aware-aeco/cli/latest";
|
|
81598
81796
|
var FEED_TIMEOUT_MS2 = 15e3;
|
|
81599
81797
|
var VERSION_TTL_MS = 5e3;
|
|
@@ -81609,8 +81807,8 @@ var nodeBridgeIo = { readdir: import_promises6.readdir, lstat: import_promises6.
|
|
|
81609
81807
|
var nodeBridgeVersionIo = { ...nodeBridgeIo, readFile: import_promises6.readFile };
|
|
81610
81808
|
var BRIDGE_VERSION_MAX_BYTES = 128;
|
|
81611
81809
|
function pathInside(root5, candidate) {
|
|
81612
|
-
const rel = (0,
|
|
81613
|
-
return rel === "" || !rel.startsWith("..") && !(0,
|
|
81810
|
+
const rel = (0, import_node_path55.relative)(root5, candidate);
|
|
81811
|
+
return rel === "" || !rel.startsWith("..") && !(0, import_node_path55.isAbsolute)(rel);
|
|
81614
81812
|
}
|
|
81615
81813
|
async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
|
|
81616
81814
|
let names;
|
|
@@ -81634,7 +81832,7 @@ async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
|
|
|
81634
81832
|
for (const host of AWARE_BRIDGE_HOSTS) {
|
|
81635
81833
|
const fileName = `aware-${host}.exe`;
|
|
81636
81834
|
if (!names.includes(fileName)) continue;
|
|
81637
|
-
const candidate = (0,
|
|
81835
|
+
const candidate = (0, import_node_path55.join)(bridgeDirectory, fileName);
|
|
81638
81836
|
try {
|
|
81639
81837
|
const stat4 = await io.lstat(candidate);
|
|
81640
81838
|
const canonical = await io.realpath(candidate);
|
|
@@ -81678,8 +81876,8 @@ async function persistentBridgeVersion(bridgeDirectory, host, io = nodeBridgeVer
|
|
|
81678
81876
|
throw error;
|
|
81679
81877
|
}
|
|
81680
81878
|
};
|
|
81681
|
-
const executable = (0,
|
|
81682
|
-
const marker = (0,
|
|
81879
|
+
const executable = (0, import_node_path55.join)(bridgeDirectory, `aware-${host}.exe`);
|
|
81880
|
+
const marker = (0, import_node_path55.join)(bridgeDirectory, `aware-${host}.version`);
|
|
81683
81881
|
try {
|
|
81684
81882
|
if (!await validateFile(executable) || !await validateFile(marker)) return null;
|
|
81685
81883
|
const bytes = await io.readFile(marker, "utf8");
|
|
@@ -81713,7 +81911,7 @@ function validateMarker(value) {
|
|
|
81713
81911
|
if (v.host != null && !isBridgeHost(v.host)) return null;
|
|
81714
81912
|
if (v.child != null) {
|
|
81715
81913
|
const child = v.child;
|
|
81716
|
-
if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0,
|
|
81914
|
+
if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0, import_node_path55.basename)(child.executableIdentity) !== child.executableIdentity) return null;
|
|
81717
81915
|
}
|
|
81718
81916
|
return {
|
|
81719
81917
|
// Normalised on read: a decoded schema-1 marker is handed to callers as a schema-2 value with
|
|
@@ -81733,7 +81931,7 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
|
81733
81931
|
const io = options.io ?? nodeMarkerIo;
|
|
81734
81932
|
const maxBytes = Math.min(options.maxBytes ?? MARKER_MAX_BYTES, MARKER_MAX_BYTES);
|
|
81735
81933
|
const randomId = options.randomId ?? import_node_crypto32.randomUUID;
|
|
81736
|
-
const directory = (0,
|
|
81934
|
+
const directory = (0, import_node_path55.dirname)(markerPath2);
|
|
81737
81935
|
return {
|
|
81738
81936
|
async read() {
|
|
81739
81937
|
let bytes;
|
|
@@ -81757,7 +81955,7 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
|
81757
81955
|
const bytes = JSON.stringify(valid);
|
|
81758
81956
|
if (Buffer.byteLength(bytes) > maxBytes) throw new Error("Refused to write an oversized AWARE maintenance marker.");
|
|
81759
81957
|
await io.mkdir(directory, { recursive: true, mode: 448 });
|
|
81760
|
-
const temp = (0,
|
|
81958
|
+
const temp = (0, import_node_path55.join)(directory, `.${(0, import_node_path55.basename)(markerPath2)}.${randomId()}.tmp`);
|
|
81761
81959
|
try {
|
|
81762
81960
|
await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
81763
81961
|
await io.rename(temp, markerPath2);
|
|
@@ -81791,7 +81989,7 @@ function validatePending(value) {
|
|
|
81791
81989
|
function createBridgePendingStore(pendingPath, options = {}) {
|
|
81792
81990
|
const io = options.io ?? nodeMarkerIo;
|
|
81793
81991
|
const randomId = options.randomId ?? import_node_crypto32.randomUUID;
|
|
81794
|
-
const directory = (0,
|
|
81992
|
+
const directory = (0, import_node_path55.dirname)(pendingPath);
|
|
81795
81993
|
return {
|
|
81796
81994
|
async read() {
|
|
81797
81995
|
let bytes;
|
|
@@ -81815,7 +82013,7 @@ function createBridgePendingStore(pendingPath, options = {}) {
|
|
|
81815
82013
|
throw new Error("Refused to write an oversized AWARE bridge-repair intent.");
|
|
81816
82014
|
}
|
|
81817
82015
|
await io.mkdir(directory, { recursive: true, mode: 448 });
|
|
81818
|
-
const temp = (0,
|
|
82016
|
+
const temp = (0, import_node_path55.join)(directory, `.${(0, import_node_path55.basename)(pendingPath)}.${randomId()}.tmp`);
|
|
81819
82017
|
try {
|
|
81820
82018
|
await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
81821
82019
|
await io.rename(temp, pendingPath);
|
|
@@ -81935,7 +82133,7 @@ async function checkAwareUpdate(bridgeDirectory) {
|
|
|
81935
82133
|
// aware-install-process.ts
|
|
81936
82134
|
var import_node_child_process11 = require("node:child_process");
|
|
81937
82135
|
var import_promises7 = require("node:fs/promises");
|
|
81938
|
-
var
|
|
82136
|
+
var import_node_path56 = require("node:path");
|
|
81939
82137
|
var import_node_util4 = require("node:util");
|
|
81940
82138
|
var execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process11.execFile);
|
|
81941
82139
|
var DEFAULT_INSTALL_TIMEOUT_MS = 10 * 6e4;
|
|
@@ -81963,7 +82161,7 @@ function killTree2(child) {
|
|
|
81963
82161
|
}
|
|
81964
82162
|
}
|
|
81965
82163
|
function safeExecutableIdentity(value) {
|
|
81966
|
-
const name = (0,
|
|
82164
|
+
const name = (0, import_node_path56.basename)(value.trim()).replace(/[^A-Za-z0-9._-]/g, "").slice(0, 128);
|
|
81967
82165
|
return name || "unknown";
|
|
81968
82166
|
}
|
|
81969
82167
|
async function maintenanceChildIdentity(pid) {
|
|
@@ -82974,10 +83172,10 @@ var import_node_child_process12 = require("node:child_process");
|
|
|
82974
83172
|
var import_node_util5 = require("node:util");
|
|
82975
83173
|
var import_node_crypto33 = require("node:crypto");
|
|
82976
83174
|
var import_node_fs61 = require("node:fs");
|
|
82977
|
-
var
|
|
82978
|
-
var
|
|
82979
|
-
var ROOT4 = () => process.env.FLOLESS_HOME ?? (0,
|
|
82980
|
-
var LEASE_DIR = () => (0,
|
|
83175
|
+
var import_node_os28 = require("node:os");
|
|
83176
|
+
var import_node_path57 = require("node:path");
|
|
83177
|
+
var ROOT4 = () => process.env.FLOLESS_HOME ?? (0, import_node_path57.join)((0, import_node_os28.homedir)(), ".floless");
|
|
83178
|
+
var LEASE_DIR = () => (0, import_node_path57.join)(ROOT4(), "run-leases");
|
|
82981
83179
|
var WIN = process.platform === "win32";
|
|
82982
83180
|
var LeaseHeldError = class extends Error {
|
|
82983
83181
|
constructor(holder) {
|
|
@@ -82988,15 +83186,15 @@ var LeaseHeldError = class extends Error {
|
|
|
82988
83186
|
};
|
|
82989
83187
|
var serverStartedAt = Math.round(Date.now() - process.uptime() * 1e3);
|
|
82990
83188
|
function canonicalDir(p) {
|
|
82991
|
-
const real = import_node_fs61.realpathSync.native((0,
|
|
83189
|
+
const real = import_node_fs61.realpathSync.native((0, import_node_path57.resolve)(p));
|
|
82992
83190
|
if (!(0, import_node_fs61.statSync)(real).isDirectory()) throw new Error(`not a directory: ${p}`);
|
|
82993
|
-
return real.length > 1 && real.endsWith(
|
|
83191
|
+
return real.length > 1 && real.endsWith(import_node_path57.sep) ? real.slice(0, -1) : real;
|
|
82994
83192
|
}
|
|
82995
83193
|
function isInside(parent, child) {
|
|
82996
83194
|
const norm = (s) => WIN ? s.toLowerCase() : s;
|
|
82997
83195
|
const p = norm(parent);
|
|
82998
83196
|
const c = norm(child);
|
|
82999
|
-
return c === p || c.startsWith(p.endsWith(
|
|
83197
|
+
return c === p || c.startsWith(p.endsWith(import_node_path57.sep) ? p : p + import_node_path57.sep);
|
|
83000
83198
|
}
|
|
83001
83199
|
function leaseKey(canonicalCwd) {
|
|
83002
83200
|
const k = WIN ? canonicalCwd.toLowerCase() : canonicalCwd;
|
|
@@ -83016,7 +83214,7 @@ function readLeaseFile(file) {
|
|
|
83016
83214
|
function claimLease(input) {
|
|
83017
83215
|
const cwd = canonicalDir(input.cwd);
|
|
83018
83216
|
(0, import_node_fs61.mkdirSync)(LEASE_DIR(), { recursive: true, mode: 448 });
|
|
83019
|
-
const file = (0,
|
|
83217
|
+
const file = (0, import_node_path57.join)(LEASE_DIR(), leaseKey(cwd));
|
|
83020
83218
|
const lease = {
|
|
83021
83219
|
leaseId: (0, import_node_crypto33.randomUUID)(),
|
|
83022
83220
|
// 32 bytes of CSPRNG. This is an authorization token, not a correlation id — it is the only
|
|
@@ -83062,7 +83260,7 @@ function claimLease(input) {
|
|
|
83062
83260
|
function listLeases() {
|
|
83063
83261
|
const dir = LEASE_DIR();
|
|
83064
83262
|
if (!(0, import_node_fs61.existsSync)(dir)) return [];
|
|
83065
|
-
return (0, import_node_fs61.readdirSync)(dir).filter((f) => f.endsWith(".json")).map((f) => readLeaseFile((0,
|
|
83263
|
+
return (0, import_node_fs61.readdirSync)(dir).filter((f) => f.endsWith(".json")).map((f) => readLeaseFile((0, import_node_path57.join)(dir, f))).filter((l) => l !== null);
|
|
83066
83264
|
}
|
|
83067
83265
|
function getLease(leaseId) {
|
|
83068
83266
|
return listLeases().find((l) => l.leaseId === leaseId) ?? null;
|
|
@@ -83080,7 +83278,7 @@ function patchLease(leaseId, generation, patch2) {
|
|
|
83080
83278
|
const dir = LEASE_DIR();
|
|
83081
83279
|
if (!(0, import_node_fs61.existsSync)(dir)) return null;
|
|
83082
83280
|
for (const f of (0, import_node_fs61.readdirSync)(dir).filter((n) => n.endsWith(".json"))) {
|
|
83083
|
-
const file = (0,
|
|
83281
|
+
const file = (0, import_node_path57.join)(dir, f);
|
|
83084
83282
|
const cur = readLeaseFile(file);
|
|
83085
83283
|
if (!cur || cur.leaseId !== leaseId) continue;
|
|
83086
83284
|
if (cur.generation !== generation) return null;
|
|
@@ -83094,7 +83292,7 @@ function releaseLease(leaseId) {
|
|
|
83094
83292
|
const dir = LEASE_DIR();
|
|
83095
83293
|
if (!(0, import_node_fs61.existsSync)(dir)) return false;
|
|
83096
83294
|
for (const f of (0, import_node_fs61.readdirSync)(dir).filter((n) => n.endsWith(".json"))) {
|
|
83097
|
-
const file = (0,
|
|
83295
|
+
const file = (0, import_node_path57.join)(dir, f);
|
|
83098
83296
|
const cur = readLeaseFile(file);
|
|
83099
83297
|
if (cur?.leaseId !== leaseId) continue;
|
|
83100
83298
|
try {
|
|
@@ -83169,190 +83367,6 @@ function sameProcess(observed, pid, procStartedAt) {
|
|
|
83169
83367
|
return seen !== void 0 && Math.abs(seen - procStartedAt) < 2e3;
|
|
83170
83368
|
}
|
|
83171
83369
|
|
|
83172
|
-
// run-relay.ts
|
|
83173
|
-
var import_node_os28 = require("node:os");
|
|
83174
|
-
var import_node_path57 = require("node:path");
|
|
83175
|
-
var RUN_POLICY = {
|
|
83176
|
-
/**
|
|
83177
|
-
* The first slice's one enabled type: small, mechanical, well-scoped.
|
|
83178
|
-
*
|
|
83179
|
-
* Three calls, and nothing else. Note what is NOT here: no `PUT /api/contract`, no `/approve`, no
|
|
83180
|
-
* project route — a `tweak` edits a node in a `.flo` and compiles it, and the approval gate stays
|
|
83181
|
-
* human. `POST /api/compile` is what replaces the skill's `aware app compile` shell-out, which is
|
|
83182
|
-
* the other half of the shell being denied.
|
|
83183
|
-
*/
|
|
83184
|
-
tweak: {
|
|
83185
|
-
runnable: true,
|
|
83186
|
-
calls: (l) => [
|
|
83187
|
-
{ method: "GET", path: "/api/requests", why: "read the authoritative spec for this request" },
|
|
83188
|
-
...isSafeAppId(l.appId) ? [{ method: "POST", path: "/api/compile", body: { id: l.appId }, why: "compile the workflow after editing its .flo" }] : [],
|
|
83189
|
-
{ method: "DELETE", path: `/api/requests/${l.requestId}`, why: "clear this request once applied" }
|
|
83190
|
-
],
|
|
83191
|
-
// The `.flo` lives in the app's own source directory, NOT in the nominated folder — which is
|
|
83192
|
-
// exactly why §D1 insists the nominated folder is an address rather than a sandbox. Without this
|
|
83193
|
-
// grant the agent can read its instruction and edit nothing.
|
|
83194
|
-
//
|
|
83195
|
-
// `.filter(Boolean)`, so an id `appSourceDir` refuses grants NOTHING rather than falling back to
|
|
83196
|
-
// something broader. A run whose app id is unusable should be refused before it starts (the route
|
|
83197
|
-
// does that), and if one ever reaches here it gets no filesystem capability at all.
|
|
83198
|
-
addDirs: (l) => l.appId ? [appSourceDir(l.appId)].filter((d) => d !== null) : []
|
|
83199
|
-
},
|
|
83200
|
-
// ── enabled by E1, but not built in this slice ──────────────────────────────
|
|
83201
|
-
// Each is mechanical and well-scoped enough to run headless; each needs its own call list worked
|
|
83202
|
-
// out from its skill and its own end-to-end proof, and the plan slices the first spawn to ONE type
|
|
83203
|
-
// on purpose. A reason, not a null, so the picker can say why the button is absent.
|
|
83204
|
-
"use-template": { runnable: false, why: "not yet available headless \u2014 run it from your terminal for now" },
|
|
83205
|
-
"ui-customize": { runnable: false, why: "not yet available headless \u2014 run it from your terminal for now" },
|
|
83206
|
-
rebake: { runnable: false, why: "not yet available headless \u2014 run it from your terminal for now" },
|
|
83207
|
-
"tweak-contract": { runnable: false, why: "not yet available headless \u2014 run it from your terminal for now" },
|
|
83208
|
-
// ── E1 says no, and these are the reasons ───────────────────────────────────
|
|
83209
|
-
"revision-read": {
|
|
83210
|
-
runnable: false,
|
|
83211
|
-
// The flagship type, and the judgment-heaviest: every arm of its instruction ends "STOP and tell
|
|
83212
|
-
// me to open Drawings → Steel Filter … do NOT read members until I explicitly come back". It is a
|
|
83213
|
-
// two-phase workflow whose first phase ends in a mandatory human checkpoint, so headless the best
|
|
83214
|
-
// outcome is "prepass runs, agent says go review, exits 0, request still pending" — a row that
|
|
83215
|
-
// lies. It waits until `needs-you` is a first-class, actionable row.
|
|
83216
|
-
why: "reading a drawing set stops at a review checkpoint \u2014 do this one in your terminal"
|
|
83217
|
-
},
|
|
83218
|
-
"knowledge-organize": {
|
|
83219
|
-
runnable: false,
|
|
83220
|
-
// Both take the server organize lock, and the plan's stated mitigation ("mark the request failed
|
|
83221
|
-
// so the lock is released") is a NO-OP: `patchRequest` writes a request file, while the lock is
|
|
83222
|
-
// released by `failOrganize` in the knowledge store. A hard-killed headless organize past
|
|
83223
|
-
// `/start` wedges the Organize button for ten minutes, on a row that renders no ✕.
|
|
83224
|
-
why: "organizing holds a lock a killed run can\u2019t release \u2014 do this one in your terminal"
|
|
83225
|
-
},
|
|
83226
|
-
"knowledge-adjust": { runnable: false, why: "organizing holds a lock a killed run can\u2019t release \u2014 do this one in your terminal" },
|
|
83227
|
-
guide: { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" },
|
|
83228
|
-
"new-workflow": { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" }
|
|
83229
|
-
};
|
|
83230
|
-
var SAFE_APP_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
83231
|
-
var isSafeAppId = (id) => typeof id === "string" && SAFE_APP_ID.test(id);
|
|
83232
|
-
function appSourceDir(appId) {
|
|
83233
|
-
if (!isSafeAppId(appId)) return null;
|
|
83234
|
-
const root5 = process.env.AWARE_HOME || (0, import_node_path57.join)((0, import_node_os28.homedir)(), ".aware");
|
|
83235
|
-
return (0, import_node_path57.join)(root5, "apps", appId);
|
|
83236
|
-
}
|
|
83237
|
-
function policyFor(type) {
|
|
83238
|
-
if (!isRequestType(type)) {
|
|
83239
|
-
return { runnable: false, why: "floless doesn\u2019t recognise this request \u2014 it may have been made by a newer version" };
|
|
83240
|
-
}
|
|
83241
|
-
return RUN_POLICY[type];
|
|
83242
|
-
}
|
|
83243
|
-
var TOOL_NAME = "floless_api";
|
|
83244
|
-
function mcpConfigFor(token2, origin) {
|
|
83245
|
-
return { mcpServers: { floless: { type: "http", url: `${origin}/api/mcp/run/${token2}` } } };
|
|
83246
|
-
}
|
|
83247
|
-
function jsonRpc(id, result) {
|
|
83248
|
-
return { jsonrpc: "2.0", id, result };
|
|
83249
|
-
}
|
|
83250
|
-
function toolRefusal(text3) {
|
|
83251
|
-
return { content: [{ type: "text", text: text3 }], isError: true };
|
|
83252
|
-
}
|
|
83253
|
-
function sameBody(want, got) {
|
|
83254
|
-
if (want === void 0 && got !== null && typeof got === "object" && Object.keys(got).length === 0) return true;
|
|
83255
|
-
return JSON.stringify(sortKeys(want)) === JSON.stringify(sortKeys(got ?? void 0));
|
|
83256
|
-
}
|
|
83257
|
-
function sortKeys(v) {
|
|
83258
|
-
if (Array.isArray(v)) return v.map(sortKeys);
|
|
83259
|
-
if (v && typeof v === "object") {
|
|
83260
|
-
return Object.fromEntries(Object.keys(v).sort().map((k) => [k, sortKeys(v[k])]));
|
|
83261
|
-
}
|
|
83262
|
-
return v;
|
|
83263
|
-
}
|
|
83264
|
-
function normalizePath(raw, origin) {
|
|
83265
|
-
if (typeof raw !== "string" || !raw) return null;
|
|
83266
|
-
let u;
|
|
83267
|
-
try {
|
|
83268
|
-
u = new URL(raw, origin);
|
|
83269
|
-
} catch {
|
|
83270
|
-
return null;
|
|
83271
|
-
}
|
|
83272
|
-
if (new URL(origin).origin !== u.origin) return null;
|
|
83273
|
-
const p = u.pathname.length > 1 && u.pathname.endsWith("/") ? u.pathname.slice(0, -1) : u.pathname;
|
|
83274
|
-
return `${p}${u.search}`;
|
|
83275
|
-
}
|
|
83276
|
-
function registerRunRelay(app, deps, origin) {
|
|
83277
|
-
app.post(
|
|
83278
|
-
"/api/mcp/run/:token",
|
|
83279
|
-
async (req, reply) => {
|
|
83280
|
-
const msg = req.body ?? {};
|
|
83281
|
-
if (msg.id === void 0) return reply.status(202).send();
|
|
83282
|
-
const lease = deps.leaseForToken(req.params.token);
|
|
83283
|
-
if (!lease) {
|
|
83284
|
-
return reply.status(200).send({
|
|
83285
|
-
jsonrpc: "2.0",
|
|
83286
|
-
id: msg.id,
|
|
83287
|
-
error: { code: -32001, message: "this run is no longer active" }
|
|
83288
|
-
});
|
|
83289
|
-
}
|
|
83290
|
-
const policy = policyFor(lease.requestType);
|
|
83291
|
-
const allowed = policy.runnable ? policy.calls(lease) : [];
|
|
83292
|
-
if (msg.method === "initialize") {
|
|
83293
|
-
const requested = msg.params?.protocolVersion;
|
|
83294
|
-
return reply.send(jsonRpc(msg.id, {
|
|
83295
|
-
protocolVersion: requested ?? "2025-06-18",
|
|
83296
|
-
capabilities: { tools: {} },
|
|
83297
|
-
serverInfo: { name: "floless", version: "1" }
|
|
83298
|
-
}));
|
|
83299
|
-
}
|
|
83300
|
-
if (msg.method === "tools/list") {
|
|
83301
|
-
return reply.send(jsonRpc(msg.id, {
|
|
83302
|
-
tools: [{
|
|
83303
|
-
name: TOOL_NAME,
|
|
83304
|
-
description: "Call the floless.app API for THIS request. This is your only channel to floless \u2014 there is no shell in this session. Exactly these calls are permitted:\n" + allowed.map((c) => ` ${c.method} ${c.path}${c.body ? ` body ${JSON.stringify(c.body)}` : ""} \u2014 ${c.why}`).join("\n") + '\nAnything else is refused. If you need something not listed, stop and finish with outcome "needs-you" explaining what you need.',
|
|
83305
|
-
inputSchema: {
|
|
83306
|
-
type: "object",
|
|
83307
|
-
properties: {
|
|
83308
|
-
method: { type: "string", enum: ["GET", "POST", "PUT", "DELETE"] },
|
|
83309
|
-
path: { type: "string" },
|
|
83310
|
-
body: { type: "object" }
|
|
83311
|
-
},
|
|
83312
|
-
required: ["method", "path"]
|
|
83313
|
-
}
|
|
83314
|
-
}]
|
|
83315
|
-
}));
|
|
83316
|
-
}
|
|
83317
|
-
if (msg.method !== "tools/call") {
|
|
83318
|
-
return reply.send({ jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: "method not found" } });
|
|
83319
|
-
}
|
|
83320
|
-
const params = msg.params;
|
|
83321
|
-
if (params?.name !== TOOL_NAME) {
|
|
83322
|
-
return reply.send(jsonRpc(msg.id, toolRefusal(`no such tool: ${String(params?.name)}`)));
|
|
83323
|
-
}
|
|
83324
|
-
if (!policy.runnable) {
|
|
83325
|
-
return reply.send(jsonRpc(msg.id, toolRefusal(`refused: ${policy.why}`)));
|
|
83326
|
-
}
|
|
83327
|
-
const argMethod = String(params.arguments?.["method"] ?? "").toUpperCase();
|
|
83328
|
-
const argPath = normalizePath(params.arguments?.["path"], origin);
|
|
83329
|
-
const argBody = params.arguments?.["body"];
|
|
83330
|
-
const match = argPath === null ? void 0 : allowed.find((c) => c.method === argMethod && c.path === argPath && sameBody(c.body, argBody));
|
|
83331
|
-
if (!match) {
|
|
83332
|
-
return reply.send(jsonRpc(msg.id, toolRefusal(
|
|
83333
|
-
`refused: ${argMethod} ${String(params.arguments?.["path"])} is not permitted for this run.
|
|
83334
|
-
Permitted:
|
|
83335
|
-
${allowed.map((c) => ` ${c.method} ${c.path}${c.body ? ` body ${JSON.stringify(c.body)}` : ""}`).join("\n")}`
|
|
83336
|
-
)));
|
|
83337
|
-
}
|
|
83338
|
-
const res = await deps.dispatch({ method: match.method, path: match.path, ...match.body !== void 0 ? { body: match.body } : {} });
|
|
83339
|
-
if (match.method === "DELETE" && match.path === `/api/requests/${lease.requestId}` && res.status < 300) {
|
|
83340
|
-
deps.markResolved(lease);
|
|
83341
|
-
}
|
|
83342
|
-
const body = match.path === "/api/requests" ? onlyThisRequest(res.body, lease.requestId) : res.body;
|
|
83343
|
-
return reply.send(jsonRpc(msg.id, {
|
|
83344
|
-
content: [{ type: "text", text: JSON.stringify({ status: res.status, body }) }],
|
|
83345
|
-
...res.status >= 400 ? { isError: true } : {}
|
|
83346
|
-
}));
|
|
83347
|
-
}
|
|
83348
|
-
);
|
|
83349
|
-
}
|
|
83350
|
-
function onlyThisRequest(body, requestId) {
|
|
83351
|
-
const b = body;
|
|
83352
|
-
if (!b || !Array.isArray(b.requests)) return body;
|
|
83353
|
-
return { ...b, requests: b.requests.filter((r) => r?.id === requestId) };
|
|
83354
|
-
}
|
|
83355
|
-
|
|
83356
83370
|
// terminal-runtime.ts
|
|
83357
83371
|
var import_node_fs62 = require("node:fs");
|
|
83358
83372
|
var import_node_os29 = require("node:os");
|
|
@@ -83444,6 +83458,12 @@ function readProviderSetting() {
|
|
|
83444
83458
|
const p = readSettings().provider;
|
|
83445
83459
|
return RUNTIMES.some((r) => r.id === p) ? p : null;
|
|
83446
83460
|
}
|
|
83461
|
+
function writeProviderSetting(provider) {
|
|
83462
|
+
if (provider !== null && !RUNTIMES.some((r) => r.id === provider)) {
|
|
83463
|
+
throw new Error(`unknown terminal runtime: ${String(provider)}`);
|
|
83464
|
+
}
|
|
83465
|
+
writeSettings({ provider });
|
|
83466
|
+
}
|
|
83447
83467
|
function resolveProvider() {
|
|
83448
83468
|
const found = detectRuntimes().filter((r) => r.state === "found");
|
|
83449
83469
|
if (!found.length) return null;
|
|
@@ -83685,6 +83705,14 @@ function registerTerminalRunRoutes(app, deps) {
|
|
|
83685
83705
|
provider: resolveProvider(),
|
|
83686
83706
|
folder: resolveRunFolder(req.query?.project ?? null)
|
|
83687
83707
|
}));
|
|
83708
|
+
app.put("/api/terminal-runtimes/provider", async (request, reply) => {
|
|
83709
|
+
const p = request.body?.provider ?? null;
|
|
83710
|
+
if (p !== null && !detectRuntimes().some((r) => r.id === p)) {
|
|
83711
|
+
return reply.status(400).send({ ok: false, error: `floless doesn\u2019t know a terminal AI called \u201C${String(p)}\u201D.` });
|
|
83712
|
+
}
|
|
83713
|
+
writeProviderSetting(p);
|
|
83714
|
+
return { ok: true, provider: resolveProvider() };
|
|
83715
|
+
});
|
|
83688
83716
|
app.put("/api/terminal-runtimes/folder", async (request, reply) => {
|
|
83689
83717
|
try {
|
|
83690
83718
|
const folder = nominateFolder(request.body?.project ?? null, String(request.body?.folder ?? ""));
|
|
@@ -83700,15 +83728,27 @@ function registerTerminalRunRoutes(app, deps) {
|
|
|
83700
83728
|
if (!req) return reply.status(404).send({ ok: false, error: "request not found" });
|
|
83701
83729
|
const policy = policyFor(req.type);
|
|
83702
83730
|
if (!policy.runnable) return reply.status(400).send({ ok: false, error: policy.why, code: "not-runnable" });
|
|
83731
|
+
if (!deps.buildPrompt(req).trim()) {
|
|
83732
|
+
return reply.status(400).send({
|
|
83733
|
+
ok: false,
|
|
83734
|
+
code: "no-prompt",
|
|
83735
|
+
error: "floless can\u2019t compose an instruction for this request, so there is nothing to hand a terminal AI. Clear it and queue it again."
|
|
83736
|
+
});
|
|
83737
|
+
}
|
|
83703
83738
|
if (req.run && (req.run.state === "queued" || req.run.state === "running")) {
|
|
83704
83739
|
return reply.status(409).send({ ok: false, error: "this request is already running", code: "running" });
|
|
83705
83740
|
}
|
|
83706
83741
|
if (req.appId !== void 0 && !isSafeAppId(req.appId)) {
|
|
83707
83742
|
return reply.status(400).send({ ok: false, error: "This request names a workflow floless can\u2019t identify.", code: "bad-app-id" });
|
|
83708
83743
|
}
|
|
83709
|
-
const
|
|
83744
|
+
const asked = request.body?.runtime;
|
|
83745
|
+
const runtime = asked == null ? resolveProvider() : detectRuntimes().find((r) => r.id === asked && r.state === "found")?.id ?? null;
|
|
83710
83746
|
if (!runtime) {
|
|
83711
|
-
return reply.status(400).send({
|
|
83747
|
+
return reply.status(400).send({
|
|
83748
|
+
ok: false,
|
|
83749
|
+
code: "no-runtime",
|
|
83750
|
+
error: asked == null ? "No terminal AI found on this machine." : `floless can\u2019t find ${String(asked)} on this machine.`
|
|
83751
|
+
});
|
|
83712
83752
|
}
|
|
83713
83753
|
const projectKey = req.project ?? req.appId ?? null;
|
|
83714
83754
|
const folder = resolveRunFolder(projectKey);
|
|
@@ -89471,7 +89511,8 @@ async function startServer() {
|
|
|
89471
89511
|
patchRequest,
|
|
89472
89512
|
buildPrompt: (r) => {
|
|
89473
89513
|
const v = requestView2(r);
|
|
89474
|
-
return v
|
|
89514
|
+
return v && v.marker && v.prompt ? `${v.marker}
|
|
89515
|
+
${v.prompt}` : "";
|
|
89475
89516
|
},
|
|
89476
89517
|
broadcast,
|
|
89477
89518
|
// The relay executes its approved calls through fastify's own dispatcher rather than over the
|