@floless/app 0.126.4 → 0.126.5
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 +806 -335
- package/dist/skills/floless-app-new-workflow/SKILL.md +18 -1
- package/dist/skills/floless-app-workflows/SKILL.md +20 -1
- package/dist/web/app.css +65 -14
- package/dist/web/aware.js +129 -2
- package/dist/web/index.html +12 -0
- package/dist/web/workspaces.js +24 -1
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -5489,7 +5489,7 @@ var require_thread_stream = __commonJS({
|
|
|
5489
5489
|
var { version } = require_package();
|
|
5490
5490
|
var { EventEmitter: EventEmitter2 } = require("events");
|
|
5491
5491
|
var { Worker: Worker2 } = require("worker_threads");
|
|
5492
|
-
var { join:
|
|
5492
|
+
var { join: join60 } = require("path");
|
|
5493
5493
|
var { pathToFileURL } = require("url");
|
|
5494
5494
|
var { wait } = require_wait();
|
|
5495
5495
|
var {
|
|
@@ -5540,7 +5540,7 @@ var require_thread_stream = __commonJS({
|
|
|
5540
5540
|
function createWorker(stream, opts) {
|
|
5541
5541
|
const { filename, workerData } = opts;
|
|
5542
5542
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
5543
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
5543
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join60(__dirname, "lib", "worker.js");
|
|
5544
5544
|
const worker = new Worker2(toExecute, {
|
|
5545
5545
|
...opts.workerOpts,
|
|
5546
5546
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -6006,9 +6006,9 @@ var require_transport = __commonJS({
|
|
|
6006
6006
|
"node_modules/pino/lib/transport.js"(exports2, module2) {
|
|
6007
6007
|
"use strict";
|
|
6008
6008
|
var { createRequire: createRequire5 } = require("module");
|
|
6009
|
-
var { existsSync:
|
|
6009
|
+
var { existsSync: existsSync57 } = require("node:fs");
|
|
6010
6010
|
var getCallers = require_caller();
|
|
6011
|
-
var { join:
|
|
6011
|
+
var { join: join60, isAbsolute: isAbsolute5, sep: sep8 } = require("node:path");
|
|
6012
6012
|
var { fileURLToPath: fileURLToPath6 } = require("node:url");
|
|
6013
6013
|
var sleep2 = require_atomic_sleep();
|
|
6014
6014
|
var onExit = require_on_exit_leak_free();
|
|
@@ -6080,7 +6080,7 @@ var require_transport = __commonJS({
|
|
|
6080
6080
|
return false;
|
|
6081
6081
|
}
|
|
6082
6082
|
}
|
|
6083
|
-
return isAbsolute5(path) && !
|
|
6083
|
+
return isAbsolute5(path) && !existsSync57(path);
|
|
6084
6084
|
}
|
|
6085
6085
|
function stripQuotes(value) {
|
|
6086
6086
|
const first = value[0];
|
|
@@ -6161,7 +6161,7 @@ var require_transport = __commonJS({
|
|
|
6161
6161
|
throw new Error("only one of target or targets can be specified");
|
|
6162
6162
|
}
|
|
6163
6163
|
if (targets) {
|
|
6164
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
6164
|
+
target = bundlerOverrides["pino-worker"] || join60(__dirname, "worker.js");
|
|
6165
6165
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
6166
6166
|
return {
|
|
6167
6167
|
...dest,
|
|
@@ -6179,7 +6179,7 @@ var require_transport = __commonJS({
|
|
|
6179
6179
|
});
|
|
6180
6180
|
});
|
|
6181
6181
|
} else if (pipeline3) {
|
|
6182
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
6182
|
+
target = bundlerOverrides["pino-worker"] || join60(__dirname, "worker.js");
|
|
6183
6183
|
options.pipelines = [pipeline3.map((dest) => {
|
|
6184
6184
|
return {
|
|
6185
6185
|
...dest,
|
|
@@ -6202,7 +6202,7 @@ var require_transport = __commonJS({
|
|
|
6202
6202
|
return origin;
|
|
6203
6203
|
}
|
|
6204
6204
|
if (origin === "pino/file") {
|
|
6205
|
-
return
|
|
6205
|
+
return join60(__dirname, "..", "file.js");
|
|
6206
6206
|
}
|
|
6207
6207
|
let fixTarget2;
|
|
6208
6208
|
for (const filePath of callers) {
|
|
@@ -7182,7 +7182,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
7182
7182
|
return circularValue;
|
|
7183
7183
|
}
|
|
7184
7184
|
let res = "";
|
|
7185
|
-
let
|
|
7185
|
+
let join60 = ",";
|
|
7186
7186
|
const originalIndentation = indentation;
|
|
7187
7187
|
if (Array.isArray(value)) {
|
|
7188
7188
|
if (value.length === 0) {
|
|
@@ -7196,7 +7196,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
7196
7196
|
indentation += spacer;
|
|
7197
7197
|
res += `
|
|
7198
7198
|
${indentation}`;
|
|
7199
|
-
|
|
7199
|
+
join60 = `,
|
|
7200
7200
|
${indentation}`;
|
|
7201
7201
|
}
|
|
7202
7202
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -7204,13 +7204,13 @@ ${indentation}`;
|
|
|
7204
7204
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
7205
7205
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
7206
7206
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
7207
|
-
res +=
|
|
7207
|
+
res += join60;
|
|
7208
7208
|
}
|
|
7209
7209
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
7210
7210
|
res += tmp !== void 0 ? tmp : "null";
|
|
7211
7211
|
if (value.length - 1 > maximumBreadth) {
|
|
7212
7212
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
7213
|
-
res += `${
|
|
7213
|
+
res += `${join60}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
7214
7214
|
}
|
|
7215
7215
|
if (spacer !== "") {
|
|
7216
7216
|
res += `
|
|
@@ -7231,7 +7231,7 @@ ${originalIndentation}`;
|
|
|
7231
7231
|
let separator = "";
|
|
7232
7232
|
if (spacer !== "") {
|
|
7233
7233
|
indentation += spacer;
|
|
7234
|
-
|
|
7234
|
+
join60 = `,
|
|
7235
7235
|
${indentation}`;
|
|
7236
7236
|
whitespace = " ";
|
|
7237
7237
|
}
|
|
@@ -7245,13 +7245,13 @@ ${indentation}`;
|
|
|
7245
7245
|
const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
|
|
7246
7246
|
if (tmp !== void 0) {
|
|
7247
7247
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
7248
|
-
separator =
|
|
7248
|
+
separator = join60;
|
|
7249
7249
|
}
|
|
7250
7250
|
}
|
|
7251
7251
|
if (keyLength > maximumBreadth) {
|
|
7252
7252
|
const removedKeys = keyLength - maximumBreadth;
|
|
7253
7253
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
7254
|
-
separator =
|
|
7254
|
+
separator = join60;
|
|
7255
7255
|
}
|
|
7256
7256
|
if (spacer !== "" && separator.length > 1) {
|
|
7257
7257
|
res = `
|
|
@@ -7292,7 +7292,7 @@ ${originalIndentation}`;
|
|
|
7292
7292
|
}
|
|
7293
7293
|
const originalIndentation = indentation;
|
|
7294
7294
|
let res = "";
|
|
7295
|
-
let
|
|
7295
|
+
let join60 = ",";
|
|
7296
7296
|
if (Array.isArray(value)) {
|
|
7297
7297
|
if (value.length === 0) {
|
|
7298
7298
|
return "[]";
|
|
@@ -7305,7 +7305,7 @@ ${originalIndentation}`;
|
|
|
7305
7305
|
indentation += spacer;
|
|
7306
7306
|
res += `
|
|
7307
7307
|
${indentation}`;
|
|
7308
|
-
|
|
7308
|
+
join60 = `,
|
|
7309
7309
|
${indentation}`;
|
|
7310
7310
|
}
|
|
7311
7311
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -7313,13 +7313,13 @@ ${indentation}`;
|
|
|
7313
7313
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
7314
7314
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
7315
7315
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
7316
|
-
res +=
|
|
7316
|
+
res += join60;
|
|
7317
7317
|
}
|
|
7318
7318
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
7319
7319
|
res += tmp !== void 0 ? tmp : "null";
|
|
7320
7320
|
if (value.length - 1 > maximumBreadth) {
|
|
7321
7321
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
7322
|
-
res += `${
|
|
7322
|
+
res += `${join60}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
7323
7323
|
}
|
|
7324
7324
|
if (spacer !== "") {
|
|
7325
7325
|
res += `
|
|
@@ -7332,7 +7332,7 @@ ${originalIndentation}`;
|
|
|
7332
7332
|
let whitespace = "";
|
|
7333
7333
|
if (spacer !== "") {
|
|
7334
7334
|
indentation += spacer;
|
|
7335
|
-
|
|
7335
|
+
join60 = `,
|
|
7336
7336
|
${indentation}`;
|
|
7337
7337
|
whitespace = " ";
|
|
7338
7338
|
}
|
|
@@ -7341,7 +7341,7 @@ ${indentation}`;
|
|
|
7341
7341
|
const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
|
|
7342
7342
|
if (tmp !== void 0) {
|
|
7343
7343
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
7344
|
-
separator =
|
|
7344
|
+
separator = join60;
|
|
7345
7345
|
}
|
|
7346
7346
|
}
|
|
7347
7347
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -7399,20 +7399,20 @@ ${originalIndentation}`;
|
|
|
7399
7399
|
indentation += spacer;
|
|
7400
7400
|
let res2 = `
|
|
7401
7401
|
${indentation}`;
|
|
7402
|
-
const
|
|
7402
|
+
const join61 = `,
|
|
7403
7403
|
${indentation}`;
|
|
7404
7404
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
7405
7405
|
let i = 0;
|
|
7406
7406
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
7407
7407
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
7408
7408
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
7409
|
-
res2 +=
|
|
7409
|
+
res2 += join61;
|
|
7410
7410
|
}
|
|
7411
7411
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
7412
7412
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
7413
7413
|
if (value.length - 1 > maximumBreadth) {
|
|
7414
7414
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
7415
|
-
res2 += `${
|
|
7415
|
+
res2 += `${join61}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
7416
7416
|
}
|
|
7417
7417
|
res2 += `
|
|
7418
7418
|
${originalIndentation}`;
|
|
@@ -7428,16 +7428,16 @@ ${originalIndentation}`;
|
|
|
7428
7428
|
return '"[Object]"';
|
|
7429
7429
|
}
|
|
7430
7430
|
indentation += spacer;
|
|
7431
|
-
const
|
|
7431
|
+
const join60 = `,
|
|
7432
7432
|
${indentation}`;
|
|
7433
7433
|
let res = "";
|
|
7434
7434
|
let separator = "";
|
|
7435
7435
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
7436
7436
|
if (isTypedArrayWithEntries(value)) {
|
|
7437
|
-
res += stringifyTypedArray(value,
|
|
7437
|
+
res += stringifyTypedArray(value, join60, maximumBreadth);
|
|
7438
7438
|
keys = keys.slice(value.length);
|
|
7439
7439
|
maximumPropertiesToStringify -= value.length;
|
|
7440
|
-
separator =
|
|
7440
|
+
separator = join60;
|
|
7441
7441
|
}
|
|
7442
7442
|
if (deterministic) {
|
|
7443
7443
|
keys = sort(keys, comparator);
|
|
@@ -7448,13 +7448,13 @@ ${indentation}`;
|
|
|
7448
7448
|
const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
|
|
7449
7449
|
if (tmp !== void 0) {
|
|
7450
7450
|
res += `${separator}${strEscape(key3)}: ${tmp}`;
|
|
7451
|
-
separator =
|
|
7451
|
+
separator = join60;
|
|
7452
7452
|
}
|
|
7453
7453
|
}
|
|
7454
7454
|
if (keyLength > maximumBreadth) {
|
|
7455
7455
|
const removedKeys = keyLength - maximumBreadth;
|
|
7456
7456
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
7457
|
-
separator =
|
|
7457
|
+
separator = join60;
|
|
7458
7458
|
}
|
|
7459
7459
|
if (separator !== "") {
|
|
7460
7460
|
res = `
|
|
@@ -41991,7 +41991,7 @@ var require_send = __commonJS({
|
|
|
41991
41991
|
var { parseTokenList } = require_parseTokenList();
|
|
41992
41992
|
var { createHttpError } = require_createHttpError();
|
|
41993
41993
|
var extname4 = path.extname;
|
|
41994
|
-
var
|
|
41994
|
+
var join60 = path.join;
|
|
41995
41995
|
var normalize2 = path.normalize;
|
|
41996
41996
|
var resolve17 = path.resolve;
|
|
41997
41997
|
var sep8 = path.sep;
|
|
@@ -42078,7 +42078,7 @@ var require_send = __commonJS({
|
|
|
42078
42078
|
return { statusCode: 403 };
|
|
42079
42079
|
}
|
|
42080
42080
|
parts = path2.split(sep8);
|
|
42081
|
-
path2 = normalize2(
|
|
42081
|
+
path2 = normalize2(join60(root5, path2));
|
|
42082
42082
|
} else {
|
|
42083
42083
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
42084
42084
|
debug('malicious path "%s"', path2);
|
|
@@ -42187,7 +42187,7 @@ var require_send = __commonJS({
|
|
|
42187
42187
|
});
|
|
42188
42188
|
});
|
|
42189
42189
|
}
|
|
42190
|
-
function
|
|
42190
|
+
function sendError3(statusCode, err2) {
|
|
42191
42191
|
const headers = {};
|
|
42192
42192
|
if (err2 && err2.headers) {
|
|
42193
42193
|
for (const headerName in err2.headers) {
|
|
@@ -42213,9 +42213,9 @@ var require_send = __commonJS({
|
|
|
42213
42213
|
case "ENAMETOOLONG":
|
|
42214
42214
|
case "ENOTDIR":
|
|
42215
42215
|
case "ENOENT":
|
|
42216
|
-
return
|
|
42216
|
+
return sendError3(404, err2);
|
|
42217
42217
|
default:
|
|
42218
|
-
return
|
|
42218
|
+
return sendError3(500, err2);
|
|
42219
42219
|
}
|
|
42220
42220
|
}
|
|
42221
42221
|
function sendNotModified(headers, path2, stat4) {
|
|
@@ -42274,7 +42274,7 @@ var require_send = __commonJS({
|
|
|
42274
42274
|
}
|
|
42275
42275
|
if (isConditionalGET(request)) {
|
|
42276
42276
|
if (isPreconditionFailure(request, headers)) {
|
|
42277
|
-
return
|
|
42277
|
+
return sendError3(412);
|
|
42278
42278
|
}
|
|
42279
42279
|
if (isNotModifiedFailure(request, headers)) {
|
|
42280
42280
|
return sendNotModified(headers, path2, stat4);
|
|
@@ -42293,7 +42293,7 @@ var require_send = __commonJS({
|
|
|
42293
42293
|
if (ranges.length === 0) {
|
|
42294
42294
|
debug("range unsatisfiable");
|
|
42295
42295
|
headers["Content-Range"] = contentRange("bytes", len);
|
|
42296
|
-
return
|
|
42296
|
+
return sendError3(416, {
|
|
42297
42297
|
headers: { "Content-Range": headers["Content-Range"] }
|
|
42298
42298
|
});
|
|
42299
42299
|
} else if (ranges.length === 1) {
|
|
@@ -42338,7 +42338,7 @@ var require_send = __commonJS({
|
|
|
42338
42338
|
}
|
|
42339
42339
|
function sendRedirect(path2, options) {
|
|
42340
42340
|
if (hasTrailingSlash(options.path)) {
|
|
42341
|
-
return
|
|
42341
|
+
return sendError3(403);
|
|
42342
42342
|
}
|
|
42343
42343
|
const loc = encodeURI(collapseLeadingSlashes(options.path + "/"));
|
|
42344
42344
|
const doc = createHtmlDocument("Redirecting", "Redirecting to " + escapeHtml(loc));
|
|
@@ -42361,7 +42361,7 @@ var require_send = __commonJS({
|
|
|
42361
42361
|
let err2;
|
|
42362
42362
|
for (let i = 0; i < options.index.length; i++) {
|
|
42363
42363
|
const index = options.index[i];
|
|
42364
|
-
const p =
|
|
42364
|
+
const p = join60(path2, index);
|
|
42365
42365
|
const { error, stat: stat4 } = await tryStat(p);
|
|
42366
42366
|
if (error) {
|
|
42367
42367
|
err2 = error;
|
|
@@ -42373,7 +42373,7 @@ var require_send = __commonJS({
|
|
|
42373
42373
|
if (err2) {
|
|
42374
42374
|
return sendStatError(err2);
|
|
42375
42375
|
}
|
|
42376
|
-
return
|
|
42376
|
+
return sendError3(404);
|
|
42377
42377
|
}
|
|
42378
42378
|
async function sendFile(request, path2, options) {
|
|
42379
42379
|
const { error, stat: stat4 } = await tryStat(path2);
|
|
@@ -42396,7 +42396,7 @@ var require_send = __commonJS({
|
|
|
42396
42396
|
if (err2) {
|
|
42397
42397
|
return sendStatError(err2);
|
|
42398
42398
|
}
|
|
42399
|
-
return
|
|
42399
|
+
return sendError3(404);
|
|
42400
42400
|
}
|
|
42401
42401
|
if (error) return sendStatError(error);
|
|
42402
42402
|
if (stat4.isDirectory()) return sendRedirect(path2, options);
|
|
@@ -42408,7 +42408,7 @@ var require_send = __commonJS({
|
|
|
42408
42408
|
const parsed = normalizePath3(_path, opts.root);
|
|
42409
42409
|
const { path: path2, parts } = parsed;
|
|
42410
42410
|
if (parsed.statusCode !== void 0) {
|
|
42411
|
-
return
|
|
42411
|
+
return sendError3(parsed.statusCode);
|
|
42412
42412
|
}
|
|
42413
42413
|
if ((debug.enabled || // if debugging is enabled, then check for all cases to log allow case
|
|
42414
42414
|
opts.dotfiles !== 0) && containsDotFile(parts)) {
|
|
@@ -42421,12 +42421,12 @@ var require_send = __commonJS({
|
|
|
42421
42421
|
/* c8 ignore stop */
|
|
42422
42422
|
case 2:
|
|
42423
42423
|
debug('deny dotfile "%s"', path2);
|
|
42424
|
-
return
|
|
42424
|
+
return sendError3(403);
|
|
42425
42425
|
case 1:
|
|
42426
42426
|
// 'ignore'
|
|
42427
42427
|
default:
|
|
42428
42428
|
debug('ignore dotfile "%s"', path2);
|
|
42429
|
-
return
|
|
42429
|
+
return sendError3(404);
|
|
42430
42430
|
}
|
|
42431
42431
|
}
|
|
42432
42432
|
if (opts.index.length && hasTrailingSlash(_path)) {
|
|
@@ -42657,7 +42657,7 @@ var require_content_disposition = __commonJS({
|
|
|
42657
42657
|
"use strict";
|
|
42658
42658
|
module2.exports = contentDisposition;
|
|
42659
42659
|
module2.exports.parse = parse;
|
|
42660
|
-
var
|
|
42660
|
+
var basename15 = require("path").basename;
|
|
42661
42661
|
var Buffer4 = require_safe_buffer().Buffer;
|
|
42662
42662
|
var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
|
|
42663
42663
|
var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
|
|
@@ -42693,9 +42693,9 @@ var require_content_disposition = __commonJS({
|
|
|
42693
42693
|
if (typeof fallback2 === "string" && NON_LATIN1_REGEXP.test(fallback2)) {
|
|
42694
42694
|
throw new TypeError("fallback must be ISO-8859-1 string");
|
|
42695
42695
|
}
|
|
42696
|
-
var name =
|
|
42696
|
+
var name = basename15(filename);
|
|
42697
42697
|
var isQuotedString = TEXT_REGEXP.test(name);
|
|
42698
|
-
var fallbackName = typeof fallback2 !== "string" ? fallback2 && getlatin1(name) :
|
|
42698
|
+
var fallbackName = typeof fallback2 !== "string" ? fallback2 && getlatin1(name) : basename15(fallback2);
|
|
42699
42699
|
var hasFallback = typeof fallbackName === "string" && fallbackName !== name;
|
|
42700
42700
|
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
|
|
42701
42701
|
params["filename*"] = name;
|
|
@@ -43145,8 +43145,8 @@ var require_static = __commonJS({
|
|
|
43145
43145
|
}
|
|
43146
43146
|
}
|
|
43147
43147
|
}
|
|
43148
|
-
for (const [
|
|
43149
|
-
const pathname =
|
|
43148
|
+
for (const [dirname28, rootPath] of indexDirs.entries()) {
|
|
43149
|
+
const pathname = dirname28 + (dirname28.endsWith("/") ? "" : "/");
|
|
43150
43150
|
const file = "/" + pathname.replace(prefix, "");
|
|
43151
43151
|
setUpHeadAndGet(routeOpts, pathname, file, rootPath);
|
|
43152
43152
|
if (opts.redirect === true) {
|
|
@@ -50827,9 +50827,9 @@ var import_node_readline2 = require("node:readline");
|
|
|
50827
50827
|
|
|
50828
50828
|
// index.ts
|
|
50829
50829
|
var import_node_url5 = require("node:url");
|
|
50830
|
-
var
|
|
50831
|
-
var
|
|
50832
|
-
var
|
|
50830
|
+
var import_node_path64 = require("node:path");
|
|
50831
|
+
var import_node_os34 = require("node:os");
|
|
50832
|
+
var import_node_fs68 = require("node:fs");
|
|
50833
50833
|
var import_node_child_process15 = require("node:child_process");
|
|
50834
50834
|
var import_node_util6 = require("node:util");
|
|
50835
50835
|
|
|
@@ -51930,6 +51930,9 @@ async function patch(id, fields) {
|
|
|
51930
51930
|
function resolveTemplateId(id) {
|
|
51931
51931
|
return readOrigin(id)?.derivedFrom ?? id;
|
|
51932
51932
|
}
|
|
51933
|
+
function sameAppLineage(a, b) {
|
|
51934
|
+
return a === b || resolveTemplateId(a) === resolveTemplateId(b);
|
|
51935
|
+
}
|
|
51933
51936
|
function resolveContractAuthorityId(id) {
|
|
51934
51937
|
if (!safeSegment(id)) throw new Error(`invalid contract authority app id: ${id}`);
|
|
51935
51938
|
assertNoPendingContractAuthorityOperation(id);
|
|
@@ -53032,12 +53035,47 @@ function newRunTicket() {
|
|
|
53032
53035
|
}
|
|
53033
53036
|
var activeRun = null;
|
|
53034
53037
|
var runChain = Promise.resolve();
|
|
53038
|
+
var TREE_KILL_RETRY_MS = 75;
|
|
53039
|
+
var TREE_KILL_MAX_ATTEMPTS = 20;
|
|
53040
|
+
var treeKillRetries = /* @__PURE__ */ new WeakMap();
|
|
53041
|
+
function retryWindowsTreeKill(child) {
|
|
53042
|
+
if (!child.pid || treeKillRetries.has(child)) return;
|
|
53043
|
+
const state2 = { attempts: 0, timer: null, closed: false };
|
|
53044
|
+
treeKillRetries.set(child, state2);
|
|
53045
|
+
const clear = () => {
|
|
53046
|
+
state2.closed = true;
|
|
53047
|
+
if (state2.timer) clearTimeout(state2.timer);
|
|
53048
|
+
treeKillRetries.delete(child);
|
|
53049
|
+
};
|
|
53050
|
+
child.once("close", clear);
|
|
53051
|
+
const attempt = () => {
|
|
53052
|
+
if (state2.closed || child.exitCode !== null || child.signalCode !== null) {
|
|
53053
|
+
clear();
|
|
53054
|
+
return;
|
|
53055
|
+
}
|
|
53056
|
+
state2.attempts += 1;
|
|
53057
|
+
(0, import_node_child_process2.execFile)("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: 1e3 }, (err2) => {
|
|
53058
|
+
if (!err2 || state2.closed) return;
|
|
53059
|
+
if (state2.attempts >= TREE_KILL_MAX_ATTEMPTS) {
|
|
53060
|
+
try {
|
|
53061
|
+
child.kill();
|
|
53062
|
+
} catch {
|
|
53063
|
+
}
|
|
53064
|
+
return;
|
|
53065
|
+
}
|
|
53066
|
+
state2.timer = setTimeout(attempt, TREE_KILL_RETRY_MS);
|
|
53067
|
+
});
|
|
53068
|
+
};
|
|
53069
|
+
attempt();
|
|
53070
|
+
}
|
|
53035
53071
|
function killTree(child) {
|
|
53036
53072
|
if (process.platform === "win32" && child.pid) {
|
|
53037
53073
|
try {
|
|
53038
53074
|
(0, import_node_child_process2.execFileSync)("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
|
|
53039
53075
|
return;
|
|
53040
53076
|
} catch {
|
|
53077
|
+
retryWindowsTreeKill(child);
|
|
53078
|
+
return;
|
|
53041
53079
|
}
|
|
53042
53080
|
}
|
|
53043
53081
|
try {
|
|
@@ -54612,7 +54650,7 @@ function appVersion() {
|
|
|
54612
54650
|
return resolveVersion({
|
|
54613
54651
|
isSea: isSea2(),
|
|
54614
54652
|
sqVersionXml: readSqVersionXml(),
|
|
54615
|
-
define: true ? "0.126.
|
|
54653
|
+
define: true ? "0.126.5" : void 0,
|
|
54616
54654
|
pkgVersion: readPkgVersion()
|
|
54617
54655
|
});
|
|
54618
54656
|
}
|
|
@@ -54628,7 +54666,7 @@ function resolveChannel(s) {
|
|
|
54628
54666
|
function appChannel() {
|
|
54629
54667
|
return resolveChannel({
|
|
54630
54668
|
isSea: isSea2(),
|
|
54631
|
-
define: true ? "0.126.
|
|
54669
|
+
define: true ? "0.126.5" : void 0,
|
|
54632
54670
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
54633
54671
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
54634
54672
|
modulePath: process.argv[1]
|
|
@@ -57552,7 +57590,7 @@ function createProject(input) {
|
|
|
57552
57590
|
writeMeta(meta);
|
|
57553
57591
|
return meta;
|
|
57554
57592
|
}
|
|
57555
|
-
function renameProject(id, name) {
|
|
57593
|
+
async function renameProject(id, name, migrateSidecars) {
|
|
57556
57594
|
const meta = readMeta(safeProjectId(id));
|
|
57557
57595
|
if (!meta) throw new ProjectError(`unknown project: ${id}`);
|
|
57558
57596
|
if (typeof name !== "string" || !name.trim()) throw new ProjectError("project name required");
|
|
@@ -57565,11 +57603,17 @@ function renameProject(id, name) {
|
|
|
57565
57603
|
} catch {
|
|
57566
57604
|
throw new ProjectError("couldn\u2019t rename the project folder \u2014 it may be open or in use. Close the project and try again.");
|
|
57567
57605
|
}
|
|
57606
|
+
let rollbackSidecars = void 0;
|
|
57568
57607
|
try {
|
|
57608
|
+
rollbackSidecars = await migrateSidecars?.(id, newId);
|
|
57569
57609
|
const next = { ...meta, id: newId, name: nextName, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
57570
57610
|
writeMeta(next);
|
|
57571
57611
|
return next;
|
|
57572
57612
|
} catch (e) {
|
|
57613
|
+
try {
|
|
57614
|
+
await rollbackSidecars?.();
|
|
57615
|
+
} catch {
|
|
57616
|
+
}
|
|
57573
57617
|
try {
|
|
57574
57618
|
(0, import_node_fs18.renameSync)(to, from);
|
|
57575
57619
|
} catch {
|
|
@@ -60130,7 +60174,11 @@ function kbClause(project, appId) {
|
|
|
60130
60174
|
if (!project) return "";
|
|
60131
60175
|
const guard = appId ? `&app=${appId}` : "";
|
|
60132
60176
|
return `
|
|
60133
|
-
First consult this project's knowledge base per your floless-app-knowledge skill: GET /api/workspace-projects/${project}/knowledge?q=<subject>${guard} returns ranked summaries of the firm's own standards, RFIs and spec notes (<subject> is what you are about to change, url-encoded; the q is required past a small knowledge base \u2014 an unqueried feed deliberately returns no pages); read a decisive one in full with GET /api/projects/${project}/knowledge/page/<slug
|
|
60177
|
+
First consult this project's knowledge base per your floless-app-knowledge skill: GET /api/workspace-projects/${project}/knowledge?q=<subject>${guard} returns ranked summaries of the firm's own standards, RFIs and spec notes (<subject> is what you are about to change, url-encoded; the q is required past a small knowledge base \u2014 an unqueried feed deliberately returns no pages); read a decisive one in full with GET /api/projects/${project}/knowledge/page/<slug>?generation=<generationId>, using the same generation.generationId the feed returned. Let those pages steer the change, and cite the slug you relied on so the user can trace it. If nothing relevant matches, say so rather than inventing a standard.` + pinClause(project, appId);
|
|
60178
|
+
}
|
|
60179
|
+
function pinClause(project, appId) {
|
|
60180
|
+
if (!appId) return "";
|
|
60181
|
+
return ` Once you have applied the change, record what informed it: PUT /api/kb-pin/${appId} with { "projectId": "${project}", "generationId": "<the generation.generationId the feed returned>", "pages": [{ "slug": "\u2026", "title": "\u2026" }] } \u2014 just the pages you actually relied on. Send the generation id you READ, even if the knowledge base has been re-organized since; it is a record of what this work was built from, not a claim about what is current, and the app shows the user when the two have diverged. If you consulted the knowledge base and nothing relevant matched, there is nothing to record \u2014 skip it rather than pinning an empty list.`;
|
|
60134
60182
|
}
|
|
60135
60183
|
function instructionFor(req) {
|
|
60136
60184
|
if (req.type === "use-template" && req.template) {
|
|
@@ -63910,8 +63958,11 @@ var GEN_KEEP = 3;
|
|
|
63910
63958
|
var vaultDir = (id) => (0, import_node_path31.join)(projectKnowledgeDir(id), "vault");
|
|
63911
63959
|
var generationsDir = (id) => (0, import_node_path31.join)(vaultDir(id), "generations");
|
|
63912
63960
|
var currentGenerationPath = (id) => (0, import_node_path31.join)(vaultDir(id), "current-generation.json");
|
|
63961
|
+
function isGenerationId(value) {
|
|
63962
|
+
return typeof value === "string" && GENERATION_ID_RE.test(value);
|
|
63963
|
+
}
|
|
63913
63964
|
function assertGenerationId(generationId) {
|
|
63914
|
-
if (
|
|
63965
|
+
if (!isGenerationId(generationId)) {
|
|
63915
63966
|
throw new KnowledgeError("invalid generation id");
|
|
63916
63967
|
}
|
|
63917
63968
|
}
|
|
@@ -63960,6 +64011,9 @@ function currentGenerationWikiDir(id) {
|
|
|
63960
64011
|
return (0, import_node_fs33.existsSync)(dir) ? dir : null;
|
|
63961
64012
|
}
|
|
63962
64013
|
var WIKI_SLUG_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
64014
|
+
function isWikiSlug(value) {
|
|
64015
|
+
return typeof value === "string" && WIKI_SLUG_RE.test(value);
|
|
64016
|
+
}
|
|
63963
64017
|
var KB_MAX_NODES = 300;
|
|
63964
64018
|
var KB_MAX_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
63965
64019
|
var KB_MAX_VISITS = 5e3;
|
|
@@ -64588,7 +64642,15 @@ function registerKnowledgeRoutes(app) {
|
|
|
64588
64642
|
try {
|
|
64589
64643
|
const project = getProject(req.params.id);
|
|
64590
64644
|
if (!project) return reply.status(404).send({ ok: false, error: `unknown project: ${req.params.id}` });
|
|
64591
|
-
|
|
64645
|
+
let wikiDir;
|
|
64646
|
+
if (req.query.generation === void 0) {
|
|
64647
|
+
wikiDir = currentGenerationWikiDir(project.id);
|
|
64648
|
+
} else if (typeof req.query.generation === "string" && isGenerationId(req.query.generation)) {
|
|
64649
|
+
const requested = generationWikiDir(project.id, req.query.generation);
|
|
64650
|
+
wikiDir = (0, import_node_fs34.existsSync)(requested) ? requested : null;
|
|
64651
|
+
} else {
|
|
64652
|
+
return reply.status(400).send({ ok: false, error: "invalid generation id" });
|
|
64653
|
+
}
|
|
64592
64654
|
const pg = wikiDir ? readPage(wikiDir, req.params.slug) : null;
|
|
64593
64655
|
if (!pg) return reply.status(404).send({ ok: false, error: "page not found" });
|
|
64594
64656
|
return { ok: true, page: pg };
|
|
@@ -76387,9 +76449,6 @@ function values(input) {
|
|
|
76387
76449
|
function optionalString(v) {
|
|
76388
76450
|
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
76389
76451
|
}
|
|
76390
|
-
function sameAppLineage(a, b) {
|
|
76391
|
-
return a === b || resolveTemplateId(a) === resolveTemplateId(b);
|
|
76392
|
-
}
|
|
76393
76452
|
function parseBool(v, fallback2) {
|
|
76394
76453
|
if (v === void 0) return fallback2;
|
|
76395
76454
|
if (Array.isArray(v)) return null;
|
|
@@ -76568,11 +76627,13 @@ function registerWorkspaceDataRoutes(app) {
|
|
|
76568
76627
|
const limit = parseIntParam(req.query.limit);
|
|
76569
76628
|
if (limit === null) return sendError(reply, 400, "invalid limit");
|
|
76570
76629
|
const q = optionalString(req.query.q);
|
|
76571
|
-
const
|
|
76572
|
-
if (!
|
|
76630
|
+
const generation = readCurrentGeneration(project.id);
|
|
76631
|
+
if (!generation) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
|
|
76632
|
+
const wikiDir = generationWikiDir(project.id, generation.generationId);
|
|
76633
|
+
if (!(0, import_node_fs48.existsSync)(wikiDir)) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
|
|
76573
76634
|
try {
|
|
76574
76635
|
const feed = readKnowledgeSummaries(wikiDir, { q, limit: limit ?? void 0 });
|
|
76575
|
-
return { ok: true, generation
|
|
76636
|
+
return { ok: true, generation, ...feed };
|
|
76576
76637
|
} catch (e) {
|
|
76577
76638
|
if (e instanceof KnowledgeError) return sendError(reply, knowledgeErrorStatus(e), e.message);
|
|
76578
76639
|
throw e;
|
|
@@ -76581,6 +76642,53 @@ function registerWorkspaceDataRoutes(app) {
|
|
|
76581
76642
|
);
|
|
76582
76643
|
}
|
|
76583
76644
|
|
|
76645
|
+
// app-id.ts
|
|
76646
|
+
var APP_ID4 = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
76647
|
+
function isSafeAppId2(value) {
|
|
76648
|
+
return typeof value === "string" && APP_ID4.test(value) && safeSegment(value);
|
|
76649
|
+
}
|
|
76650
|
+
|
|
76651
|
+
// contract-request-route.ts
|
|
76652
|
+
function registerContractRequestRoute(app, deps) {
|
|
76653
|
+
app.post(
|
|
76654
|
+
"/api/contract-request",
|
|
76655
|
+
{ bodyLimit: 25 * 1024 * 1024 },
|
|
76656
|
+
async (req, reply) => {
|
|
76657
|
+
const { appId, project, instruction, intent, target, snapshots } = req.body ?? {};
|
|
76658
|
+
if (!isSafeAppId2(appId)) {
|
|
76659
|
+
return reply.status(400).send({ ok: false, error: "invalid appId" });
|
|
76660
|
+
}
|
|
76661
|
+
if (typeof instruction !== "string" || !instruction) {
|
|
76662
|
+
return reply.status(400).send({ ok: false, error: "instruction required" });
|
|
76663
|
+
}
|
|
76664
|
+
let projectId;
|
|
76665
|
+
let requestAppId = appId;
|
|
76666
|
+
if (project !== void 0) {
|
|
76667
|
+
if (!isProjectId(project)) return reply.status(400).send({ ok: false, error: "invalid project id" });
|
|
76668
|
+
const targetProject = getProject(project);
|
|
76669
|
+
if (!targetProject) return reply.status(404).send({ ok: false, error: `unknown project: ${project}` });
|
|
76670
|
+
if (!sameAppLineage(appId, targetProject.app)) {
|
|
76671
|
+
return reply.status(404).send({ ok: false, error: `project "${targetProject.id}" belongs to app "${targetProject.app}", not "${appId}"` });
|
|
76672
|
+
}
|
|
76673
|
+
projectId = targetProject.id;
|
|
76674
|
+
requestAppId = targetProject.app;
|
|
76675
|
+
}
|
|
76676
|
+
let decoded;
|
|
76677
|
+
try {
|
|
76678
|
+
decoded = decodeSnapshots(snapshots);
|
|
76679
|
+
} catch (e) {
|
|
76680
|
+
return reply.status(400).send({ ok: false, error: e instanceof Error ? e.message : "bad snapshot" });
|
|
76681
|
+
}
|
|
76682
|
+
const request = addRequest(
|
|
76683
|
+
{ type: "tweak-contract", appId: requestAppId, ...projectId ? { project: projectId } : {}, instruction, ...intent ? { intent } : {}, ...target ? { target } : {} },
|
|
76684
|
+
decoded
|
|
76685
|
+
);
|
|
76686
|
+
deps.broadcast({ type: "request-added", request });
|
|
76687
|
+
return { ok: true, request: deps.requestView(request) };
|
|
76688
|
+
}
|
|
76689
|
+
);
|
|
76690
|
+
}
|
|
76691
|
+
|
|
76584
76692
|
// project-publication-state.ts
|
|
76585
76693
|
function classifyProjectPublicationState(appId, liveProjects) {
|
|
76586
76694
|
return liveProjects.some((project) => project.app === appId) ? "project-publication" : "project-publication-missing-project";
|
|
@@ -76737,17 +76845,79 @@ function registerMigrationCommitRoute(app, deps) {
|
|
|
76737
76845
|
var import_node_fs49 = require("node:fs");
|
|
76738
76846
|
var import_node_os22 = require("node:os");
|
|
76739
76847
|
var import_node_path44 = require("node:path");
|
|
76848
|
+
var WORKSPACE_MANIFEST_VERSION = "0.2.1";
|
|
76849
|
+
var OWNER_FILE = "floless-workspace.owner.json";
|
|
76740
76850
|
function awareHome() {
|
|
76741
76851
|
return process.env.AWARE_HOME || (0, import_node_path44.join)((0, import_node_os22.homedir)(), ".aware");
|
|
76742
76852
|
}
|
|
76743
76853
|
function workspaceAgentDir() {
|
|
76744
76854
|
return (0, import_node_path44.join)(awareHome(), "agents", "floless-workspace");
|
|
76745
76855
|
}
|
|
76746
|
-
function
|
|
76856
|
+
function ownerPath2(dir) {
|
|
76857
|
+
return (0, import_node_path44.join)(dir, OWNER_FILE);
|
|
76858
|
+
}
|
|
76859
|
+
function readOwner2(path) {
|
|
76860
|
+
try {
|
|
76861
|
+
const parsed = JSON.parse((0, import_node_fs49.readFileSync)(path, "utf8"));
|
|
76862
|
+
if (Number.isSafeInteger(parsed.pid) && parsed.pid > 0 && Number.isSafeInteger(parsed.port) && parsed.port > 0 && parsed.port <= 65535 && typeof parsed.manifestVersion === "string" && parsed.manifestVersion.length > 0) return {
|
|
76863
|
+
pid: parsed.pid,
|
|
76864
|
+
port: parsed.port,
|
|
76865
|
+
manifestVersion: parsed.manifestVersion
|
|
76866
|
+
};
|
|
76867
|
+
} catch {
|
|
76868
|
+
}
|
|
76869
|
+
return null;
|
|
76870
|
+
}
|
|
76871
|
+
function processIsAlive(pid) {
|
|
76872
|
+
try {
|
|
76873
|
+
process.kill(pid, 0);
|
|
76874
|
+
return true;
|
|
76875
|
+
} catch (err2) {
|
|
76876
|
+
return err2.code === "EPERM";
|
|
76877
|
+
}
|
|
76878
|
+
}
|
|
76879
|
+
function syncWorkspaceAgentManifest(port, deps = {}) {
|
|
76747
76880
|
const dir = workspaceAgentDir();
|
|
76748
76881
|
(0, import_node_fs49.mkdirSync)(dir, { recursive: true });
|
|
76882
|
+
const ownPath = ownerPath2(dir);
|
|
76883
|
+
const pid = deps.pid ?? process.pid;
|
|
76884
|
+
const isAlive = deps.isProcessAlive ?? processIsAlive;
|
|
76885
|
+
const mine = { pid, port, manifestVersion: WORKSPACE_MANIFEST_VERSION };
|
|
76886
|
+
let previousOwner = null;
|
|
76887
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
76888
|
+
const current = readOwner2(ownPath);
|
|
76889
|
+
if (current && isAlive(current.pid)) {
|
|
76890
|
+
if (current.pid !== pid) {
|
|
76891
|
+
return { path: (0, import_node_path44.join)(dir, "manifest.yaml"), owner: current, outcome: "preserved-live-owner", previousOwner: current };
|
|
76892
|
+
}
|
|
76893
|
+
previousOwner = current;
|
|
76894
|
+
break;
|
|
76895
|
+
}
|
|
76896
|
+
previousOwner = current;
|
|
76897
|
+
if ((0, import_node_fs49.existsSync)(ownPath)) {
|
|
76898
|
+
try {
|
|
76899
|
+
(0, import_node_fs49.unlinkSync)(ownPath);
|
|
76900
|
+
} catch {
|
|
76901
|
+
continue;
|
|
76902
|
+
}
|
|
76903
|
+
}
|
|
76904
|
+
try {
|
|
76905
|
+
(0, import_node_fs49.writeFileSync)(ownPath, `${JSON.stringify(mine)}
|
|
76906
|
+
`, { encoding: "utf8", flag: "wx" });
|
|
76907
|
+
break;
|
|
76908
|
+
} catch (err2) {
|
|
76909
|
+
if (err2.code !== "EEXIST") throw err2;
|
|
76910
|
+
}
|
|
76911
|
+
}
|
|
76912
|
+
const claimed2 = readOwner2(ownPath);
|
|
76913
|
+
if (!claimed2 || claimed2.pid !== mine.pid || claimed2.port !== mine.port) {
|
|
76914
|
+
if (claimed2 && isAlive(claimed2.pid)) {
|
|
76915
|
+
return { path: (0, import_node_path44.join)(dir, "manifest.yaml"), owner: claimed2, outcome: "preserved-live-owner", previousOwner: claimed2 };
|
|
76916
|
+
}
|
|
76917
|
+
throw new Error("could not claim floless-workspace manifest ownership");
|
|
76918
|
+
}
|
|
76749
76919
|
const manifest = `agent: floless-workspace
|
|
76750
|
-
version:
|
|
76920
|
+
version: ${WORKSPACE_MANIFEST_VERSION}
|
|
76751
76921
|
sdk-target: 2.4.0
|
|
76752
76922
|
display-name: FloLess Workspace
|
|
76753
76923
|
description: |
|
|
@@ -76890,8 +77060,24 @@ commands:
|
|
|
76890
77060
|
body: object
|
|
76891
77061
|
`;
|
|
76892
77062
|
const path = (0, import_node_path44.join)(dir, "manifest.yaml");
|
|
76893
|
-
|
|
76894
|
-
|
|
77063
|
+
try {
|
|
77064
|
+
(0, import_node_fs49.writeFileSync)(path, manifest, "utf8");
|
|
77065
|
+
} catch (err2) {
|
|
77066
|
+
const current = readOwner2(ownPath);
|
|
77067
|
+
if (current?.pid === mine.pid && current.port === mine.port) {
|
|
77068
|
+
try {
|
|
77069
|
+
(0, import_node_fs49.unlinkSync)(ownPath);
|
|
77070
|
+
} catch {
|
|
77071
|
+
}
|
|
77072
|
+
}
|
|
77073
|
+
throw err2;
|
|
77074
|
+
}
|
|
77075
|
+
return {
|
|
77076
|
+
path,
|
|
77077
|
+
owner: mine,
|
|
77078
|
+
outcome: previousOwner ? "reclaimed-stale-owner" : "written",
|
|
77079
|
+
previousOwner
|
|
77080
|
+
};
|
|
76895
77081
|
}
|
|
76896
77082
|
|
|
76897
77083
|
// steel-diff.ts
|
|
@@ -78498,6 +78684,14 @@ function awareFailureMessage(e, fallback2) {
|
|
|
78498
78684
|
if (!message || INPUTS_TEMPFILE.test(message)) return fallback2;
|
|
78499
78685
|
return message;
|
|
78500
78686
|
}
|
|
78687
|
+
function agentUpdateFailureMessage(e, id) {
|
|
78688
|
+
const fallback2 = `Could not update \u201C${id}\u201D.`;
|
|
78689
|
+
const message = awareFailureMessage(e, fallback2);
|
|
78690
|
+
if (/^conflict:\s*agent\s+\S+\s+has version\s+.+?\s+installed,\s+which the registry does not publish\b/i.test(message)) {
|
|
78691
|
+
return `\u201C${id}\u201D is a local copy, so it was not replaced by the registry version. This protects any local changes. To replace it deliberately, run \u201Caware agent update ${id} --force\u201D in a terminal.`;
|
|
78692
|
+
}
|
|
78693
|
+
return message;
|
|
78694
|
+
}
|
|
78501
78695
|
|
|
78502
78696
|
// scene-bake.ts
|
|
78503
78697
|
var import_node_fs51 = require("node:fs");
|
|
@@ -79717,9 +79911,9 @@ function nothingToApprove(contract) {
|
|
|
79717
79911
|
}
|
|
79718
79912
|
|
|
79719
79913
|
// app-lifecycle.ts
|
|
79720
|
-
var
|
|
79721
|
-
var
|
|
79722
|
-
var
|
|
79914
|
+
var import_node_fs57 = require("node:fs");
|
|
79915
|
+
var import_node_os26 = require("node:os");
|
|
79916
|
+
var import_node_path51 = require("node:path");
|
|
79723
79917
|
|
|
79724
79918
|
// routines.ts
|
|
79725
79919
|
var import_node_fs55 = require("node:fs");
|
|
@@ -80525,8 +80719,184 @@ async function stopScheduler() {
|
|
|
80525
80719
|
await stopAllSessions();
|
|
80526
80720
|
}
|
|
80527
80721
|
|
|
80722
|
+
// kb-pin-store.ts
|
|
80723
|
+
var import_node_fs56 = require("node:fs");
|
|
80724
|
+
var import_node_path50 = require("node:path");
|
|
80725
|
+
var import_node_os25 = require("node:os");
|
|
80726
|
+
var KbPinError = class extends Error {
|
|
80727
|
+
code;
|
|
80728
|
+
constructor(message, code) {
|
|
80729
|
+
super(message);
|
|
80730
|
+
this.name = "KbPinError";
|
|
80731
|
+
this.code = code;
|
|
80732
|
+
}
|
|
80733
|
+
};
|
|
80734
|
+
var pinsDir = () => (0, import_node_path50.join)(process.env.FLOLESS_HOME ?? (0, import_node_path50.join)((0, import_node_os25.homedir)(), ".floless"), "kb-pins");
|
|
80735
|
+
var withPinLock = (fn) => withLifecycleLock("internal-export", "kb-pin-store", fn);
|
|
80736
|
+
var KB_PIN_MAX_PAGES = 20;
|
|
80737
|
+
var KB_PIN_MAX_TITLE = 200;
|
|
80738
|
+
var ISO_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
80739
|
+
var isIsoTimestamp = (v) => {
|
|
80740
|
+
if (typeof v !== "string") return false;
|
|
80741
|
+
const m = ISO_RE.exec(v);
|
|
80742
|
+
if (!m) return false;
|
|
80743
|
+
const year = Number(m[1]);
|
|
80744
|
+
const month = Number(m[2]);
|
|
80745
|
+
const day2 = Number(m[3]);
|
|
80746
|
+
const hour2 = Number(m[4]);
|
|
80747
|
+
const minute = Number(m[5]);
|
|
80748
|
+
const second = Number(m[6]);
|
|
80749
|
+
const millis = Number((m[7] ?? "").padEnd(3, "0"));
|
|
80750
|
+
const offsetHour = Number(m[9] ?? 0);
|
|
80751
|
+
const offsetMinute = Number(m[10] ?? 0);
|
|
80752
|
+
if (offsetHour > 23 || offsetMinute > 59) return false;
|
|
80753
|
+
const calendar = /* @__PURE__ */ new Date(0);
|
|
80754
|
+
calendar.setUTCFullYear(year, month - 1, day2);
|
|
80755
|
+
calendar.setUTCHours(hour2, minute, second, millis);
|
|
80756
|
+
return calendar.getUTCFullYear() === year && calendar.getUTCMonth() === month - 1 && calendar.getUTCDate() === day2 && calendar.getUTCHours() === hour2 && calendar.getUTCMinutes() === minute && calendar.getUTCSeconds() === second && Number.isFinite(Date.parse(v));
|
|
80757
|
+
};
|
|
80758
|
+
function safeAppId(appId) {
|
|
80759
|
+
if (typeof appId !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(appId)) {
|
|
80760
|
+
throw new KbPinError(`invalid appId: ${String(appId)}`, "invalid-app");
|
|
80761
|
+
}
|
|
80762
|
+
return appId;
|
|
80763
|
+
}
|
|
80764
|
+
var isProjectId2 = (v) => typeof v === "string" && /^[a-z0-9][a-z0-9-]*$/.test(v);
|
|
80765
|
+
var pinPath = (appId) => (0, import_node_path50.join)(pinsDir(), `${safeAppId(appId)}.json`);
|
|
80766
|
+
function assertAppId(appId) {
|
|
80767
|
+
safeAppId(appId);
|
|
80768
|
+
}
|
|
80769
|
+
function normalizePages(pages) {
|
|
80770
|
+
if (!Array.isArray(pages)) throw new KbPinError("pages must be an array", "invalid-pages");
|
|
80771
|
+
if (pages.length > KB_PIN_MAX_PAGES) {
|
|
80772
|
+
throw new KbPinError(`pages must be at most ${KB_PIN_MAX_PAGES} entries`, "invalid-pages");
|
|
80773
|
+
}
|
|
80774
|
+
const seen = /* @__PURE__ */ new Set();
|
|
80775
|
+
const out = [];
|
|
80776
|
+
for (const page of pages) {
|
|
80777
|
+
const p = page;
|
|
80778
|
+
if (!p || typeof p !== "object") throw new KbPinError("each page must be an object", "invalid-pages");
|
|
80779
|
+
if (!isWikiSlug(p.slug)) throw new KbPinError(`invalid page slug: ${String(p.slug)}`, "invalid-pages");
|
|
80780
|
+
if (typeof p.title !== "string" || p.title.length > KB_PIN_MAX_TITLE) {
|
|
80781
|
+
throw new KbPinError(`invalid page title for "${p.slug}"`, "invalid-pages");
|
|
80782
|
+
}
|
|
80783
|
+
if (seen.has(p.slug)) continue;
|
|
80784
|
+
seen.add(p.slug);
|
|
80785
|
+
out.push({ slug: p.slug, title: p.title });
|
|
80786
|
+
}
|
|
80787
|
+
return out;
|
|
80788
|
+
}
|
|
80789
|
+
function readPinUnlocked(appId) {
|
|
80790
|
+
const p = pinPath(appId);
|
|
80791
|
+
if (!(0, import_node_fs56.existsSync)(p)) return null;
|
|
80792
|
+
try {
|
|
80793
|
+
const parsed = JSON.parse((0, import_node_fs56.readFileSync)(p, "utf8"));
|
|
80794
|
+
if (!parsed || typeof parsed !== "object") {
|
|
80795
|
+
console.warn(`kb-pin-store: ignoring schema-invalid pin at ${p} (not an object)`);
|
|
80796
|
+
return null;
|
|
80797
|
+
}
|
|
80798
|
+
if (!isProjectId2(parsed.projectId) || !isGenerationId(parsed.generationId) || !isIsoTimestamp(parsed.pinnedAt)) {
|
|
80799
|
+
console.warn(`kb-pin-store: ignoring schema-invalid pin at ${p} (bad projectId/generationId/pinnedAt)`);
|
|
80800
|
+
return null;
|
|
80801
|
+
}
|
|
80802
|
+
let pages;
|
|
80803
|
+
try {
|
|
80804
|
+
pages = normalizePages(parsed.pages);
|
|
80805
|
+
} catch (e) {
|
|
80806
|
+
console.warn(`kb-pin-store: ignoring schema-invalid pin at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
80807
|
+
return null;
|
|
80808
|
+
}
|
|
80809
|
+
return { projectId: parsed.projectId, generationId: parsed.generationId, pinnedAt: parsed.pinnedAt, pages };
|
|
80810
|
+
} catch (e) {
|
|
80811
|
+
console.warn(`kb-pin-store: ignoring unreadable pin at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
80812
|
+
return null;
|
|
80813
|
+
}
|
|
80814
|
+
}
|
|
80815
|
+
function readPin(appId) {
|
|
80816
|
+
return withPinLock(() => readPinUnlocked(appId));
|
|
80817
|
+
}
|
|
80818
|
+
function writePinUnlocked(appId, pin) {
|
|
80819
|
+
const p = pinPath(appId);
|
|
80820
|
+
if (!isProjectId2(pin.projectId)) {
|
|
80821
|
+
throw new KbPinError(`invalid project id: ${String(pin.projectId)}`, "invalid-project");
|
|
80822
|
+
}
|
|
80823
|
+
if (!isGenerationId(pin.generationId)) {
|
|
80824
|
+
throw new KbPinError(`invalid generation id: ${String(pin.generationId)}`, "invalid-generation");
|
|
80825
|
+
}
|
|
80826
|
+
const doc = {
|
|
80827
|
+
projectId: pin.projectId,
|
|
80828
|
+
generationId: pin.generationId,
|
|
80829
|
+
pinnedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
80830
|
+
pages: normalizePages(pin.pages)
|
|
80831
|
+
};
|
|
80832
|
+
(0, import_node_fs56.mkdirSync)((0, import_node_path50.dirname)(p), { recursive: true });
|
|
80833
|
+
writeJsonAtomic(p, doc);
|
|
80834
|
+
return doc;
|
|
80835
|
+
}
|
|
80836
|
+
function writePin(appId, pin) {
|
|
80837
|
+
return withPinLock(() => writePinUnlocked(appId, pin));
|
|
80838
|
+
}
|
|
80839
|
+
function movePinBytesUnlocked(fromAppId, toAppId) {
|
|
80840
|
+
const from = pinPath(fromAppId);
|
|
80841
|
+
const to = pinPath(toAppId);
|
|
80842
|
+
if (from === to || !(0, import_node_fs56.existsSync)(from)) return false;
|
|
80843
|
+
(0, import_node_fs56.mkdirSync)((0, import_node_path50.dirname)(to), { recursive: true });
|
|
80844
|
+
(0, import_node_fs56.renameSync)(from, to);
|
|
80845
|
+
return true;
|
|
80846
|
+
}
|
|
80847
|
+
function movePinBytes(fromAppId, toAppId) {
|
|
80848
|
+
return withPinLock(() => movePinBytesUnlocked(fromAppId, toAppId));
|
|
80849
|
+
}
|
|
80850
|
+
function dropPinBytesUnlocked(appId) {
|
|
80851
|
+
const p = pinPath(appId);
|
|
80852
|
+
if (!(0, import_node_fs56.existsSync)(p)) return false;
|
|
80853
|
+
(0, import_node_fs56.rmSync)(p, { force: true });
|
|
80854
|
+
return true;
|
|
80855
|
+
}
|
|
80856
|
+
function dropPinBytes(appId) {
|
|
80857
|
+
return withPinLock(() => dropPinBytesUnlocked(appId));
|
|
80858
|
+
}
|
|
80859
|
+
function repointProjectPinsUnlocked(fromProjectId, toProjectId) {
|
|
80860
|
+
if (!isProjectId2(fromProjectId) || !isProjectId2(toProjectId)) {
|
|
80861
|
+
throw new KbPinError("invalid project id for pin repoint", "invalid-project");
|
|
80862
|
+
}
|
|
80863
|
+
if (fromProjectId === toProjectId || !(0, import_node_fs56.existsSync)(pinsDir())) return 0;
|
|
80864
|
+
const targets = [];
|
|
80865
|
+
for (const entry2 of (0, import_node_fs56.readdirSync)(pinsDir(), { withFileTypes: true })) {
|
|
80866
|
+
if (!entry2.isFile() || !entry2.name.endsWith(".json")) continue;
|
|
80867
|
+
const appId = (0, import_node_path50.basename)(entry2.name, ".json");
|
|
80868
|
+
let pin;
|
|
80869
|
+
try {
|
|
80870
|
+
pin = readPinUnlocked(appId);
|
|
80871
|
+
} catch {
|
|
80872
|
+
continue;
|
|
80873
|
+
}
|
|
80874
|
+
if (!pin || pin.projectId !== fromProjectId) continue;
|
|
80875
|
+
targets.push({ path: pinPath(appId), pin });
|
|
80876
|
+
}
|
|
80877
|
+
const written = [];
|
|
80878
|
+
try {
|
|
80879
|
+
for (const target of targets) {
|
|
80880
|
+
writeJsonAtomic(target.path, { ...target.pin, projectId: toProjectId });
|
|
80881
|
+
written.push(target);
|
|
80882
|
+
}
|
|
80883
|
+
} catch (e) {
|
|
80884
|
+
for (const target of written.reverse()) {
|
|
80885
|
+
try {
|
|
80886
|
+
writeJsonAtomic(target.path, target.pin);
|
|
80887
|
+
} catch {
|
|
80888
|
+
}
|
|
80889
|
+
}
|
|
80890
|
+
throw e;
|
|
80891
|
+
}
|
|
80892
|
+
return targets.length;
|
|
80893
|
+
}
|
|
80894
|
+
function repointProjectPins(fromProjectId, toProjectId) {
|
|
80895
|
+
return withPinLock(() => repointProjectPinsUnlocked(fromProjectId, toProjectId));
|
|
80896
|
+
}
|
|
80897
|
+
|
|
80528
80898
|
// app-lifecycle.ts
|
|
80529
|
-
var
|
|
80899
|
+
var APP_ID5 = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
80530
80900
|
var AppLifecycleError = class extends Error {
|
|
80531
80901
|
status;
|
|
80532
80902
|
constructor(message, status) {
|
|
@@ -80536,17 +80906,27 @@ var AppLifecycleError = class extends Error {
|
|
|
80536
80906
|
}
|
|
80537
80907
|
};
|
|
80538
80908
|
function appsDir() {
|
|
80539
|
-
return process.env.AWARE_HOME ? (0,
|
|
80909
|
+
return process.env.AWARE_HOME ? (0, import_node_path51.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path51.join)((0, import_node_os26.homedir)(), ".aware", "apps");
|
|
80540
80910
|
}
|
|
80541
80911
|
function appDirPath(id) {
|
|
80542
|
-
return (0,
|
|
80912
|
+
return (0, import_node_path51.join)(appsDir(), id);
|
|
80543
80913
|
}
|
|
80544
80914
|
function appInstalled(id) {
|
|
80545
|
-
return
|
|
80915
|
+
return APP_ID5.test(id) && (0, import_node_fs57.existsSync)(appDirPath(id));
|
|
80546
80916
|
}
|
|
80547
80917
|
function logCascade(what, e) {
|
|
80548
80918
|
console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
|
|
80549
80919
|
}
|
|
80920
|
+
async function clearDestinationPin(newId) {
|
|
80921
|
+
try {
|
|
80922
|
+
await dropPinBytes(newId);
|
|
80923
|
+
} catch (e) {
|
|
80924
|
+
throw new AppLifecycleError(
|
|
80925
|
+
`could not clear stale knowledge provenance for "${newId}": ${e instanceof Error ? e.message : String(e)}`,
|
|
80926
|
+
500
|
|
80927
|
+
);
|
|
80928
|
+
}
|
|
80929
|
+
}
|
|
80550
80930
|
function mapAwareError(e) {
|
|
80551
80931
|
const code = e instanceof AwareError ? e.detail?.code : void 0;
|
|
80552
80932
|
if (code === 8) throw new AppLifecycleError("a workflow with that name already exists", 409);
|
|
@@ -80555,7 +80935,7 @@ function mapAwareError(e) {
|
|
|
80555
80935
|
throw e;
|
|
80556
80936
|
}
|
|
80557
80937
|
function assertNewId(newId) {
|
|
80558
|
-
if (!newId || !
|
|
80938
|
+
if (!newId || !APP_ID5.test(newId) || !safeSegment(newId)) {
|
|
80559
80939
|
throw new AppLifecycleError('name must be letters, digits, dot, dash or underscore (no spaces, slashes or "..")', 400);
|
|
80560
80940
|
}
|
|
80561
80941
|
}
|
|
@@ -80569,6 +80949,7 @@ async function renameApp(oldId, newId, deps = defaultDeps2) {
|
|
|
80569
80949
|
assertNewId(newId);
|
|
80570
80950
|
if (newId === oldId) throw new AppLifecycleError("that is already its name", 400);
|
|
80571
80951
|
if (appInstalled(newId)) throw new AppLifecycleError(`a workflow named "${newId}" already exists`, 409);
|
|
80952
|
+
await clearDestinationPin(newId);
|
|
80572
80953
|
const originRenameToken = await beginOriginRename(oldId, newId);
|
|
80573
80954
|
let compiled;
|
|
80574
80955
|
let originCompleted = false;
|
|
@@ -80623,6 +81004,11 @@ async function renameApp(oldId, newId, deps = defaultDeps2) {
|
|
|
80623
81004
|
} catch (e) {
|
|
80624
81005
|
logCascade("move contract", e);
|
|
80625
81006
|
}
|
|
81007
|
+
try {
|
|
81008
|
+
await movePinBytes(oldId, newId);
|
|
81009
|
+
} catch (e) {
|
|
81010
|
+
logCascade("move knowledge pin", e);
|
|
81011
|
+
}
|
|
80626
81012
|
let projectsStale;
|
|
80627
81013
|
try {
|
|
80628
81014
|
projectsStale = repointProjects(oldId, newId).skipped.length;
|
|
@@ -80636,6 +81022,7 @@ async function duplicateApp(srcId, newId, deps = defaultDeps2) {
|
|
|
80636
81022
|
if (!appInstalled(srcId)) throw new AppLifecycleError(`workflow not found: ${srcId}`, 404);
|
|
80637
81023
|
assertNewId(newId);
|
|
80638
81024
|
if (appInstalled(newId)) throw new AppLifecycleError(`a workflow named "${newId}" already exists`, 409);
|
|
81025
|
+
await clearDestinationPin(newId);
|
|
80639
81026
|
const originDuplicateToken = await beginOriginDuplicate(srcId, newId);
|
|
80640
81027
|
let compiled;
|
|
80641
81028
|
let originCompleted = false;
|
|
@@ -80726,6 +81113,80 @@ async function deleteApp(id, deps = defaultDeps2) {
|
|
|
80726
81113
|
} catch (e) {
|
|
80727
81114
|
logCascade("drop contract", e);
|
|
80728
81115
|
}
|
|
81116
|
+
try {
|
|
81117
|
+
await dropPinBytes(id);
|
|
81118
|
+
} catch (e) {
|
|
81119
|
+
logCascade("drop knowledge pin", e);
|
|
81120
|
+
}
|
|
81121
|
+
}
|
|
81122
|
+
|
|
81123
|
+
// kb-pin-routes.ts
|
|
81124
|
+
var import_node_fs58 = require("node:fs");
|
|
81125
|
+
function driftOf(pin) {
|
|
81126
|
+
const cur = readCurrentGeneration(pin.projectId);
|
|
81127
|
+
if (cur === null) return true;
|
|
81128
|
+
if (!(0, import_node_fs58.existsSync)(generationWikiDir(pin.projectId, cur.generationId))) return true;
|
|
81129
|
+
return cur.generationId !== pin.generationId;
|
|
81130
|
+
}
|
|
81131
|
+
function registerKbPinRoutes(app, deps) {
|
|
81132
|
+
app.get("/api/kb-pin/:appId", async (req, reply) => {
|
|
81133
|
+
try {
|
|
81134
|
+
const pin = await readPin(req.params.appId);
|
|
81135
|
+
return { ok: true, pin, drift: pin === null ? false : driftOf(pin) };
|
|
81136
|
+
} catch (e) {
|
|
81137
|
+
return sendError2(reply, e);
|
|
81138
|
+
}
|
|
81139
|
+
});
|
|
81140
|
+
app.put(
|
|
81141
|
+
"/api/kb-pin/:appId",
|
|
81142
|
+
async (req, reply) => {
|
|
81143
|
+
try {
|
|
81144
|
+
const { appId } = req.params;
|
|
81145
|
+
assertAppId(appId);
|
|
81146
|
+
const body = req.body ?? {};
|
|
81147
|
+
if (typeof body.projectId !== "string") {
|
|
81148
|
+
return reply.status(400).send({ ok: false, error: "projectId must be a string", code: "invalid-body" });
|
|
81149
|
+
}
|
|
81150
|
+
if (typeof body.generationId !== "string") {
|
|
81151
|
+
return reply.status(400).send({ ok: false, error: "generationId must be a string", code: "invalid-body" });
|
|
81152
|
+
}
|
|
81153
|
+
const projectId = body.projectId;
|
|
81154
|
+
const generationId = body.generationId;
|
|
81155
|
+
return await withLifecycleLock("app", appId, async () => {
|
|
81156
|
+
if (!appInstalled(appId)) {
|
|
81157
|
+
return reply.status(404).send({ ok: false, error: `unknown workflow: ${appId}`, code: "unknown-app" });
|
|
81158
|
+
}
|
|
81159
|
+
getProject(projectId);
|
|
81160
|
+
return withLifecycleLock("project", projectId, async () => {
|
|
81161
|
+
const project = getProject(projectId);
|
|
81162
|
+
if (!project) {
|
|
81163
|
+
return reply.status(404).send({ ok: false, error: `unknown project: ${projectId}`, code: "unknown-project" });
|
|
81164
|
+
}
|
|
81165
|
+
if (!sameAppLineage(appId, project.app)) {
|
|
81166
|
+
return reply.status(404).send({
|
|
81167
|
+
ok: false,
|
|
81168
|
+
error: `project ${projectId} does not belong to workflow ${appId}`,
|
|
81169
|
+
code: "project-app-mismatch"
|
|
81170
|
+
});
|
|
81171
|
+
}
|
|
81172
|
+
const pin = await writePin(appId, { projectId, generationId, pages: body.pages });
|
|
81173
|
+
deps.broadcast({ type: "kb-pin-changed", id: appId });
|
|
81174
|
+
return { ok: true, pin, drift: driftOf(pin) };
|
|
81175
|
+
});
|
|
81176
|
+
});
|
|
81177
|
+
} catch (e) {
|
|
81178
|
+
return sendError2(reply, e);
|
|
81179
|
+
}
|
|
81180
|
+
}
|
|
81181
|
+
);
|
|
81182
|
+
}
|
|
81183
|
+
function sendError2(reply, e) {
|
|
81184
|
+
if (e instanceof KbPinError) return reply.status(400).send({ ok: false, error: e.message, code: e.code });
|
|
81185
|
+
if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message, code: "invalid-project" });
|
|
81186
|
+
if (e instanceof KnowledgeError) {
|
|
81187
|
+
return reply.status(knowledgeErrorStatus(e)).send({ ok: false, error: e.message, code: e.code ?? "invalid-generation" });
|
|
81188
|
+
}
|
|
81189
|
+
throw e;
|
|
80729
81190
|
}
|
|
80730
81191
|
|
|
80731
81192
|
// route-gate.ts
|
|
@@ -80780,9 +81241,9 @@ function isGatedAwareRoute(url, method) {
|
|
|
80780
81241
|
|
|
80781
81242
|
// autostart.mjs
|
|
80782
81243
|
var import_node_child_process8 = require("node:child_process");
|
|
80783
|
-
var
|
|
80784
|
-
var
|
|
80785
|
-
var
|
|
81244
|
+
var import_node_fs59 = require("node:fs");
|
|
81245
|
+
var import_node_os27 = require("node:os");
|
|
81246
|
+
var import_node_path52 = require("node:path");
|
|
80786
81247
|
|
|
80787
81248
|
// teardown.mjs
|
|
80788
81249
|
var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
@@ -80894,8 +81355,8 @@ function removeLegacyRunKey() {
|
|
|
80894
81355
|
}
|
|
80895
81356
|
function logLine(msg) {
|
|
80896
81357
|
try {
|
|
80897
|
-
(0,
|
|
80898
|
-
(0,
|
|
81358
|
+
(0, import_node_fs59.mkdirSync)(logDir(), { recursive: true });
|
|
81359
|
+
(0, import_node_fs59.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
80899
81360
|
`);
|
|
80900
81361
|
} catch {
|
|
80901
81362
|
}
|
|
@@ -80903,8 +81364,8 @@ function logLine(msg) {
|
|
|
80903
81364
|
function registerAutostart(exePath) {
|
|
80904
81365
|
if (!isWin) return;
|
|
80905
81366
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
80906
|
-
const tmp = (0,
|
|
80907
|
-
(0,
|
|
81367
|
+
const tmp = (0, import_node_path52.join)((0, import_node_os27.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
81368
|
+
(0, import_node_fs59.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
80908
81369
|
try {
|
|
80909
81370
|
(0, import_node_child_process8.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
80910
81371
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -80915,7 +81376,7 @@ function registerAutostart(exePath) {
|
|
|
80915
81376
|
throw err2;
|
|
80916
81377
|
} finally {
|
|
80917
81378
|
try {
|
|
80918
|
-
(0,
|
|
81379
|
+
(0, import_node_fs59.rmSync)(tmp, { force: true });
|
|
80919
81380
|
} catch {
|
|
80920
81381
|
}
|
|
80921
81382
|
}
|
|
@@ -80950,26 +81411,26 @@ function unregisterAutostart() {
|
|
|
80950
81411
|
// updater.ts
|
|
80951
81412
|
var import_node_child_process9 = require("node:child_process");
|
|
80952
81413
|
var import_node_crypto31 = require("node:crypto");
|
|
80953
|
-
var
|
|
81414
|
+
var import_node_fs61 = require("node:fs");
|
|
80954
81415
|
var import_node_stream3 = require("node:stream");
|
|
80955
81416
|
var import_promises5 = require("node:stream/promises");
|
|
80956
|
-
var
|
|
81417
|
+
var import_node_path54 = require("node:path");
|
|
80957
81418
|
|
|
80958
81419
|
// post-update-marker.mjs
|
|
80959
|
-
var
|
|
80960
|
-
var
|
|
80961
|
-
var
|
|
81420
|
+
var import_node_fs60 = require("node:fs");
|
|
81421
|
+
var import_node_os28 = require("node:os");
|
|
81422
|
+
var import_node_path53 = require("node:path");
|
|
80962
81423
|
var FRESH_MS = 12e4;
|
|
80963
81424
|
function markerPath() {
|
|
80964
81425
|
const override = (process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim();
|
|
80965
81426
|
if (override) return override;
|
|
80966
|
-
const root5 = process.env.FLOLESS_HOME ?? (0,
|
|
80967
|
-
return (0,
|
|
81427
|
+
const root5 = process.env.FLOLESS_HOME ?? (0, import_node_path53.join)((0, import_node_os28.homedir)(), ".floless");
|
|
81428
|
+
return (0, import_node_path53.join)(root5, ".post-update");
|
|
80968
81429
|
}
|
|
80969
81430
|
function legacyMarkerPath() {
|
|
80970
81431
|
if ((process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim()) return null;
|
|
80971
81432
|
try {
|
|
80972
|
-
return (0,
|
|
81433
|
+
return (0, import_node_path53.join)((0, import_node_path53.dirname)((0, import_node_path53.dirname)(process.execPath)), ".floless-post-update");
|
|
80973
81434
|
} catch {
|
|
80974
81435
|
return null;
|
|
80975
81436
|
}
|
|
@@ -80979,7 +81440,7 @@ function writePostUpdateMarker() {
|
|
|
80979
81440
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
80980
81441
|
if (!p) continue;
|
|
80981
81442
|
try {
|
|
80982
|
-
(0,
|
|
81443
|
+
(0, import_node_fs60.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
|
|
80983
81444
|
wrote = true;
|
|
80984
81445
|
} catch {
|
|
80985
81446
|
}
|
|
@@ -80991,9 +81452,9 @@ function consumePostUpdateMarker() {
|
|
|
80991
81452
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
80992
81453
|
if (!p) continue;
|
|
80993
81454
|
try {
|
|
80994
|
-
if (!(0,
|
|
80995
|
-
const ageMs = Date.now() - (0,
|
|
80996
|
-
(0,
|
|
81455
|
+
if (!(0, import_node_fs60.existsSync)(p)) continue;
|
|
81456
|
+
const ageMs = Date.now() - (0, import_node_fs60.statSync)(p).mtimeMs;
|
|
81457
|
+
(0, import_node_fs60.rmSync)(p, { force: true });
|
|
80997
81458
|
if (ageMs < FRESH_MS) fresh = true;
|
|
80998
81459
|
} catch {
|
|
80999
81460
|
}
|
|
@@ -81010,13 +81471,13 @@ function currentVersion() {
|
|
|
81010
81471
|
return appVersion();
|
|
81011
81472
|
}
|
|
81012
81473
|
function installRoot() {
|
|
81013
|
-
return (0,
|
|
81474
|
+
return (0, import_node_path54.dirname)((0, import_node_path54.dirname)(process.execPath));
|
|
81014
81475
|
}
|
|
81015
81476
|
function updateExePath() {
|
|
81016
|
-
return (0,
|
|
81477
|
+
return (0, import_node_path54.join)(installRoot(), "Update.exe");
|
|
81017
81478
|
}
|
|
81018
81479
|
function packagesDir() {
|
|
81019
|
-
return (0,
|
|
81480
|
+
return (0, import_node_path54.join)(installRoot(), "packages");
|
|
81020
81481
|
}
|
|
81021
81482
|
function feedUrl() {
|
|
81022
81483
|
const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
|
|
@@ -81107,22 +81568,22 @@ async function checkForUpdate() {
|
|
|
81107
81568
|
}
|
|
81108
81569
|
async function sha1OfFile(path) {
|
|
81109
81570
|
const hash2 = (0, import_node_crypto31.createHash)("sha1");
|
|
81110
|
-
await (0, import_promises5.pipeline)((0,
|
|
81571
|
+
await (0, import_promises5.pipeline)((0, import_node_fs61.createReadStream)(path), hash2);
|
|
81111
81572
|
return hash2.digest("hex").toUpperCase();
|
|
81112
81573
|
}
|
|
81113
81574
|
async function downloadPackage(asset) {
|
|
81114
81575
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
81115
81576
|
const want = asset.SHA1.toUpperCase();
|
|
81116
81577
|
const dir = packagesDir();
|
|
81117
|
-
(0,
|
|
81118
|
-
const dest = (0,
|
|
81119
|
-
if ((0,
|
|
81578
|
+
(0, import_node_fs61.mkdirSync)(dir, { recursive: true });
|
|
81579
|
+
const dest = (0, import_node_path54.join)(dir, asset.FileName);
|
|
81580
|
+
if ((0, import_node_fs61.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
81120
81581
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
81121
81582
|
redirect: "follow",
|
|
81122
81583
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
81123
81584
|
});
|
|
81124
81585
|
if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
|
|
81125
|
-
await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0,
|
|
81586
|
+
await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs61.createWriteStream)(dest));
|
|
81126
81587
|
const got = await sha1OfFile(dest);
|
|
81127
81588
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
81128
81589
|
return dest;
|
|
@@ -81131,7 +81592,7 @@ async function applyUpdate(check, opts) {
|
|
|
81131
81592
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
81132
81593
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
81133
81594
|
const exe2 = updateExePath();
|
|
81134
|
-
if (!(0,
|
|
81595
|
+
if (!(0, import_node_fs61.existsSync)(exe2)) {
|
|
81135
81596
|
return { applied: false, message: `Update.exe not found at ${exe2} \u2014 is this a Velopack install?` };
|
|
81136
81597
|
}
|
|
81137
81598
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -81371,12 +81832,12 @@ function isTraceCorrupt(events) {
|
|
|
81371
81832
|
|
|
81372
81833
|
// launch.mjs
|
|
81373
81834
|
var import_node_child_process10 = require("node:child_process");
|
|
81374
|
-
var
|
|
81835
|
+
var import_node_path55 = require("node:path");
|
|
81375
81836
|
var import_node_url3 = require("node:url");
|
|
81376
|
-
var
|
|
81837
|
+
var import_node_fs62 = require("node:fs");
|
|
81377
81838
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
81378
81839
|
var import_node_readline = require("node:readline");
|
|
81379
|
-
var __dirname2 = (0,
|
|
81840
|
+
var __dirname2 = (0, import_node_path55.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
81380
81841
|
var PORT = Number(process.env.PORT ?? 4317);
|
|
81381
81842
|
var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
|
|
81382
81843
|
var BROWSER_URL = `http://floless.localhost:${PORT}`;
|
|
@@ -81454,8 +81915,8 @@ async function waitHealthy(timeoutMs = 3e4) {
|
|
|
81454
81915
|
function resolveServerStart() {
|
|
81455
81916
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
81456
81917
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
81457
|
-
const bundle = (0,
|
|
81458
|
-
if ((0,
|
|
81918
|
+
const bundle = (0, import_node_path55.join)(__dirname2, "dist", "floless-server.cjs");
|
|
81919
|
+
if ((0, import_node_fs62.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
81459
81920
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
81460
81921
|
}
|
|
81461
81922
|
function startServerDetached() {
|
|
@@ -81608,8 +82069,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
|
|
|
81608
82069
|
}
|
|
81609
82070
|
function killSupervisor({ tree = true } = {}) {
|
|
81610
82071
|
if (!isWin2) return;
|
|
81611
|
-
const isNpmChannel = /^node(\.exe)?$/i.test((0,
|
|
81612
|
-
const scriptMatch = isNpmChannel ? (0,
|
|
82072
|
+
const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path55.basename)(process.execPath));
|
|
82073
|
+
const scriptMatch = isNpmChannel ? (0, import_node_path55.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
|
|
81613
82074
|
const realExe = resolveRealInstallExe(process.execPath);
|
|
81614
82075
|
const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
|
|
81615
82076
|
const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
|
|
@@ -81780,7 +82241,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null, selfChannel = n
|
|
|
81780
82241
|
}
|
|
81781
82242
|
await action(parseTeardownFlags(flagArgv));
|
|
81782
82243
|
}
|
|
81783
|
-
var entry = (0,
|
|
82244
|
+
var entry = (0, import_node_path55.basename)(process.argv[1] ?? "").toLowerCase();
|
|
81784
82245
|
if (entry === "launch.mjs") {
|
|
81785
82246
|
runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
|
|
81786
82247
|
log(`error: ${e?.message ?? e}`);
|
|
@@ -81791,7 +82252,7 @@ if (entry === "launch.mjs") {
|
|
|
81791
82252
|
// aware-update.ts
|
|
81792
82253
|
var import_promises6 = require("node:fs/promises");
|
|
81793
82254
|
var import_node_crypto32 = require("node:crypto");
|
|
81794
|
-
var
|
|
82255
|
+
var import_node_path56 = require("node:path");
|
|
81795
82256
|
var REGISTRY_LATEST = "https://registry.npmjs.org/@aware-aeco/cli/latest";
|
|
81796
82257
|
var FEED_TIMEOUT_MS2 = 15e3;
|
|
81797
82258
|
var VERSION_TTL_MS = 5e3;
|
|
@@ -81807,8 +82268,8 @@ var nodeBridgeIo = { readdir: import_promises6.readdir, lstat: import_promises6.
|
|
|
81807
82268
|
var nodeBridgeVersionIo = { ...nodeBridgeIo, readFile: import_promises6.readFile };
|
|
81808
82269
|
var BRIDGE_VERSION_MAX_BYTES = 128;
|
|
81809
82270
|
function pathInside(root5, candidate) {
|
|
81810
|
-
const rel = (0,
|
|
81811
|
-
return rel === "" || !rel.startsWith("..") && !(0,
|
|
82271
|
+
const rel = (0, import_node_path56.relative)(root5, candidate);
|
|
82272
|
+
return rel === "" || !rel.startsWith("..") && !(0, import_node_path56.isAbsolute)(rel);
|
|
81812
82273
|
}
|
|
81813
82274
|
async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
|
|
81814
82275
|
let names;
|
|
@@ -81832,7 +82293,7 @@ async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
|
|
|
81832
82293
|
for (const host of AWARE_BRIDGE_HOSTS) {
|
|
81833
82294
|
const fileName = `aware-${host}.exe`;
|
|
81834
82295
|
if (!names.includes(fileName)) continue;
|
|
81835
|
-
const candidate = (0,
|
|
82296
|
+
const candidate = (0, import_node_path56.join)(bridgeDirectory, fileName);
|
|
81836
82297
|
try {
|
|
81837
82298
|
const stat4 = await io.lstat(candidate);
|
|
81838
82299
|
const canonical = await io.realpath(candidate);
|
|
@@ -81876,8 +82337,8 @@ async function persistentBridgeVersion(bridgeDirectory, host, io = nodeBridgeVer
|
|
|
81876
82337
|
throw error;
|
|
81877
82338
|
}
|
|
81878
82339
|
};
|
|
81879
|
-
const executable = (0,
|
|
81880
|
-
const marker = (0,
|
|
82340
|
+
const executable = (0, import_node_path56.join)(bridgeDirectory, `aware-${host}.exe`);
|
|
82341
|
+
const marker = (0, import_node_path56.join)(bridgeDirectory, `aware-${host}.version`);
|
|
81881
82342
|
try {
|
|
81882
82343
|
if (!await validateFile(executable) || !await validateFile(marker)) return null;
|
|
81883
82344
|
const bytes = await io.readFile(marker, "utf8");
|
|
@@ -81911,7 +82372,7 @@ function validateMarker(value) {
|
|
|
81911
82372
|
if (v.host != null && !isBridgeHost(v.host)) return null;
|
|
81912
82373
|
if (v.child != null) {
|
|
81913
82374
|
const child = v.child;
|
|
81914
|
-
if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0,
|
|
82375
|
+
if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0, import_node_path56.basename)(child.executableIdentity) !== child.executableIdentity) return null;
|
|
81915
82376
|
}
|
|
81916
82377
|
return {
|
|
81917
82378
|
// Normalised on read: a decoded schema-1 marker is handed to callers as a schema-2 value with
|
|
@@ -81931,7 +82392,7 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
|
81931
82392
|
const io = options.io ?? nodeMarkerIo;
|
|
81932
82393
|
const maxBytes = Math.min(options.maxBytes ?? MARKER_MAX_BYTES, MARKER_MAX_BYTES);
|
|
81933
82394
|
const randomId = options.randomId ?? import_node_crypto32.randomUUID;
|
|
81934
|
-
const directory = (0,
|
|
82395
|
+
const directory = (0, import_node_path56.dirname)(markerPath2);
|
|
81935
82396
|
return {
|
|
81936
82397
|
async read() {
|
|
81937
82398
|
let bytes;
|
|
@@ -81955,7 +82416,7 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
|
81955
82416
|
const bytes = JSON.stringify(valid);
|
|
81956
82417
|
if (Buffer.byteLength(bytes) > maxBytes) throw new Error("Refused to write an oversized AWARE maintenance marker.");
|
|
81957
82418
|
await io.mkdir(directory, { recursive: true, mode: 448 });
|
|
81958
|
-
const temp = (0,
|
|
82419
|
+
const temp = (0, import_node_path56.join)(directory, `.${(0, import_node_path56.basename)(markerPath2)}.${randomId()}.tmp`);
|
|
81959
82420
|
try {
|
|
81960
82421
|
await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
81961
82422
|
await io.rename(temp, markerPath2);
|
|
@@ -81989,7 +82450,7 @@ function validatePending(value) {
|
|
|
81989
82450
|
function createBridgePendingStore(pendingPath, options = {}) {
|
|
81990
82451
|
const io = options.io ?? nodeMarkerIo;
|
|
81991
82452
|
const randomId = options.randomId ?? import_node_crypto32.randomUUID;
|
|
81992
|
-
const directory = (0,
|
|
82453
|
+
const directory = (0, import_node_path56.dirname)(pendingPath);
|
|
81993
82454
|
return {
|
|
81994
82455
|
async read() {
|
|
81995
82456
|
let bytes;
|
|
@@ -82013,7 +82474,7 @@ function createBridgePendingStore(pendingPath, options = {}) {
|
|
|
82013
82474
|
throw new Error("Refused to write an oversized AWARE bridge-repair intent.");
|
|
82014
82475
|
}
|
|
82015
82476
|
await io.mkdir(directory, { recursive: true, mode: 448 });
|
|
82016
|
-
const temp = (0,
|
|
82477
|
+
const temp = (0, import_node_path56.join)(directory, `.${(0, import_node_path56.basename)(pendingPath)}.${randomId()}.tmp`);
|
|
82017
82478
|
try {
|
|
82018
82479
|
await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
82019
82480
|
await io.rename(temp, pendingPath);
|
|
@@ -82133,7 +82594,7 @@ async function checkAwareUpdate(bridgeDirectory) {
|
|
|
82133
82594
|
// aware-install-process.ts
|
|
82134
82595
|
var import_node_child_process11 = require("node:child_process");
|
|
82135
82596
|
var import_promises7 = require("node:fs/promises");
|
|
82136
|
-
var
|
|
82597
|
+
var import_node_path57 = require("node:path");
|
|
82137
82598
|
var import_node_util4 = require("node:util");
|
|
82138
82599
|
var execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process11.execFile);
|
|
82139
82600
|
var DEFAULT_INSTALL_TIMEOUT_MS = 10 * 6e4;
|
|
@@ -82161,7 +82622,7 @@ function killTree2(child) {
|
|
|
82161
82622
|
}
|
|
82162
82623
|
}
|
|
82163
82624
|
function safeExecutableIdentity(value) {
|
|
82164
|
-
const name = (0,
|
|
82625
|
+
const name = (0, import_node_path57.basename)(value.trim()).replace(/[^A-Za-z0-9._-]/g, "").slice(0, 128);
|
|
82165
82626
|
return name || "unknown";
|
|
82166
82627
|
}
|
|
82167
82628
|
async function maintenanceChildIdentity(pid) {
|
|
@@ -83113,10 +83574,10 @@ function registerDebugNodeRoute(app, deps) {
|
|
|
83113
83574
|
// terminal-run.ts
|
|
83114
83575
|
var import_node_child_process13 = require("node:child_process");
|
|
83115
83576
|
var import_node_child_process14 = require("node:child_process");
|
|
83116
|
-
var
|
|
83577
|
+
var import_node_fs65 = require("node:fs");
|
|
83117
83578
|
var import_node_crypto34 = require("node:crypto");
|
|
83118
|
-
var
|
|
83119
|
-
var
|
|
83579
|
+
var import_node_os31 = require("node:os");
|
|
83580
|
+
var import_node_path60 = require("node:path");
|
|
83120
83581
|
|
|
83121
83582
|
// run-contract.ts
|
|
83122
83583
|
var COMPLETION_SCHEMA = {
|
|
@@ -83171,11 +83632,11 @@ function terminalEvent(stdout) {
|
|
|
83171
83632
|
var import_node_child_process12 = require("node:child_process");
|
|
83172
83633
|
var import_node_util5 = require("node:util");
|
|
83173
83634
|
var import_node_crypto33 = require("node:crypto");
|
|
83174
|
-
var
|
|
83175
|
-
var
|
|
83176
|
-
var
|
|
83177
|
-
var ROOT4 = () => process.env.FLOLESS_HOME ?? (0,
|
|
83178
|
-
var LEASE_DIR = () => (0,
|
|
83635
|
+
var import_node_fs63 = require("node:fs");
|
|
83636
|
+
var import_node_os29 = require("node:os");
|
|
83637
|
+
var import_node_path58 = require("node:path");
|
|
83638
|
+
var ROOT4 = () => process.env.FLOLESS_HOME ?? (0, import_node_path58.join)((0, import_node_os29.homedir)(), ".floless");
|
|
83639
|
+
var LEASE_DIR = () => (0, import_node_path58.join)(ROOT4(), "run-leases");
|
|
83179
83640
|
var WIN = process.platform === "win32";
|
|
83180
83641
|
var LeaseHeldError = class extends Error {
|
|
83181
83642
|
constructor(holder) {
|
|
@@ -83186,15 +83647,15 @@ var LeaseHeldError = class extends Error {
|
|
|
83186
83647
|
};
|
|
83187
83648
|
var serverStartedAt = Math.round(Date.now() - process.uptime() * 1e3);
|
|
83188
83649
|
function canonicalDir(p) {
|
|
83189
|
-
const real =
|
|
83190
|
-
if (!(0,
|
|
83191
|
-
return real.length > 1 && real.endsWith(
|
|
83650
|
+
const real = import_node_fs63.realpathSync.native((0, import_node_path58.resolve)(p));
|
|
83651
|
+
if (!(0, import_node_fs63.statSync)(real).isDirectory()) throw new Error(`not a directory: ${p}`);
|
|
83652
|
+
return real.length > 1 && real.endsWith(import_node_path58.sep) ? real.slice(0, -1) : real;
|
|
83192
83653
|
}
|
|
83193
83654
|
function isInside(parent, child) {
|
|
83194
83655
|
const norm = (s) => WIN ? s.toLowerCase() : s;
|
|
83195
83656
|
const p = norm(parent);
|
|
83196
83657
|
const c = norm(child);
|
|
83197
|
-
return c === p || c.startsWith(p.endsWith(
|
|
83658
|
+
return c === p || c.startsWith(p.endsWith(import_node_path58.sep) ? p : p + import_node_path58.sep);
|
|
83198
83659
|
}
|
|
83199
83660
|
function leaseKey(canonicalCwd) {
|
|
83200
83661
|
const k = WIN ? canonicalCwd.toLowerCase() : canonicalCwd;
|
|
@@ -83202,7 +83663,7 @@ function leaseKey(canonicalCwd) {
|
|
|
83202
83663
|
}
|
|
83203
83664
|
function readLeaseFile(file) {
|
|
83204
83665
|
try {
|
|
83205
|
-
const parsed = JSON.parse((0,
|
|
83666
|
+
const parsed = JSON.parse((0, import_node_fs63.readFileSync)(file, "utf8"));
|
|
83206
83667
|
const l = parsed;
|
|
83207
83668
|
if (typeof l?.leaseId !== "string" || typeof l.token !== "string" || typeof l.cwd !== "string") return null;
|
|
83208
83669
|
if (typeof l.requestId !== "string" || typeof l.generation !== "number") return null;
|
|
@@ -83213,8 +83674,8 @@ function readLeaseFile(file) {
|
|
|
83213
83674
|
}
|
|
83214
83675
|
function claimLease(input) {
|
|
83215
83676
|
const cwd = canonicalDir(input.cwd);
|
|
83216
|
-
(0,
|
|
83217
|
-
const file = (0,
|
|
83677
|
+
(0, import_node_fs63.mkdirSync)(LEASE_DIR(), { recursive: true, mode: 448 });
|
|
83678
|
+
const file = (0, import_node_path58.join)(LEASE_DIR(), leaseKey(cwd));
|
|
83218
83679
|
const lease = {
|
|
83219
83680
|
leaseId: (0, import_node_crypto33.randomUUID)(),
|
|
83220
83681
|
// 32 bytes of CSPRNG. This is an authorization token, not a correlation id — it is the only
|
|
@@ -83236,18 +83697,18 @@ function claimLease(input) {
|
|
|
83236
83697
|
resolvedAt: null
|
|
83237
83698
|
};
|
|
83238
83699
|
try {
|
|
83239
|
-
(0,
|
|
83700
|
+
(0, import_node_fs63.writeFileSync)(file, JSON.stringify(lease, null, 2), { flag: "wx", mode: 384 });
|
|
83240
83701
|
return lease;
|
|
83241
83702
|
} catch (err2) {
|
|
83242
83703
|
if (err2?.code !== "EEXIST") throw err2;
|
|
83243
83704
|
const holder = readLeaseFile(file);
|
|
83244
83705
|
if (holder) throw new LeaseHeldError(holder);
|
|
83245
83706
|
try {
|
|
83246
|
-
(0,
|
|
83707
|
+
(0, import_node_fs63.rmSync)(file);
|
|
83247
83708
|
} catch {
|
|
83248
83709
|
}
|
|
83249
83710
|
try {
|
|
83250
|
-
(0,
|
|
83711
|
+
(0, import_node_fs63.writeFileSync)(file, JSON.stringify(lease, null, 2), { flag: "wx", mode: 384 });
|
|
83251
83712
|
return lease;
|
|
83252
83713
|
} catch (retryErr) {
|
|
83253
83714
|
if (retryErr?.code !== "EEXIST") throw retryErr;
|
|
@@ -83259,8 +83720,8 @@ function claimLease(input) {
|
|
|
83259
83720
|
}
|
|
83260
83721
|
function listLeases() {
|
|
83261
83722
|
const dir = LEASE_DIR();
|
|
83262
|
-
if (!(0,
|
|
83263
|
-
return (0,
|
|
83723
|
+
if (!(0, import_node_fs63.existsSync)(dir)) return [];
|
|
83724
|
+
return (0, import_node_fs63.readdirSync)(dir).filter((f) => f.endsWith(".json")).map((f) => readLeaseFile((0, import_node_path58.join)(dir, f))).filter((l) => l !== null);
|
|
83264
83725
|
}
|
|
83265
83726
|
function getLease(leaseId) {
|
|
83266
83727
|
return listLeases().find((l) => l.leaseId === leaseId) ?? null;
|
|
@@ -83276,27 +83737,27 @@ function leaseForToken(token2) {
|
|
|
83276
83737
|
}
|
|
83277
83738
|
function patchLease(leaseId, generation, patch2) {
|
|
83278
83739
|
const dir = LEASE_DIR();
|
|
83279
|
-
if (!(0,
|
|
83280
|
-
for (const f of (0,
|
|
83281
|
-
const file = (0,
|
|
83740
|
+
if (!(0, import_node_fs63.existsSync)(dir)) return null;
|
|
83741
|
+
for (const f of (0, import_node_fs63.readdirSync)(dir).filter((n) => n.endsWith(".json"))) {
|
|
83742
|
+
const file = (0, import_node_path58.join)(dir, f);
|
|
83282
83743
|
const cur = readLeaseFile(file);
|
|
83283
83744
|
if (!cur || cur.leaseId !== leaseId) continue;
|
|
83284
83745
|
if (cur.generation !== generation) return null;
|
|
83285
83746
|
const next = { ...cur, ...patch2, leaseId: cur.leaseId, token: cur.token, generation: cur.generation };
|
|
83286
|
-
(0,
|
|
83747
|
+
(0, import_node_fs63.writeFileSync)(file, JSON.stringify(next, null, 2), { mode: 384 });
|
|
83287
83748
|
return next;
|
|
83288
83749
|
}
|
|
83289
83750
|
return null;
|
|
83290
83751
|
}
|
|
83291
83752
|
function releaseLease(leaseId) {
|
|
83292
83753
|
const dir = LEASE_DIR();
|
|
83293
|
-
if (!(0,
|
|
83294
|
-
for (const f of (0,
|
|
83295
|
-
const file = (0,
|
|
83754
|
+
if (!(0, import_node_fs63.existsSync)(dir)) return false;
|
|
83755
|
+
for (const f of (0, import_node_fs63.readdirSync)(dir).filter((n) => n.endsWith(".json"))) {
|
|
83756
|
+
const file = (0, import_node_path58.join)(dir, f);
|
|
83296
83757
|
const cur = readLeaseFile(file);
|
|
83297
83758
|
if (cur?.leaseId !== leaseId) continue;
|
|
83298
83759
|
try {
|
|
83299
|
-
(0,
|
|
83760
|
+
(0, import_node_fs63.rmSync)(file);
|
|
83300
83761
|
} catch {
|
|
83301
83762
|
}
|
|
83302
83763
|
return true;
|
|
@@ -83368,9 +83829,9 @@ function sameProcess(observed, pid, procStartedAt) {
|
|
|
83368
83829
|
}
|
|
83369
83830
|
|
|
83370
83831
|
// terminal-runtime.ts
|
|
83371
|
-
var
|
|
83372
|
-
var
|
|
83373
|
-
var
|
|
83832
|
+
var import_node_fs64 = require("node:fs");
|
|
83833
|
+
var import_node_os30 = require("node:os");
|
|
83834
|
+
var import_node_path59 = require("node:path");
|
|
83374
83835
|
var WIN2 = process.platform === "win32";
|
|
83375
83836
|
var exe = (name) => WIN2 ? `${name}.exe` : name;
|
|
83376
83837
|
var RUNTIMES = [
|
|
@@ -83381,7 +83842,7 @@ var RUNTIMES = [
|
|
|
83381
83842
|
command: "claude",
|
|
83382
83843
|
// Measured: the native installer puts it in ~/.local/bin, NOT under npm root -g.
|
|
83383
83844
|
// npm package, when that is how it was installed: @anthropic-ai/claude-code.
|
|
83384
|
-
candidates: () => [(0,
|
|
83845
|
+
candidates: () => [(0, import_node_path59.join)((0, import_node_os30.homedir)(), ".local", "bin", exe("claude")), ...npmShims("claude")]
|
|
83385
83846
|
},
|
|
83386
83847
|
{
|
|
83387
83848
|
id: "codex",
|
|
@@ -83390,7 +83851,7 @@ var RUNTIMES = [
|
|
|
83390
83851
|
command: "codex",
|
|
83391
83852
|
// Measured: %LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe.
|
|
83392
83853
|
candidates: () => [
|
|
83393
|
-
WIN2 && process.env.LOCALAPPDATA ? (0,
|
|
83854
|
+
WIN2 && process.env.LOCALAPPDATA ? (0, import_node_path59.join)(process.env.LOCALAPPDATA, "Programs", "OpenAI", "Codex", "bin", exe("codex")) : (0, import_node_path59.join)((0, import_node_os30.homedir)(), ".codex", "bin", exe("codex")),
|
|
83394
83855
|
...npmShims("codex")
|
|
83395
83856
|
// npm package, when installed that way: @openai/codex
|
|
83396
83857
|
]
|
|
@@ -83403,23 +83864,23 @@ var RUNTIMES = [
|
|
|
83403
83864
|
// NOT MEASURED — no OpenCode on the machine this was written against, so these are the
|
|
83404
83865
|
// documented locations and unproven. The E2E that first enables OpenCode's arm has to confirm
|
|
83405
83866
|
// them on a machine that has it; until then a false `not-found` here is the expected failure.
|
|
83406
|
-
candidates: () => [(0,
|
|
83867
|
+
candidates: () => [(0, import_node_path59.join)((0, import_node_os30.homedir)(), ".opencode", "bin", exe("opencode")), ...npmShims("opencode")]
|
|
83407
83868
|
}
|
|
83408
83869
|
];
|
|
83409
83870
|
function npmShims(bin) {
|
|
83410
|
-
if (WIN2) return process.env.APPDATA ? [(0,
|
|
83871
|
+
if (WIN2) return process.env.APPDATA ? [(0, import_node_path59.join)(process.env.APPDATA, "npm", `${bin}.cmd`)] : [];
|
|
83411
83872
|
return [
|
|
83412
|
-
(0,
|
|
83413
|
-
(0,
|
|
83414
|
-
(0,
|
|
83873
|
+
(0, import_node_path59.join)((0, import_node_os30.homedir)(), ".npm-global", "bin", bin),
|
|
83874
|
+
(0, import_node_path59.join)("/usr", "local", "bin", bin),
|
|
83875
|
+
(0, import_node_path59.join)("/opt", "homebrew", "bin", bin)
|
|
83415
83876
|
// Apple-silicon Homebrew
|
|
83416
83877
|
];
|
|
83417
83878
|
}
|
|
83418
83879
|
function usableBinary(p) {
|
|
83419
83880
|
try {
|
|
83420
|
-
const st = (0,
|
|
83881
|
+
const st = (0, import_node_fs64.statSync)(p);
|
|
83421
83882
|
if (!st.isFile() || st.size === 0) return false;
|
|
83422
|
-
if (!WIN2) (0,
|
|
83883
|
+
if (!WIN2) (0, import_node_fs64.accessSync)(p, import_node_fs64.constants.X_OK);
|
|
83423
83884
|
return true;
|
|
83424
83885
|
} catch {
|
|
83425
83886
|
return false;
|
|
@@ -83441,17 +83902,17 @@ function detectRuntimes(opts) {
|
|
|
83441
83902
|
function refreshRuntimes() {
|
|
83442
83903
|
_cache2 = null;
|
|
83443
83904
|
}
|
|
83444
|
-
var settingsPath = () => (0,
|
|
83905
|
+
var settingsPath = () => (0, import_node_path59.join)(process.env.FLOLESS_HOME ?? (0, import_node_path59.join)((0, import_node_os30.homedir)(), ".floless"), "terminal-runtime.json");
|
|
83445
83906
|
function readSettings() {
|
|
83446
83907
|
try {
|
|
83447
|
-
const raw = JSON.parse((0,
|
|
83908
|
+
const raw = JSON.parse((0, import_node_fs64.readFileSync)(settingsPath(), "utf8"));
|
|
83448
83909
|
return raw && typeof raw === "object" ? raw : {};
|
|
83449
83910
|
} catch {
|
|
83450
83911
|
return {};
|
|
83451
83912
|
}
|
|
83452
83913
|
}
|
|
83453
83914
|
function writeSettings(patch2) {
|
|
83454
|
-
(0,
|
|
83915
|
+
(0, import_node_fs64.mkdirSync)((0, import_node_path59.dirname)(settingsPath()), { recursive: true });
|
|
83455
83916
|
writeJsonAtomic(settingsPath(), { ...readSettings(), ...patch2 });
|
|
83456
83917
|
}
|
|
83457
83918
|
function readProviderSetting() {
|
|
@@ -83483,12 +83944,12 @@ function nominateFolder(projectKey, folder) {
|
|
|
83483
83944
|
throw new FolderError(`That folder doesn\u2019t exist, or isn\u2019t a folder: ${raw}`);
|
|
83484
83945
|
}
|
|
83485
83946
|
try {
|
|
83486
|
-
(0,
|
|
83947
|
+
(0, import_node_fs64.accessSync)(canonical, import_node_fs64.constants.W_OK);
|
|
83487
83948
|
} catch {
|
|
83488
83949
|
throw new FolderError(`floless can\u2019t write in that folder: ${canonical}`);
|
|
83489
83950
|
}
|
|
83490
|
-
const own3 = process.env.FLOLESS_HOME ?? (0,
|
|
83491
|
-
if ((0,
|
|
83951
|
+
const own3 = process.env.FLOLESS_HOME ?? (0, import_node_path59.join)((0, import_node_os30.homedir)(), ".floless");
|
|
83952
|
+
if ((0, import_node_fs64.existsSync)(own3) && isInside(canonicalDir(own3), canonical)) {
|
|
83492
83953
|
throw new FolderError("That\u2019s floless\u2019s own data folder. Pick a folder where your work lives.");
|
|
83493
83954
|
}
|
|
83494
83955
|
if (projectKey) {
|
|
@@ -83519,7 +83980,7 @@ function buildSpawnPlan(input) {
|
|
|
83519
83980
|
}
|
|
83520
83981
|
let file;
|
|
83521
83982
|
try {
|
|
83522
|
-
file =
|
|
83983
|
+
file = import_node_fs64.realpathSync.native(found.path);
|
|
83523
83984
|
if (!usableBinary(file)) throw new Error("not usable");
|
|
83524
83985
|
} catch {
|
|
83525
83986
|
return { ok: false, reason: "Claude Code moved or was uninstalled since floless last looked. Try again." };
|
|
@@ -83657,17 +84118,17 @@ async function finish(deps, lease, patch2) {
|
|
|
83657
84118
|
if (contained) releaseLease(lease.leaseId);
|
|
83658
84119
|
else console.error(`[terminal-run] could not prove the tree for lease ${lease.leaseId} is gone \u2014 lease held`);
|
|
83659
84120
|
}
|
|
83660
|
-
var mcpDir = () => (0,
|
|
83661
|
-
var mcpPath = (leaseId) => (0,
|
|
84121
|
+
var mcpDir = () => (0, import_node_path60.join)(process.env.FLOLESS_HOME ?? (0, import_node_path60.join)((0, import_node_os31.homedir)(), ".floless"), "run-mcp");
|
|
84122
|
+
var mcpPath = (leaseId) => (0, import_node_path60.join)(mcpDir(), `${leaseId}.json`);
|
|
83662
84123
|
function writeMcpConfig(lease) {
|
|
83663
|
-
(0,
|
|
84124
|
+
(0, import_node_fs65.mkdirSync)(mcpDir(), { recursive: true });
|
|
83664
84125
|
const p = mcpPath(lease.leaseId);
|
|
83665
|
-
(0,
|
|
84126
|
+
(0, import_node_fs65.writeFileSync)(p, JSON.stringify(mcpConfigFor(lease.token, selfOrigin()), null, 2), { mode: 384 });
|
|
83666
84127
|
return p;
|
|
83667
84128
|
}
|
|
83668
84129
|
function cleanupMcpConfig(leaseId) {
|
|
83669
84130
|
try {
|
|
83670
|
-
(0,
|
|
84131
|
+
(0, import_node_fs65.rmSync)(mcpPath(leaseId));
|
|
83671
84132
|
} catch {
|
|
83672
84133
|
}
|
|
83673
84134
|
}
|
|
@@ -83992,9 +84453,9 @@ async function stopAllRuns(deps) {
|
|
|
83992
84453
|
}
|
|
83993
84454
|
|
|
83994
84455
|
// skill-sync.ts
|
|
83995
|
-
var
|
|
83996
|
-
var
|
|
83997
|
-
var
|
|
84456
|
+
var import_node_fs66 = require("node:fs");
|
|
84457
|
+
var import_node_os32 = require("node:os");
|
|
84458
|
+
var import_node_path61 = require("node:path");
|
|
83998
84459
|
var import_node_url4 = require("node:url");
|
|
83999
84460
|
var import_yaml11 = __toESM(require_dist6(), 1);
|
|
84000
84461
|
|
|
@@ -84041,30 +84502,30 @@ function selectShippedSkillNames(names) {
|
|
|
84041
84502
|
}
|
|
84042
84503
|
|
|
84043
84504
|
// skill-sync.ts
|
|
84044
|
-
var __dirname3 = (0,
|
|
84505
|
+
var __dirname3 = (0, import_node_path61.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
|
|
84045
84506
|
function bundledSkillsRoot() {
|
|
84046
84507
|
const candidates = [
|
|
84047
|
-
(0,
|
|
84048
|
-
(0,
|
|
84049
|
-
(0,
|
|
84508
|
+
(0, import_node_path61.join)(__dirname3, "skills"),
|
|
84509
|
+
(0, import_node_path61.join)((0, import_node_path61.dirname)(process.execPath), "skills"),
|
|
84510
|
+
(0, import_node_path61.join)(__dirname3, "..", ".claude", "skills")
|
|
84050
84511
|
];
|
|
84051
|
-
return candidates.find((p) => (0,
|
|
84512
|
+
return candidates.find((p) => (0, import_node_fs66.existsSync)(p)) ?? null;
|
|
84052
84513
|
}
|
|
84053
84514
|
function targetConfigDirs() {
|
|
84054
84515
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
84055
84516
|
if (override) {
|
|
84056
84517
|
return override.split(";").map((d) => d.trim()).filter(Boolean).map((dir) => ({ runtime: "custom", dir }));
|
|
84057
84518
|
}
|
|
84058
|
-
const home = (0,
|
|
84519
|
+
const home = (0, import_node_os32.homedir)();
|
|
84059
84520
|
return [
|
|
84060
|
-
{ runtime: "claude", dir: (0,
|
|
84061
|
-
{ runtime: "codex", dir: (0,
|
|
84062
|
-
{ runtime: "opencode", dir: (0,
|
|
84521
|
+
{ runtime: "claude", dir: (0, import_node_path61.join)(home, ".claude") },
|
|
84522
|
+
{ runtime: "codex", dir: (0, import_node_path61.join)(home, ".codex") },
|
|
84523
|
+
{ runtime: "opencode", dir: (0, import_node_path61.join)(home, ".opencode") }
|
|
84063
84524
|
];
|
|
84064
84525
|
}
|
|
84065
84526
|
function skillVersion(skillMdPath) {
|
|
84066
84527
|
try {
|
|
84067
|
-
const text3 = (0,
|
|
84528
|
+
const text3 = (0, import_node_fs66.readFileSync)(skillMdPath, "utf8");
|
|
84068
84529
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
|
|
84069
84530
|
if (!m || m[1] === void 0) return null;
|
|
84070
84531
|
const fm = (0, import_yaml11.parse)(m[1]);
|
|
@@ -84104,21 +84565,21 @@ function decideAction(installed, bundled) {
|
|
|
84104
84565
|
function bundledSkills(root5) {
|
|
84105
84566
|
let entries2 = [];
|
|
84106
84567
|
try {
|
|
84107
|
-
entries2 = selectShippedSkillNames((0,
|
|
84568
|
+
entries2 = selectShippedSkillNames((0, import_node_fs66.readdirSync)(root5));
|
|
84108
84569
|
} catch {
|
|
84109
84570
|
return [];
|
|
84110
84571
|
}
|
|
84111
84572
|
const out = [];
|
|
84112
84573
|
for (const name of entries2) {
|
|
84113
|
-
const dir = (0,
|
|
84574
|
+
const dir = (0, import_node_path61.join)(root5, name);
|
|
84114
84575
|
let isDir = false;
|
|
84115
84576
|
try {
|
|
84116
|
-
isDir = (0,
|
|
84577
|
+
isDir = (0, import_node_fs66.statSync)(dir).isDirectory();
|
|
84117
84578
|
} catch {
|
|
84118
84579
|
isDir = false;
|
|
84119
84580
|
}
|
|
84120
84581
|
if (!isDir) continue;
|
|
84121
|
-
const v = skillVersion((0,
|
|
84582
|
+
const v = skillVersion((0, import_node_path61.join)(dir, "SKILL.md"));
|
|
84122
84583
|
if (!v) continue;
|
|
84123
84584
|
out.push({ name, dir, version: v });
|
|
84124
84585
|
}
|
|
@@ -84131,17 +84592,17 @@ function syncSkills() {
|
|
|
84131
84592
|
const skills = bundledSkills(root5);
|
|
84132
84593
|
if (!skills.length) return results;
|
|
84133
84594
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
84134
|
-
if (!(0,
|
|
84135
|
-
const skillsDir = (0,
|
|
84595
|
+
if (!(0, import_node_fs66.existsSync)(cfg)) continue;
|
|
84596
|
+
const skillsDir = (0, import_node_path61.join)(cfg, "skills");
|
|
84136
84597
|
for (const s of skills) {
|
|
84137
|
-
const dest = (0,
|
|
84138
|
-
const installedMd = (0,
|
|
84139
|
-
const installed = (0,
|
|
84598
|
+
const dest = (0, import_node_path61.join)(skillsDir, s.name);
|
|
84599
|
+
const installedMd = (0, import_node_path61.join)(dest, "SKILL.md");
|
|
84600
|
+
const installed = (0, import_node_fs66.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
84140
84601
|
const action = decideAction(installed, s.version);
|
|
84141
84602
|
if (action === "installed" || action === "updated") {
|
|
84142
84603
|
try {
|
|
84143
|
-
if (action === "updated") (0,
|
|
84144
|
-
(0,
|
|
84604
|
+
if (action === "updated") (0, import_node_fs66.rmSync)(dest, { recursive: true, force: true });
|
|
84605
|
+
(0, import_node_fs66.cpSync)(s.dir, dest, { recursive: true });
|
|
84145
84606
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
84146
84607
|
} catch {
|
|
84147
84608
|
}
|
|
@@ -84154,9 +84615,9 @@ function syncSkills() {
|
|
|
84154
84615
|
}
|
|
84155
84616
|
|
|
84156
84617
|
// watch.ts
|
|
84157
|
-
var
|
|
84158
|
-
var
|
|
84159
|
-
var
|
|
84618
|
+
var import_node_os33 = require("node:os");
|
|
84619
|
+
var import_node_path63 = require("node:path");
|
|
84620
|
+
var import_node_fs67 = require("node:fs");
|
|
84160
84621
|
|
|
84161
84622
|
// node_modules/chokidar/esm/index.js
|
|
84162
84623
|
var import_fs2 = require("fs");
|
|
@@ -84167,7 +84628,7 @@ var sysPath2 = __toESM(require("path"), 1);
|
|
|
84167
84628
|
// node_modules/readdirp/esm/index.js
|
|
84168
84629
|
var import_promises8 = require("node:fs/promises");
|
|
84169
84630
|
var import_node_stream4 = require("node:stream");
|
|
84170
|
-
var
|
|
84631
|
+
var import_node_path62 = require("node:path");
|
|
84171
84632
|
var EntryTypes = {
|
|
84172
84633
|
FILE_TYPE: "files",
|
|
84173
84634
|
DIR_TYPE: "directories",
|
|
@@ -84242,7 +84703,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
84242
84703
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
84243
84704
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
84244
84705
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
84245
|
-
this._root = (0,
|
|
84706
|
+
this._root = (0, import_node_path62.resolve)(root5);
|
|
84246
84707
|
this._isDirent = !opts.alwaysStat;
|
|
84247
84708
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
84248
84709
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
@@ -84311,10 +84772,10 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
84311
84772
|
}
|
|
84312
84773
|
async _formatEntry(dirent, path) {
|
|
84313
84774
|
let entry2;
|
|
84314
|
-
const
|
|
84775
|
+
const basename15 = this._isDirent ? dirent.name : dirent;
|
|
84315
84776
|
try {
|
|
84316
|
-
const fullPath = (0,
|
|
84317
|
-
entry2 = { path: (0,
|
|
84777
|
+
const fullPath = (0, import_node_path62.resolve)((0, import_node_path62.join)(path, basename15));
|
|
84778
|
+
entry2 = { path: (0, import_node_path62.relative)(this._root, fullPath), fullPath, basename: basename15 };
|
|
84318
84779
|
entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
84319
84780
|
} catch (err2) {
|
|
84320
84781
|
this._onError(err2);
|
|
@@ -84348,7 +84809,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
84348
84809
|
}
|
|
84349
84810
|
if (entryRealPathStats.isDirectory()) {
|
|
84350
84811
|
const len = entryRealPath.length;
|
|
84351
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
84812
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path62.sep) {
|
|
84352
84813
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
84353
84814
|
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
84354
84815
|
return this._onError(recursiveError);
|
|
@@ -84853,9 +85314,9 @@ var NodeFsHandler = class {
|
|
|
84853
85314
|
_watchWithNodeFs(path, listener) {
|
|
84854
85315
|
const opts = this.fsw.options;
|
|
84855
85316
|
const directory = sysPath.dirname(path);
|
|
84856
|
-
const
|
|
85317
|
+
const basename15 = sysPath.basename(path);
|
|
84857
85318
|
const parent = this.fsw._getWatchedDir(directory);
|
|
84858
|
-
parent.add(
|
|
85319
|
+
parent.add(basename15);
|
|
84859
85320
|
const absolutePath = sysPath.resolve(path);
|
|
84860
85321
|
const options = {
|
|
84861
85322
|
persistent: opts.persistent
|
|
@@ -84865,7 +85326,7 @@ var NodeFsHandler = class {
|
|
|
84865
85326
|
let closer;
|
|
84866
85327
|
if (opts.usePolling) {
|
|
84867
85328
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
84868
|
-
options.interval = enableBin && isBinaryPath(
|
|
85329
|
+
options.interval = enableBin && isBinaryPath(basename15) ? opts.binaryInterval : opts.interval;
|
|
84869
85330
|
closer = setFsWatchFileListener(path, absolutePath, options, {
|
|
84870
85331
|
listener,
|
|
84871
85332
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -84887,11 +85348,11 @@ var NodeFsHandler = class {
|
|
|
84887
85348
|
if (this.fsw.closed) {
|
|
84888
85349
|
return;
|
|
84889
85350
|
}
|
|
84890
|
-
const
|
|
84891
|
-
const
|
|
84892
|
-
const parent = this.fsw._getWatchedDir(
|
|
85351
|
+
const dirname28 = sysPath.dirname(file);
|
|
85352
|
+
const basename15 = sysPath.basename(file);
|
|
85353
|
+
const parent = this.fsw._getWatchedDir(dirname28);
|
|
84893
85354
|
let prevStats = stats;
|
|
84894
|
-
if (parent.has(
|
|
85355
|
+
if (parent.has(basename15))
|
|
84895
85356
|
return;
|
|
84896
85357
|
const listener = async (path, newStats) => {
|
|
84897
85358
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
@@ -84916,9 +85377,9 @@ var NodeFsHandler = class {
|
|
|
84916
85377
|
prevStats = newStats2;
|
|
84917
85378
|
}
|
|
84918
85379
|
} catch (error) {
|
|
84919
|
-
this.fsw._remove(
|
|
85380
|
+
this.fsw._remove(dirname28, basename15);
|
|
84920
85381
|
}
|
|
84921
|
-
} else if (parent.has(
|
|
85382
|
+
} else if (parent.has(basename15)) {
|
|
84922
85383
|
const at = newStats.atimeMs;
|
|
84923
85384
|
const mt = newStats.mtimeMs;
|
|
84924
85385
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
|
@@ -85856,33 +86317,33 @@ function appIdFromLogPath(path) {
|
|
|
85856
86317
|
return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
|
|
85857
86318
|
}
|
|
85858
86319
|
function samePath(a, b) {
|
|
85859
|
-
const ra = (0,
|
|
85860
|
-
const rb = (0,
|
|
86320
|
+
const ra = (0, import_node_path63.resolve)(a);
|
|
86321
|
+
const rb = (0, import_node_path63.resolve)(b);
|
|
85861
86322
|
return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
|
|
85862
86323
|
}
|
|
85863
86324
|
function underDir(path, dir) {
|
|
85864
|
-
const rp = (0,
|
|
85865
|
-
const rd = (0,
|
|
86325
|
+
const rp = (0, import_node_path63.resolve)(path);
|
|
86326
|
+
const rd = (0, import_node_path63.resolve)(dir);
|
|
85866
86327
|
const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
|
|
85867
|
-
return p === d || p.startsWith(d +
|
|
86328
|
+
return p === d || p.startsWith(d + import_node_path63.sep);
|
|
85868
86329
|
}
|
|
85869
86330
|
function startWatcher() {
|
|
85870
|
-
const awareDir = process.env.AWARE_HOME ?? (0,
|
|
85871
|
-
const credentialsDir = (0,
|
|
85872
|
-
if (!(0,
|
|
86331
|
+
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path63.join)((0, import_node_os33.homedir)(), ".aware");
|
|
86332
|
+
const credentialsDir = (0, import_node_path63.join)(awareDir, "credentials");
|
|
86333
|
+
if (!(0, import_node_fs67.existsSync)(credentialsDir)) {
|
|
85873
86334
|
try {
|
|
85874
|
-
(0,
|
|
86335
|
+
(0, import_node_fs67.mkdirSync)(credentialsDir, { recursive: true });
|
|
85875
86336
|
} catch {
|
|
85876
86337
|
}
|
|
85877
86338
|
}
|
|
85878
|
-
if (!(0,
|
|
86339
|
+
if (!(0, import_node_fs67.existsSync)(uiDir)) {
|
|
85879
86340
|
try {
|
|
85880
|
-
(0,
|
|
86341
|
+
(0, import_node_fs67.mkdirSync)(uiDir, { recursive: true });
|
|
85881
86342
|
} catch {
|
|
85882
86343
|
}
|
|
85883
86344
|
}
|
|
85884
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0,
|
|
85885
|
-
if ((0,
|
|
86345
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path63.join)(awareDir, d)).filter((p) => (0, import_node_fs67.existsSync)(p));
|
|
86346
|
+
if ((0, import_node_fs67.existsSync)(uiDir)) targets.push(uiDir);
|
|
85886
86347
|
if (targets.length === 0) {
|
|
85887
86348
|
return null;
|
|
85888
86349
|
}
|
|
@@ -85911,11 +86372,11 @@ function startWatcher() {
|
|
|
85911
86372
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
85912
86373
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
85913
86374
|
broadcast({ type: "fs-change", kind, event, path });
|
|
85914
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
86375
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs67.existsSync)(path)) {
|
|
85915
86376
|
const id = appIdFromLogPath(path);
|
|
85916
86377
|
if (!id) return;
|
|
85917
86378
|
try {
|
|
85918
|
-
broadcast({ type: "trace-file", id, runId: path.split(
|
|
86379
|
+
broadcast({ type: "trace-file", id, runId: path.split(import_node_path63.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs67.readFileSync)(path, "utf8")) });
|
|
85919
86380
|
} catch {
|
|
85920
86381
|
}
|
|
85921
86382
|
}
|
|
@@ -85924,10 +86385,10 @@ function startWatcher() {
|
|
|
85924
86385
|
}
|
|
85925
86386
|
|
|
85926
86387
|
// index.ts
|
|
85927
|
-
var __dirname4 = (0,
|
|
85928
|
-
var WEB_ROOT = [(0,
|
|
85929
|
-
(p) => (0,
|
|
85930
|
-
) ?? (0,
|
|
86388
|
+
var __dirname4 = (0, import_node_path64.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
|
|
86389
|
+
var WEB_ROOT = [(0, import_node_path64.join)(__dirname4, "web"), (0, import_node_path64.join)((0, import_node_path64.dirname)(process.execPath), "web"), (0, import_node_path64.join)(__dirname4, "..", "web")].find(
|
|
86390
|
+
(p) => (0, import_node_fs68.existsSync)(p)
|
|
86391
|
+
) ?? (0, import_node_path64.join)(__dirname4, "..", "web");
|
|
85931
86392
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
85932
86393
|
var HOST = "127.0.0.1";
|
|
85933
86394
|
var crashHandlersInstalled = false;
|
|
@@ -85943,7 +86404,7 @@ function installCrashHandlers() {
|
|
|
85943
86404
|
${stack}
|
|
85944
86405
|
`;
|
|
85945
86406
|
try {
|
|
85946
|
-
(0,
|
|
86407
|
+
(0, import_node_fs68.appendFileSync)(logFilePath(), line);
|
|
85947
86408
|
} catch {
|
|
85948
86409
|
}
|
|
85949
86410
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -86038,12 +86499,12 @@ async function startServer() {
|
|
|
86038
86499
|
skip: process.env.AWARE_SKIP_BOOTSTRAP === "1",
|
|
86039
86500
|
logWarn: (msg, fields) => app.log.warn(fields, msg)
|
|
86040
86501
|
};
|
|
86041
|
-
const AWARE_BRIDGE_DIRECTORY = (0,
|
|
86502
|
+
const AWARE_BRIDGE_DIRECTORY = (0, import_node_path64.join)((0, import_node_os34.homedir)(), ".aware", "bridges");
|
|
86042
86503
|
const awareMaintenance = createMaintenanceMarkerStore(
|
|
86043
|
-
(0,
|
|
86504
|
+
(0, import_node_path64.join)((0, import_node_os34.homedir)(), ".floless", "aware-maintenance.json")
|
|
86044
86505
|
);
|
|
86045
86506
|
const awareBridgePending = createBridgePendingStore(
|
|
86046
|
-
(0,
|
|
86507
|
+
(0, import_node_path64.join)((0, import_node_os34.homedir)(), ".floless", "aware-bridge-pending.json")
|
|
86047
86508
|
);
|
|
86048
86509
|
async function staleBridgesForInstalledRuntime() {
|
|
86049
86510
|
const target = aware.npmVersion();
|
|
@@ -86599,16 +87060,17 @@ async function startServer() {
|
|
|
86599
87060
|
const bdir = backupDir(id, fromVersion, Date.now());
|
|
86600
87061
|
let backedUp = false;
|
|
86601
87062
|
try {
|
|
86602
|
-
(0,
|
|
86603
|
-
(0,
|
|
87063
|
+
(0, import_node_fs68.mkdirSync)((0, import_node_path64.dirname)(bdir), { recursive: true });
|
|
87064
|
+
(0, import_node_fs68.cpSync)(appDirPath2, bdir, { recursive: true });
|
|
86604
87065
|
backedUp = true;
|
|
86605
|
-
(0,
|
|
87066
|
+
(0, import_node_fs68.cpSync)(templatePath, srcPath);
|
|
86606
87067
|
if (id !== templateId) stampSourceAppId(srcPath, id);
|
|
86607
87068
|
if (contract != null) {
|
|
86608
87069
|
bakeContractIntoApp(srcPath, contract);
|
|
86609
87070
|
await bakeDownstream(srcPath, id, contract);
|
|
86610
87071
|
}
|
|
86611
87072
|
await aware.compile(srcPath);
|
|
87073
|
+
await dropPinBytes(id);
|
|
86612
87074
|
return { backupPath: bdir };
|
|
86613
87075
|
} catch (e) {
|
|
86614
87076
|
const msg = e instanceof Error ? e.message : String(e);
|
|
@@ -86616,8 +87078,8 @@ async function startServer() {
|
|
|
86616
87078
|
throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
|
|
86617
87079
|
}
|
|
86618
87080
|
try {
|
|
86619
|
-
(0,
|
|
86620
|
-
(0,
|
|
87081
|
+
(0, import_node_fs68.rmSync)(appDirPath2, { recursive: true, force: true });
|
|
87082
|
+
(0, import_node_fs68.cpSync)(bdir, appDirPath2, { recursive: true });
|
|
86621
87083
|
} catch (re) {
|
|
86622
87084
|
const rmsg = re instanceof Error ? re.message : String(re);
|
|
86623
87085
|
throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
|
|
@@ -86629,7 +87091,7 @@ async function startServer() {
|
|
|
86629
87091
|
function readSwapContract(id, verb) {
|
|
86630
87092
|
const gerund = verb === "update" ? "updating" : "restoring";
|
|
86631
87093
|
const contract = readAcceptedForRequest(id, void 0);
|
|
86632
|
-
if (contract == null && (0,
|
|
87094
|
+
if (contract == null && (0, import_node_fs68.existsSync)(contractPath(id))) {
|
|
86633
87095
|
return { ok: false, body: { ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before ${gerund}`, code: "contract-corrupt" } };
|
|
86634
87096
|
}
|
|
86635
87097
|
if (contract != null && !validateContract(contract).valid) {
|
|
@@ -86701,7 +87163,14 @@ async function startServer() {
|
|
|
86701
87163
|
const res = await run2();
|
|
86702
87164
|
result = { type: "agent-install-result", action, id, ok: true, installed: res.installed ?? id };
|
|
86703
87165
|
} catch (err2) {
|
|
86704
|
-
|
|
87166
|
+
const fallback2 = `Could not ${action} \u201C${id}\u201D.`;
|
|
87167
|
+
result = {
|
|
87168
|
+
type: "agent-install-result",
|
|
87169
|
+
action,
|
|
87170
|
+
id,
|
|
87171
|
+
ok: false,
|
|
87172
|
+
error: action === "update" ? agentUpdateFailureMessage(err2, id) : awareFailureMessage(err2, fallback2)
|
|
87173
|
+
};
|
|
86705
87174
|
} finally {
|
|
86706
87175
|
agentJobsInFlight.delete(id);
|
|
86707
87176
|
}
|
|
@@ -86798,7 +87267,8 @@ async function startServer() {
|
|
|
86798
87267
|
};
|
|
86799
87268
|
const requestContractType = (r, memo) => {
|
|
86800
87269
|
if (r.type !== "revision-read" || !r.appId || !r.project) return void 0;
|
|
86801
|
-
|
|
87270
|
+
const project = getProject(r.project);
|
|
87271
|
+
if (!project || !sameAppLineage(r.appId, project.app)) return void 0;
|
|
86802
87272
|
return storedContractType(r.appId, r.project, memo);
|
|
86803
87273
|
};
|
|
86804
87274
|
const requestProjectName = (r, memo) => {
|
|
@@ -86862,7 +87332,12 @@ async function startServer() {
|
|
|
86862
87332
|
{ kind: "project", key: req.params.id }
|
|
86863
87333
|
);
|
|
86864
87334
|
const before = getProject(req.params.id);
|
|
86865
|
-
const project = renameProject(req.params.id, req.body?.name)
|
|
87335
|
+
const project = await renameProject(req.params.id, req.body?.name, async (fromId, toId) => {
|
|
87336
|
+
await repointProjectPins(fromId, toId);
|
|
87337
|
+
return async () => {
|
|
87338
|
+
await repointProjectPins(toId, fromId);
|
|
87339
|
+
};
|
|
87340
|
+
});
|
|
86866
87341
|
if (!before) {
|
|
86867
87342
|
req.log.error({ id: req.params.id }, "rename: pre-read missing \u2014 other tabs cannot reconcile this rename");
|
|
86868
87343
|
} else if (before.id !== project.id) {
|
|
@@ -86957,7 +87432,7 @@ async function startServer() {
|
|
|
86957
87432
|
}
|
|
86958
87433
|
let data;
|
|
86959
87434
|
try {
|
|
86960
|
-
data = (0,
|
|
87435
|
+
data = (0, import_node_fs68.readFileSync)(thumb.path);
|
|
86961
87436
|
} catch {
|
|
86962
87437
|
return reply.status(404).send({ ok: false, error: "no thumbnail" });
|
|
86963
87438
|
}
|
|
@@ -87325,7 +87800,7 @@ async function startServer() {
|
|
|
87325
87800
|
const { source, contract } = consumeExportHandle(req.body.sourceHandle, project.id, project.uuid);
|
|
87326
87801
|
const safeLabel = source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-");
|
|
87327
87802
|
const filename = uniqueProjectExportFilename(project.id, `${exportFileBase(project.id, project.app)}-${safeLabel}.flo-contract.json`);
|
|
87328
|
-
const savedTo = (0,
|
|
87803
|
+
const savedTo = (0, import_node_path64.join)(projectExportsDir(project.id), filename);
|
|
87329
87804
|
durableCanonicalJson(savedTo, {
|
|
87330
87805
|
schema: 1,
|
|
87331
87806
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -87381,6 +87856,7 @@ async function startServer() {
|
|
|
87381
87856
|
registerRevisionRoutes(app);
|
|
87382
87857
|
registerSteelPrepassRoute(app, { getProject, clearApproval, broadcast });
|
|
87383
87858
|
registerKnowledgeRoutes(app);
|
|
87859
|
+
registerKbPinRoutes(app, { broadcast });
|
|
87384
87860
|
function projectAppMismatch(appId, project) {
|
|
87385
87861
|
const p = getProject(project);
|
|
87386
87862
|
if (!p) return `unknown project: ${project}`;
|
|
@@ -87489,9 +87965,9 @@ async function startServer() {
|
|
|
87489
87965
|
const bad = projectAppMismatch(req.params.appId, project);
|
|
87490
87966
|
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
87491
87967
|
const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
|
|
87492
|
-
const file = (0,
|
|
87493
|
-
if (!(0,
|
|
87494
|
-
return reply.type("image/svg+xml").send((0,
|
|
87968
|
+
const file = (0, import_node_path64.join)((0, import_node_path64.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
|
|
87969
|
+
if (!(0, import_node_fs68.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
|
|
87970
|
+
return reply.type("image/svg+xml").send((0, import_node_fs68.readFileSync)(file, "utf8"));
|
|
87495
87971
|
}
|
|
87496
87972
|
);
|
|
87497
87973
|
app.put(
|
|
@@ -87980,7 +88456,7 @@ async function startServer() {
|
|
|
87980
88456
|
}
|
|
87981
88457
|
const statedAt = (filename) => {
|
|
87982
88458
|
try {
|
|
87983
|
-
const st = (0,
|
|
88459
|
+
const st = (0, import_node_fs68.statSync)((0, import_node_path64.join)(dir, filename));
|
|
87984
88460
|
return st.isFile() ? st.mtime.toISOString() : null;
|
|
87985
88461
|
} catch {
|
|
87986
88462
|
return null;
|
|
@@ -87990,14 +88466,14 @@ async function startServer() {
|
|
|
87990
88466
|
const rows2 = (byKind.get(kind) ?? []).map((receipt) => ({
|
|
87991
88467
|
variant: receipt.variant ?? null,
|
|
87992
88468
|
filename: receipt.filename,
|
|
87993
|
-
path: (0,
|
|
88469
|
+
path: (0, import_node_path64.join)(dir, receipt.filename),
|
|
87994
88470
|
exportedAt: statedAt(receipt.filename)
|
|
87995
88471
|
})).sort((a, b) => String(b.exportedAt ?? "").localeCompare(String(a.exportedAt ?? "")));
|
|
87996
88472
|
const headline = rows2[0];
|
|
87997
88473
|
return {
|
|
87998
88474
|
kind,
|
|
87999
88475
|
filename: headline?.filename ?? legacy,
|
|
88000
|
-
path: headline?.path ?? (0,
|
|
88476
|
+
path: headline?.path ?? (0, import_node_path64.join)(dir, legacy),
|
|
88001
88477
|
exportedAt: headline?.exportedAt ?? null,
|
|
88002
88478
|
...rows2.length ? { variants: rows2 } : {}
|
|
88003
88479
|
};
|
|
@@ -88145,7 +88621,7 @@ async function startServer() {
|
|
|
88145
88621
|
}
|
|
88146
88622
|
if (!hasExportableSceneRecords(scene)) return reply.status(422).send({ ok: false, error: emptyError, skipped });
|
|
88147
88623
|
const filename = `${exportFileBase(project, appId)}${explicitExportSourceSuffix(input)}.ifc`;
|
|
88148
|
-
const finalPath = (0,
|
|
88624
|
+
const finalPath = (0, import_node_path64.join)(project ? projectExportsDir(project) : (0, import_node_path64.dirname)(bomExportPath(appId, "csv")), filename);
|
|
88149
88625
|
const priorProjectIfc = project ? listProjectExportReceipts(project).find((row) => row.kind === "ifc") : void 0;
|
|
88150
88626
|
const tempPath = requestIfcTempPath(finalPath);
|
|
88151
88627
|
try {
|
|
@@ -88153,10 +88629,10 @@ async function startServer() {
|
|
|
88153
88629
|
scene,
|
|
88154
88630
|
"output-path": tempPath
|
|
88155
88631
|
});
|
|
88156
|
-
if (!(0,
|
|
88632
|
+
if (!(0, import_node_fs68.existsSync)(tempPath) || (0, import_node_fs68.statSync)(tempPath).size === 0) {
|
|
88157
88633
|
throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
|
|
88158
88634
|
}
|
|
88159
|
-
const artifactBytes = (0,
|
|
88635
|
+
const artifactBytes = (0, import_node_fs68.readFileSync)(tempPath);
|
|
88160
88636
|
const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
|
|
88161
88637
|
index: parseStepData(artifactBytes),
|
|
88162
88638
|
bytes: artifactBytes
|
|
@@ -88212,7 +88688,7 @@ async function startServer() {
|
|
|
88212
88688
|
ok: false,
|
|
88213
88689
|
error: awareFailureMessage(error, "IFC export failed"),
|
|
88214
88690
|
...reason ? { reason } : {},
|
|
88215
|
-
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0,
|
|
88691
|
+
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs68.existsSync)(finalPath)
|
|
88216
88692
|
});
|
|
88217
88693
|
} finally {
|
|
88218
88694
|
cleanupIfcTemp(tempPath);
|
|
@@ -88259,10 +88735,10 @@ async function startServer() {
|
|
|
88259
88735
|
const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
|
|
88260
88736
|
if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
|
|
88261
88737
|
const path = resolveProjectExportReceiptPath(project, receipt);
|
|
88262
|
-
if (!path || !(0,
|
|
88738
|
+
if (!path || !(0, import_node_fs68.existsSync)(path)) {
|
|
88263
88739
|
return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
|
|
88264
88740
|
}
|
|
88265
|
-
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0,
|
|
88741
|
+
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs68.readFileSync)(path));
|
|
88266
88742
|
});
|
|
88267
88743
|
const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
|
|
88268
88744
|
app.post("/api/contract/:appId/render", async (req, reply) => {
|
|
@@ -88323,8 +88799,8 @@ async function startServer() {
|
|
|
88323
88799
|
}
|
|
88324
88800
|
const kind = output === "turntable" ? "render-mp4" : "render-png";
|
|
88325
88801
|
const extension = output === "turntable" ? ".mp4" : ".png";
|
|
88326
|
-
const scratch = (0,
|
|
88327
|
-
const ifcPath = (0,
|
|
88802
|
+
const scratch = (0, import_node_fs68.mkdtempSync)((0, import_node_path64.join)((0, import_node_os34.tmpdir)(), "floless-render-"));
|
|
88803
|
+
const ifcPath = (0, import_node_path64.join)(scratch, "model.ifc");
|
|
88328
88804
|
const rendered = [];
|
|
88329
88805
|
const progress = (stage, extra = {}) => {
|
|
88330
88806
|
try {
|
|
@@ -88335,13 +88811,13 @@ async function startServer() {
|
|
|
88335
88811
|
try {
|
|
88336
88812
|
progress("preparing");
|
|
88337
88813
|
await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
|
|
88338
|
-
if (!(0,
|
|
88814
|
+
if (!(0, import_node_fs68.existsSync)(ifcPath) || (0, import_node_fs68.statSync)(ifcPath).size === 0) {
|
|
88339
88815
|
throw new Error("AWARE reported a successful IFC write but produced no file to render");
|
|
88340
88816
|
}
|
|
88341
88817
|
const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
|
|
88342
88818
|
for (const [i, viewpoint] of viewpoints.entries()) {
|
|
88343
88819
|
progress("rendering", { viewpoint, index: i + 1, output });
|
|
88344
|
-
const artifactPath = (0,
|
|
88820
|
+
const artifactPath = (0, import_node_path64.join)(scratch, `render-${viewpoint}${extension}`);
|
|
88345
88821
|
const receipt = await aware.agentInvoke(RENDER_AGENT_ID, output === "turntable" ? "render.turntable" : "render.still", {
|
|
88346
88822
|
"ifc-path": ifcPath,
|
|
88347
88823
|
"output-path": artifactPath,
|
|
@@ -88353,10 +88829,10 @@ async function startServer() {
|
|
|
88353
88829
|
environment: "studio",
|
|
88354
88830
|
...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
|
|
88355
88831
|
}, { timeoutMs: renderBudgetMs });
|
|
88356
|
-
if (!(0,
|
|
88832
|
+
if (!(0, import_node_fs68.existsSync)(artifactPath) || (0, import_node_fs68.statSync)(artifactPath).size === 0) {
|
|
88357
88833
|
throw new Error(`the ${viewpoint} render reported success but produced no image`);
|
|
88358
88834
|
}
|
|
88359
|
-
const bytes = (0,
|
|
88835
|
+
const bytes = (0, import_node_fs68.readFileSync)(artifactPath);
|
|
88360
88836
|
const sourceSuffix = "source" in projectSnapshot && projectSnapshot.source ? `-${projectSnapshot.source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-")}` : "";
|
|
88361
88837
|
const preferred = `${exportFileBase(project, appId)}-${viewpoint}${sourceSuffix}${extension}`;
|
|
88362
88838
|
const filename = uniqueProjectExportFilename(project, preferred);
|
|
@@ -88394,7 +88870,7 @@ async function startServer() {
|
|
|
88394
88870
|
// Kept for a single-viewpoint caller so the existing shape still reads naturally.
|
|
88395
88871
|
filename: rendered[0]?.filename,
|
|
88396
88872
|
viewpoint: rendered[0]?.viewpoint,
|
|
88397
|
-
savedTo: rendered[0] ? (0,
|
|
88873
|
+
savedTo: rendered[0] ? (0, import_node_path64.join)(projectExportsDir(project), rendered[0].filename) : void 0
|
|
88398
88874
|
};
|
|
88399
88875
|
} catch (error) {
|
|
88400
88876
|
const reason = awareStderr(error);
|
|
@@ -88412,7 +88888,7 @@ async function startServer() {
|
|
|
88412
88888
|
rendered
|
|
88413
88889
|
});
|
|
88414
88890
|
} finally {
|
|
88415
|
-
(0,
|
|
88891
|
+
(0, import_node_fs68.rmSync)(scratch, { recursive: true, force: true });
|
|
88416
88892
|
}
|
|
88417
88893
|
}, {
|
|
88418
88894
|
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
@@ -88650,10 +89126,10 @@ async function startServer() {
|
|
|
88650
89126
|
}
|
|
88651
89127
|
const preferredFilename = `${exportFileBase(project, appId)}-bom${explicitExportSourceSuffix(input.source)}.${format}`;
|
|
88652
89128
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
88653
|
-
const outPath = project ? (0,
|
|
88654
|
-
const dir = (0,
|
|
89129
|
+
const outPath = project ? (0, import_node_path64.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
|
|
89130
|
+
const dir = (0, import_node_path64.dirname)(outPath);
|
|
88655
89131
|
try {
|
|
88656
|
-
(0,
|
|
89132
|
+
(0, import_node_fs68.mkdirSync)(dir, { recursive: true });
|
|
88657
89133
|
const kind = BOM_EXPORT_KIND[format];
|
|
88658
89134
|
let text3 = null;
|
|
88659
89135
|
let buf;
|
|
@@ -88681,8 +89157,8 @@ async function startServer() {
|
|
|
88681
89157
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
88682
89158
|
contractHash: projectSnapshot.contractHash
|
|
88683
89159
|
}, buf);
|
|
88684
|
-
} else if (text3 != null) (0,
|
|
88685
|
-
else (0,
|
|
89160
|
+
} else if (text3 != null) (0, import_node_fs68.writeFileSync)(outPath, text3, "utf8");
|
|
89161
|
+
else (0, import_node_fs68.writeFileSync)(outPath, buf);
|
|
88686
89162
|
return {
|
|
88687
89163
|
ok: true,
|
|
88688
89164
|
payload: text3 != null ? { filename, encoding: "utf8", content: text3, bytes: buf.length, savedTo: outPath } : { filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath }
|
|
@@ -88720,9 +89196,9 @@ async function startServer() {
|
|
|
88720
89196
|
const svg = contractToSvg(cleaned);
|
|
88721
89197
|
const preferredFilename = `${exportFileBase(project, appId)}${explicitExportSourceSuffix(input)}.svg`;
|
|
88722
89198
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
88723
|
-
const outPath = project ? (0,
|
|
89199
|
+
const outPath = project ? (0, import_node_path64.join)(projectExportsDir(project), filename) : (0, import_node_path64.join)(appPath(appId), filename);
|
|
88724
89200
|
try {
|
|
88725
|
-
(0,
|
|
89201
|
+
(0, import_node_fs68.mkdirSync)((0, import_node_path64.dirname)(outPath), { recursive: true });
|
|
88726
89202
|
if (project && projectSnapshot) {
|
|
88727
89203
|
publishProjectExportArtifact(project, {
|
|
88728
89204
|
kind: "svg",
|
|
@@ -88733,7 +89209,7 @@ async function startServer() {
|
|
|
88733
89209
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
88734
89210
|
contractHash: projectSnapshot.contractHash
|
|
88735
89211
|
}, Buffer.from(svg, "utf8"));
|
|
88736
|
-
} else (0,
|
|
89212
|
+
} else (0, import_node_fs68.writeFileSync)(outPath, svg, "utf8");
|
|
88737
89213
|
return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
|
|
88738
89214
|
} catch (e) {
|
|
88739
89215
|
app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
|
|
@@ -88879,12 +89355,12 @@ async function startServer() {
|
|
|
88879
89355
|
if (!id && !sourcePath) return reply.status(400).send({ ok: false, error: "id or sourcePath required" });
|
|
88880
89356
|
const explicitInstalledId = (() => {
|
|
88881
89357
|
if (!sourcePath) return null;
|
|
88882
|
-
const awareRoot = process.env.AWARE_HOME || (0,
|
|
88883
|
-
const rel = (0,
|
|
89358
|
+
const awareRoot = process.env.AWARE_HOME || (0, import_node_path64.join)((0, import_node_os34.homedir)(), ".aware");
|
|
89359
|
+
const rel = (0, import_node_path64.relative)((0, import_node_path64.resolve)(awareRoot, "apps"), (0, import_node_path64.resolve)(sourcePath));
|
|
88884
89360
|
const segments = rel.split(/[\\/]/);
|
|
88885
89361
|
if (segments.length !== 2 || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(segments[0])) return null;
|
|
88886
89362
|
try {
|
|
88887
|
-
return (0,
|
|
89363
|
+
return (0, import_node_path64.resolve)(readApp(segments[0]).source.path) === (0, import_node_path64.resolve)(sourcePath) ? segments[0] : null;
|
|
88888
89364
|
} catch {
|
|
88889
89365
|
return null;
|
|
88890
89366
|
}
|
|
@@ -88915,11 +89391,22 @@ async function startServer() {
|
|
|
88915
89391
|
return reply.status(409).send({ ok: false, error: `a workflow named "${id}" is already installed \u2014 remove it first, or rename the file's app: id`, code: "exists", id });
|
|
88916
89392
|
}
|
|
88917
89393
|
await deleteOrigin(id);
|
|
88918
|
-
const stageRoot = (0, import_node_fs66.mkdtempSync)((0, import_node_path63.join)((0, import_node_os33.tmpdir)(), "floless-import-"));
|
|
88919
89394
|
try {
|
|
88920
|
-
|
|
88921
|
-
|
|
88922
|
-
|
|
89395
|
+
await dropPinBytes(id);
|
|
89396
|
+
} catch (e) {
|
|
89397
|
+
app.log.error({ err: e, id }, "could not drop stale knowledge pin before import");
|
|
89398
|
+
return reply.status(500).send({
|
|
89399
|
+
ok: false,
|
|
89400
|
+
error: "Could not clear stale knowledge provenance before import. Close anything using that file and try again.",
|
|
89401
|
+
code: "kb_pin_cleanup_failed",
|
|
89402
|
+
id
|
|
89403
|
+
});
|
|
89404
|
+
}
|
|
89405
|
+
const stageRoot = (0, import_node_fs68.mkdtempSync)((0, import_node_path64.join)((0, import_node_os34.tmpdir)(), "floless-import-"));
|
|
89406
|
+
try {
|
|
89407
|
+
const stageDir = (0, import_node_path64.join)(stageRoot, id);
|
|
89408
|
+
(0, import_node_fs68.mkdirSync)(stageDir);
|
|
89409
|
+
(0, import_node_fs68.writeFileSync)((0, import_node_path64.join)(stageDir, `${id}.flo`), content);
|
|
88923
89410
|
await aware.install(stageDir);
|
|
88924
89411
|
} catch (err2) {
|
|
88925
89412
|
try {
|
|
@@ -88930,7 +89417,7 @@ async function startServer() {
|
|
|
88930
89417
|
const reason = awareStderr(err2);
|
|
88931
89418
|
return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
|
|
88932
89419
|
} finally {
|
|
88933
|
-
(0,
|
|
89420
|
+
(0, import_node_fs68.rmSync)(stageRoot, { recursive: true, force: true });
|
|
88934
89421
|
}
|
|
88935
89422
|
broadcast({ type: "apps-changed", id });
|
|
88936
89423
|
return { ok: true, id };
|
|
@@ -88946,13 +89433,13 @@ async function startServer() {
|
|
|
88946
89433
|
}
|
|
88947
89434
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
88948
89435
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
88949
|
-
const tmpRoot = (0,
|
|
88950
|
-
const backupDir2 = (0,
|
|
88951
|
-
const bakeDir = (0,
|
|
88952
|
-
(0,
|
|
88953
|
-
(0,
|
|
89436
|
+
const tmpRoot = (0, import_node_fs68.mkdtempSync)((0, import_node_path64.join)((0, import_node_os34.tmpdir)(), "floless-bake-"));
|
|
89437
|
+
const backupDir2 = (0, import_node_path64.join)(tmpRoot, `${id}-backup`);
|
|
89438
|
+
const bakeDir = (0, import_node_path64.join)(tmpRoot, id);
|
|
89439
|
+
(0, import_node_fs68.cpSync)(appDir(id), backupDir2, { recursive: true });
|
|
89440
|
+
(0, import_node_fs68.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
88954
89441
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
88955
|
-
(0,
|
|
89442
|
+
(0, import_node_fs68.writeFileSync)((0, import_node_path64.join)(bakeDir, floName), baked);
|
|
88956
89443
|
let appInstalled2 = true;
|
|
88957
89444
|
try {
|
|
88958
89445
|
await aware.uninstall(id);
|
|
@@ -88974,18 +89461,18 @@ async function startServer() {
|
|
|
88974
89461
|
throw installErr;
|
|
88975
89462
|
}
|
|
88976
89463
|
try {
|
|
88977
|
-
await aware.compile((0,
|
|
89464
|
+
await aware.compile((0, import_node_path64.join)(appDir(id), floName));
|
|
88978
89465
|
} catch (compileErr) {
|
|
88979
89466
|
app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
|
|
88980
89467
|
}
|
|
88981
89468
|
broadcast({ type: "baked", id });
|
|
88982
89469
|
return { ok: true, id, agent: id, inputs };
|
|
88983
89470
|
} finally {
|
|
88984
|
-
if (appInstalled2) (0,
|
|
89471
|
+
if (appInstalled2) (0, import_node_fs68.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
88985
89472
|
}
|
|
88986
89473
|
});
|
|
88987
89474
|
});
|
|
88988
|
-
const graftAgentsDir = () => (0,
|
|
89475
|
+
const graftAgentsDir = () => (0, import_node_path64.join)((0, import_node_os34.homedir)(), ".aware", "agents");
|
|
88989
89476
|
app.post("/api/graft/match", async (req, reply) => {
|
|
88990
89477
|
const { glob } = req.body ?? {};
|
|
88991
89478
|
if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
|
|
@@ -89002,7 +89489,7 @@ async function startServer() {
|
|
|
89002
89489
|
if (!sourceKind || !sourceRef) {
|
|
89003
89490
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
89004
89491
|
}
|
|
89005
|
-
const tempHome = (0,
|
|
89492
|
+
const tempHome = (0, import_node_fs68.mkdtempSync)((0, import_node_path64.join)((0, import_node_os34.tmpdir)(), "floless-graft-"));
|
|
89006
89493
|
let result;
|
|
89007
89494
|
try {
|
|
89008
89495
|
result = await aware.build({
|
|
@@ -89015,19 +89502,19 @@ async function startServer() {
|
|
|
89015
89502
|
awareHome: tempHome
|
|
89016
89503
|
});
|
|
89017
89504
|
} catch (err2) {
|
|
89018
|
-
(0,
|
|
89505
|
+
(0, import_node_fs68.rmSync)(tempHome, { recursive: true, force: true });
|
|
89019
89506
|
const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
|
|
89020
89507
|
return reply.status(422).send({ ok: false, error: msg });
|
|
89021
89508
|
}
|
|
89022
89509
|
const manifest = readStagedManifest(result.agentDir);
|
|
89023
89510
|
if (!manifest) {
|
|
89024
|
-
(0,
|
|
89511
|
+
(0, import_node_fs68.rmSync)(tempHome, { recursive: true, force: true });
|
|
89025
89512
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
89026
89513
|
}
|
|
89027
89514
|
const token2 = (0, import_node_crypto35.randomUUID)();
|
|
89028
89515
|
registerStage(token2, tempHome, result.agentId);
|
|
89029
89516
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token2);
|
|
89030
|
-
if ((0,
|
|
89517
|
+
if ((0, import_node_fs68.existsSync)((0, import_node_path64.join)(graftAgentsDir(), result.agentId))) {
|
|
89031
89518
|
preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
89032
89519
|
}
|
|
89033
89520
|
return { ok: true, preview: preview2 };
|
|
@@ -89046,7 +89533,7 @@ async function startServer() {
|
|
|
89046
89533
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
89047
89534
|
return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
|
|
89048
89535
|
}
|
|
89049
|
-
(0,
|
|
89536
|
+
(0, import_node_fs68.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
89050
89537
|
throw err2;
|
|
89051
89538
|
}
|
|
89052
89539
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -89329,18 +89816,18 @@ async function startServer() {
|
|
|
89329
89816
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
89330
89817
|
const n = Number.parseInt(req.params.n, 10);
|
|
89331
89818
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
89332
|
-
if (!p || !(0,
|
|
89819
|
+
if (!p || !(0, import_node_fs68.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
89333
89820
|
const ext = p.split(".").pop().toLowerCase();
|
|
89334
89821
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
|
|
89335
89822
|
reply.header("Cache-Control", "no-store");
|
|
89336
|
-
return (0,
|
|
89823
|
+
return (0, import_node_fs68.readFileSync)(p);
|
|
89337
89824
|
});
|
|
89338
89825
|
app.post(
|
|
89339
89826
|
"/api/tweak",
|
|
89340
89827
|
{ bodyLimit: 25 * 1024 * 1024 },
|
|
89341
89828
|
async (req, reply) => {
|
|
89342
89829
|
const { appId, nodeId, instruction, snapshots } = req.body ?? {};
|
|
89343
|
-
if (!appId || !nodeId || !instruction) {
|
|
89830
|
+
if (!isSafeAppId2(appId) || !nodeId || !instruction) {
|
|
89344
89831
|
return reply.status(400).send({ ok: false, error: "appId, nodeId, instruction required" });
|
|
89345
89832
|
}
|
|
89346
89833
|
let decoded;
|
|
@@ -89354,28 +89841,7 @@ async function startServer() {
|
|
|
89354
89841
|
return { ok: true, request: requestView2(request) };
|
|
89355
89842
|
}
|
|
89356
89843
|
);
|
|
89357
|
-
app
|
|
89358
|
-
"/api/contract-request",
|
|
89359
|
-
{ bodyLimit: 25 * 1024 * 1024 },
|
|
89360
|
-
async (req, reply) => {
|
|
89361
|
-
const { appId, project, instruction, intent, target, snapshots } = req.body ?? {};
|
|
89362
|
-
if (!appId || !instruction) {
|
|
89363
|
-
return reply.status(400).send({ ok: false, error: "appId, instruction required" });
|
|
89364
|
-
}
|
|
89365
|
-
let decoded;
|
|
89366
|
-
try {
|
|
89367
|
-
decoded = decodeSnapshots(snapshots);
|
|
89368
|
-
} catch (e) {
|
|
89369
|
-
return reply.status(400).send({ ok: false, error: e instanceof Error ? e.message : "bad snapshot" });
|
|
89370
|
-
}
|
|
89371
|
-
const request = addRequest(
|
|
89372
|
-
{ type: "tweak-contract", appId, ...project ? { project } : {}, instruction, ...intent ? { intent } : {}, ...target ? { target } : {} },
|
|
89373
|
-
decoded
|
|
89374
|
-
);
|
|
89375
|
-
broadcast({ type: "request-added", request });
|
|
89376
|
-
return { ok: true, request: requestView2(request) };
|
|
89377
|
-
}
|
|
89378
|
-
);
|
|
89844
|
+
registerContractRequestRoute(app, { broadcast, requestView: requestView2 });
|
|
89379
89845
|
const REBAKE_INSTRUCTION = "Re-read the attached drawing and re-bake the extracted values into this app's config.yaml (the literals the deterministic run uses), then `aware app compile` the app and tell me to approve the new lock. Do not change node logic \u2014 only the baked config values.";
|
|
89380
89846
|
app.post(
|
|
89381
89847
|
"/api/rebake",
|
|
@@ -89385,7 +89851,7 @@ async function startServer() {
|
|
|
89385
89851
|
async (req, reply) => {
|
|
89386
89852
|
const { appId, inputName, instruction, snapshots } = req.body ?? {};
|
|
89387
89853
|
const sourceName = typeof req.body?.sourceName === "string" ? req.body.sourceName : void 0;
|
|
89388
|
-
if (!appId) return reply.status(400).send({ ok: false, error: "appId required" });
|
|
89854
|
+
if (!isSafeAppId2(appId)) return reply.status(400).send({ ok: false, error: "a valid appId is required" });
|
|
89389
89855
|
let decoded;
|
|
89390
89856
|
try {
|
|
89391
89857
|
decoded = decodeSnapshots(snapshots);
|
|
@@ -89477,7 +89943,7 @@ async function startServer() {
|
|
|
89477
89943
|
);
|
|
89478
89944
|
app.post("/api/use-template", async (req, reply) => {
|
|
89479
89945
|
const { appId, templateId } = req.body ?? {};
|
|
89480
|
-
if (!appId || !templateId) return reply.status(400).send({ ok: false, error: "appId and templateId required" });
|
|
89946
|
+
if (!isSafeAppId2(appId) || !templateId) return reply.status(400).send({ ok: false, error: "a valid appId and templateId are required" });
|
|
89481
89947
|
const template = getTemplate(templateId);
|
|
89482
89948
|
if (!template) return reply.status(404).send({ ok: false, error: "template not found" });
|
|
89483
89949
|
const request = addRequest({ type: "use-template", appId, templateId, template });
|
|
@@ -89486,7 +89952,7 @@ async function startServer() {
|
|
|
89486
89952
|
});
|
|
89487
89953
|
app.post("/api/guide", async (req, reply) => {
|
|
89488
89954
|
const { appId } = req.body ?? {};
|
|
89489
|
-
if (!appId) return reply.status(400).send({ ok: false, error: "appId required" });
|
|
89955
|
+
if (!isSafeAppId2(appId)) return reply.status(400).send({ ok: false, error: "a valid appId is required" });
|
|
89490
89956
|
const request = addRequest({ type: "guide", appId });
|
|
89491
89957
|
broadcast({ type: "request-added", request });
|
|
89492
89958
|
return { ok: true, request: requestView2(request) };
|
|
@@ -89593,7 +90059,7 @@ ${v.prompt}` : "";
|
|
|
89593
90059
|
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
89594
90060
|
let finishedAt2 = null;
|
|
89595
90061
|
try {
|
|
89596
|
-
finishedAt2 = (0,
|
|
90062
|
+
finishedAt2 = (0, import_node_fs68.statSync)(latest.path).mtime.toISOString();
|
|
89597
90063
|
} catch {
|
|
89598
90064
|
finishedAt2 = null;
|
|
89599
90065
|
}
|
|
@@ -89603,7 +90069,7 @@ ${v.prompt}` : "";
|
|
|
89603
90069
|
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
89604
90070
|
if (!finishedAt) {
|
|
89605
90071
|
try {
|
|
89606
|
-
finishedAt = (0,
|
|
90072
|
+
finishedAt = (0, import_node_fs68.statSync)(latest.path).mtime.toISOString();
|
|
89607
90073
|
} catch {
|
|
89608
90074
|
finishedAt = null;
|
|
89609
90075
|
}
|
|
@@ -89742,8 +90208,13 @@ ${v.prompt}` : "";
|
|
|
89742
90208
|
await app.listen({ port: PORT2, host: HOST });
|
|
89743
90209
|
app.log.info(`floless.app on http://${HOST}:${PORT2} (aware npm ${getBootstrapState().awareVersion ?? "unresolved"})`);
|
|
89744
90210
|
try {
|
|
89745
|
-
const
|
|
89746
|
-
|
|
90211
|
+
const manifest = syncWorkspaceAgentManifest(PORT2);
|
|
90212
|
+
const logFields = { manifestPath: manifest.path, owner: manifest.owner, previousOwner: manifest.previousOwner };
|
|
90213
|
+
if (manifest.outcome === "preserved-live-owner") {
|
|
90214
|
+
app.log.info(logFields, "preserved floless-workspace AWARE agent manifest owned by a live server");
|
|
90215
|
+
} else {
|
|
90216
|
+
app.log.info({ ...logFields, outcome: manifest.outcome }, "wrote floless-workspace AWARE agent manifest");
|
|
90217
|
+
}
|
|
89747
90218
|
} catch (err2) {
|
|
89748
90219
|
app.log.warn({ err: String(err2) }, "workspace agent manifest sync failed (non-fatal)");
|
|
89749
90220
|
}
|