@floless/app 0.126.4 → 0.127.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +1007 -340
- package/dist/skills/floless-app-new-workflow/SKILL.md +18 -1
- package/dist/skills/floless-app-queue/SKILL.md +3 -2
- package/dist/skills/floless-app-workflows/SKILL.md +50 -1
- package/dist/web/app.css +72 -14
- package/dist/web/aware.js +189 -6
- 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);
|
|
@@ -52696,6 +52699,12 @@ var AwareUnsupportedError = class extends AwareError {
|
|
|
52696
52699
|
this.name = "AwareUnsupportedError";
|
|
52697
52700
|
}
|
|
52698
52701
|
};
|
|
52702
|
+
var AwareManagedSidecarContractError = class extends AwareError {
|
|
52703
|
+
constructor(message, detail) {
|
|
52704
|
+
super(message, detail);
|
|
52705
|
+
this.name = "AwareManagedSidecarContractError";
|
|
52706
|
+
}
|
|
52707
|
+
};
|
|
52699
52708
|
function resolveInvoker() {
|
|
52700
52709
|
const envDir = process.env.AWARE_CLI_DIR;
|
|
52701
52710
|
if (envDir && (0, import_node_fs9.existsSync)((0, import_node_path7.join)(envDir, "scripts/bin/aware.js"))) {
|
|
@@ -53032,12 +53041,47 @@ function newRunTicket() {
|
|
|
53032
53041
|
}
|
|
53033
53042
|
var activeRun = null;
|
|
53034
53043
|
var runChain = Promise.resolve();
|
|
53044
|
+
var TREE_KILL_RETRY_MS = 75;
|
|
53045
|
+
var TREE_KILL_MAX_ATTEMPTS = 20;
|
|
53046
|
+
var treeKillRetries = /* @__PURE__ */ new WeakMap();
|
|
53047
|
+
function retryWindowsTreeKill(child) {
|
|
53048
|
+
if (!child.pid || treeKillRetries.has(child)) return;
|
|
53049
|
+
const state2 = { attempts: 0, timer: null, closed: false };
|
|
53050
|
+
treeKillRetries.set(child, state2);
|
|
53051
|
+
const clear = () => {
|
|
53052
|
+
state2.closed = true;
|
|
53053
|
+
if (state2.timer) clearTimeout(state2.timer);
|
|
53054
|
+
treeKillRetries.delete(child);
|
|
53055
|
+
};
|
|
53056
|
+
child.once("close", clear);
|
|
53057
|
+
const attempt = () => {
|
|
53058
|
+
if (state2.closed || child.exitCode !== null || child.signalCode !== null) {
|
|
53059
|
+
clear();
|
|
53060
|
+
return;
|
|
53061
|
+
}
|
|
53062
|
+
state2.attempts += 1;
|
|
53063
|
+
(0, import_node_child_process2.execFile)("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: 1e3 }, (err2) => {
|
|
53064
|
+
if (!err2 || state2.closed) return;
|
|
53065
|
+
if (state2.attempts >= TREE_KILL_MAX_ATTEMPTS) {
|
|
53066
|
+
try {
|
|
53067
|
+
child.kill();
|
|
53068
|
+
} catch {
|
|
53069
|
+
}
|
|
53070
|
+
return;
|
|
53071
|
+
}
|
|
53072
|
+
state2.timer = setTimeout(attempt, TREE_KILL_RETRY_MS);
|
|
53073
|
+
});
|
|
53074
|
+
};
|
|
53075
|
+
attempt();
|
|
53076
|
+
}
|
|
53035
53077
|
function killTree(child) {
|
|
53036
53078
|
if (process.platform === "win32" && child.pid) {
|
|
53037
53079
|
try {
|
|
53038
53080
|
(0, import_node_child_process2.execFileSync)("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
|
|
53039
53081
|
return;
|
|
53040
53082
|
} catch {
|
|
53083
|
+
retryWindowsTreeKill(child);
|
|
53084
|
+
return;
|
|
53041
53085
|
}
|
|
53042
53086
|
}
|
|
53043
53087
|
try {
|
|
@@ -53332,6 +53376,53 @@ function agentUpdateArgv(id) {
|
|
|
53332
53376
|
function sidecarInstallArgv(host) {
|
|
53333
53377
|
return ["sidecar", "install", assertId(host)];
|
|
53334
53378
|
}
|
|
53379
|
+
function sidecarListArgv() {
|
|
53380
|
+
return ["sidecar", "list"];
|
|
53381
|
+
}
|
|
53382
|
+
function sidecarRepairInstalledArgv() {
|
|
53383
|
+
return ["sidecar", "repair", "--installed"];
|
|
53384
|
+
}
|
|
53385
|
+
var MANAGED_SIDECAR_STATUSES = /* @__PURE__ */ new Set(["current", "stale", "legacy", "missing"]);
|
|
53386
|
+
function parseManagedSidecarInventory(value) {
|
|
53387
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
53388
|
+
throw new AwareManagedSidecarContractError("aware sidecar list returned an invalid managed-sidecar inventory");
|
|
53389
|
+
}
|
|
53390
|
+
const record3 = value;
|
|
53391
|
+
const runtimeVersion = record3["runtime-version"];
|
|
53392
|
+
if (record3["schema-version"] !== 1 || typeof runtimeVersion !== "string" || !Array.isArray(record3.sidecars)) {
|
|
53393
|
+
throw new AwareManagedSidecarContractError("aware CLI does not expose managed-sidecar inventory schema 1 \u2014 update AWARE");
|
|
53394
|
+
}
|
|
53395
|
+
const ids = /* @__PURE__ */ new Set();
|
|
53396
|
+
const sidecars = record3.sidecars.map((row) => {
|
|
53397
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) {
|
|
53398
|
+
throw new AwareManagedSidecarContractError("aware sidecar list returned an invalid sidecar row");
|
|
53399
|
+
}
|
|
53400
|
+
const sidecar = row;
|
|
53401
|
+
const id = sidecar.id;
|
|
53402
|
+
const binary = sidecar.binary;
|
|
53403
|
+
const description = sidecar.description;
|
|
53404
|
+
const status = sidecar.status;
|
|
53405
|
+
const installedVersion = sidecar["installed-version"];
|
|
53406
|
+
const repairEligible = sidecar["repair-eligible"];
|
|
53407
|
+
if (typeof id !== "string" || !id || ids.has(id) || typeof binary !== "string" || !binary || typeof description !== "string" || typeof status !== "string" || !MANAGED_SIDECAR_STATUSES.has(status) || installedVersion !== null && typeof installedVersion !== "string" || typeof repairEligible !== "boolean") {
|
|
53408
|
+
throw new AwareManagedSidecarContractError("aware sidecar list returned an unsupported sidecar row");
|
|
53409
|
+
}
|
|
53410
|
+
ids.add(id);
|
|
53411
|
+
return Object.freeze({
|
|
53412
|
+
id,
|
|
53413
|
+
binary,
|
|
53414
|
+
description,
|
|
53415
|
+
status,
|
|
53416
|
+
installedVersion,
|
|
53417
|
+
repairEligible
|
|
53418
|
+
});
|
|
53419
|
+
});
|
|
53420
|
+
return Object.freeze({
|
|
53421
|
+
schemaVersion: 1,
|
|
53422
|
+
runtimeVersion,
|
|
53423
|
+
sidecars: Object.freeze(sidecars)
|
|
53424
|
+
});
|
|
53425
|
+
}
|
|
53335
53426
|
function parseAgentInstallOutput(stdout) {
|
|
53336
53427
|
const m = stdout.match(/✓\s+(?:installed|updated)\s+(\S+)/);
|
|
53337
53428
|
return { installed: m?.[1] ?? null };
|
|
@@ -53721,9 +53812,40 @@ var awareImpl = {
|
|
|
53721
53812
|
return { output: stdout.trim() };
|
|
53722
53813
|
}, opts.signal), opts.signal);
|
|
53723
53814
|
},
|
|
53815
|
+
/** AWARE's authoritative inventory of managed runtime sidecars. */
|
|
53816
|
+
async managedSidecarInventory() {
|
|
53817
|
+
try {
|
|
53818
|
+
const { data } = await runJson(sidecarListArgv(), 3e4);
|
|
53819
|
+
return parseManagedSidecarInventory(data);
|
|
53820
|
+
} catch (error) {
|
|
53821
|
+
if (error instanceof AwareError && /sidecar list did not return JSON/.test(error.message)) {
|
|
53822
|
+
throw new AwareUnsupportedError("installed AWARE does not support the managed-sidecar inventory contract", error.detail);
|
|
53823
|
+
}
|
|
53824
|
+
throw error;
|
|
53825
|
+
}
|
|
53826
|
+
},
|
|
53724
53827
|
/**
|
|
53725
|
-
*
|
|
53726
|
-
*
|
|
53828
|
+
* Repair every stale installed sidecar in AWARE's own snapshot, then obtain a
|
|
53829
|
+
* fresh inventory. FloLess neither supplies nor parses a sidecar ID list.
|
|
53830
|
+
*/
|
|
53831
|
+
async repairInstalledManagedSidecars(opts = {}) {
|
|
53832
|
+
return withAwareShared(() => withSidecarWrite(async () => {
|
|
53833
|
+
const { code, stdout, stderr } = await runRawWithEnv(
|
|
53834
|
+
sidecarRepairInstalledArgv(),
|
|
53835
|
+
void 0,
|
|
53836
|
+
opts.timeoutMs ?? 6e5,
|
|
53837
|
+
opts.onSpawn,
|
|
53838
|
+
opts.signal
|
|
53839
|
+
);
|
|
53840
|
+
if (code !== 0) throw new AwareError(`aware sidecar repair --installed failed (exit ${code})`, { stdout, stderr });
|
|
53841
|
+
return this.managedSidecarInventory();
|
|
53842
|
+
}, opts.signal), opts.signal);
|
|
53843
|
+
},
|
|
53844
|
+
/**
|
|
53845
|
+
* Ensure the connection-reader bridge (the web-ifc Node SEA) is present.
|
|
53846
|
+
* Catalogue-wide stale-sidecar repair belongs to the caller's exclusive
|
|
53847
|
+
* lifecycle boundary (`aware-managed-sidecars`); this method retains only
|
|
53848
|
+
* the legacy presence/install behavior for the reader it directly needs.
|
|
53727
53849
|
* `aware app run` on a connection-reader node needs this bridge (the tessellator is web-ifc, not
|
|
53728
53850
|
* Rust) — the reader agent's manifest alone isn't enough.
|
|
53729
53851
|
*/
|
|
@@ -54612,7 +54734,7 @@ function appVersion() {
|
|
|
54612
54734
|
return resolveVersion({
|
|
54613
54735
|
isSea: isSea2(),
|
|
54614
54736
|
sqVersionXml: readSqVersionXml(),
|
|
54615
|
-
define: true ? "0.
|
|
54737
|
+
define: true ? "0.127.0" : void 0,
|
|
54616
54738
|
pkgVersion: readPkgVersion()
|
|
54617
54739
|
});
|
|
54618
54740
|
}
|
|
@@ -54628,7 +54750,7 @@ function resolveChannel(s) {
|
|
|
54628
54750
|
function appChannel() {
|
|
54629
54751
|
return resolveChannel({
|
|
54630
54752
|
isSea: isSea2(),
|
|
54631
|
-
define: true ? "0.
|
|
54753
|
+
define: true ? "0.127.0" : void 0,
|
|
54632
54754
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
54633
54755
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
54634
54756
|
modulePath: process.argv[1]
|
|
@@ -57552,7 +57674,7 @@ function createProject(input) {
|
|
|
57552
57674
|
writeMeta(meta);
|
|
57553
57675
|
return meta;
|
|
57554
57676
|
}
|
|
57555
|
-
function renameProject(id, name) {
|
|
57677
|
+
async function renameProject(id, name, migrateSidecars) {
|
|
57556
57678
|
const meta = readMeta(safeProjectId(id));
|
|
57557
57679
|
if (!meta) throw new ProjectError(`unknown project: ${id}`);
|
|
57558
57680
|
if (typeof name !== "string" || !name.trim()) throw new ProjectError("project name required");
|
|
@@ -57565,11 +57687,17 @@ function renameProject(id, name) {
|
|
|
57565
57687
|
} catch {
|
|
57566
57688
|
throw new ProjectError("couldn\u2019t rename the project folder \u2014 it may be open or in use. Close the project and try again.");
|
|
57567
57689
|
}
|
|
57690
|
+
let rollbackSidecars = void 0;
|
|
57568
57691
|
try {
|
|
57692
|
+
rollbackSidecars = await migrateSidecars?.(id, newId);
|
|
57569
57693
|
const next = { ...meta, id: newId, name: nextName, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
57570
57694
|
writeMeta(next);
|
|
57571
57695
|
return next;
|
|
57572
57696
|
} catch (e) {
|
|
57697
|
+
try {
|
|
57698
|
+
await rollbackSidecars?.();
|
|
57699
|
+
} catch {
|
|
57700
|
+
}
|
|
57573
57701
|
try {
|
|
57574
57702
|
(0, import_node_fs18.renameSync)(to, from);
|
|
57575
57703
|
} catch {
|
|
@@ -59807,7 +59935,8 @@ var TYPE_SET = {
|
|
|
59807
59935
|
"new-workflow": true,
|
|
59808
59936
|
"revision-read": true,
|
|
59809
59937
|
"knowledge-organize": true,
|
|
59810
|
-
"knowledge-adjust": true
|
|
59938
|
+
"knowledge-adjust": true,
|
|
59939
|
+
"knowledge-consult": true
|
|
59811
59940
|
};
|
|
59812
59941
|
var REQUEST_TYPES = Object.keys(TYPE_SET);
|
|
59813
59942
|
function isRequestType(t) {
|
|
@@ -59996,6 +60125,7 @@ var RUN_POLICY = {
|
|
|
59996
60125
|
why: "organizing holds a lock a killed run can\u2019t release \u2014 do this one in your terminal"
|
|
59997
60126
|
},
|
|
59998
60127
|
"knowledge-adjust": { runnable: false, why: "organizing holds a lock a killed run can\u2019t release \u2014 do this one in your terminal" },
|
|
60128
|
+
"knowledge-consult": { runnable: false, why: "it changes the workflow structure \u2014 do this one in your terminal" },
|
|
59999
60129
|
guide: { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" },
|
|
60000
60130
|
"new-workflow": { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" }
|
|
60001
60131
|
};
|
|
@@ -60130,7 +60260,11 @@ function kbClause(project, appId) {
|
|
|
60130
60260
|
if (!project) return "";
|
|
60131
60261
|
const guard = appId ? `&app=${appId}` : "";
|
|
60132
60262
|
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
|
|
60263
|
+
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);
|
|
60264
|
+
}
|
|
60265
|
+
function pinClause(project, appId) {
|
|
60266
|
+
if (!appId) return "";
|
|
60267
|
+
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
60268
|
}
|
|
60135
60269
|
function instructionFor(req) {
|
|
60136
60270
|
if (req.type === "use-template" && req.template) {
|
|
@@ -60159,6 +60293,41 @@ New drawing${req.snapshots.length > 1 ? "s" : ""} (read for the re-extraction):
|
|
|
60159
60293
|
if (req.type === "new-workflow") {
|
|
60160
60294
|
return `Help me build a brand-new floless workflow from scratch, step by step, with your floless-app-new-workflow skill. Ask me what I want it to do, then before writing any node confirm the agents it needs are installed (offer to install a missing one from the catalogue, or to report a not-yet-existing agent as an idea). Author the .flo node by node, verifying each step is correct (plain-English descriptions, validate, compile, a real run), and finish by installing \u2192 Compile \u2192 \u25B6 Run so I can see it work and approve.`;
|
|
60161
60295
|
}
|
|
60296
|
+
if (req.type === "knowledge-consult") {
|
|
60297
|
+
return `In floless app "${req.appId}", add the proven deterministic knowledge-consult pair below. Preserve the existing workflow and its inputs, requires, nodes, and connections; add only missing inputs/requires, and choose non-colliding ids if "kb" or "gate" already exists. Do not add a model or agent that interprets knowledge, a vector store, a knowledge-drift Run gate, or any other run-time decision. The knowledge read is retrieval only; its deterministic predicate may gate downstream work. Give the new nodes their plain-English descriptions (the floless-workspace command description for kb and the inline description for gate), then compile the FloLess .flo workflow so the user can choose a project and subject before running.
|
|
60298
|
+
|
|
60299
|
+
\`\`\`yaml
|
|
60300
|
+
inputs:
|
|
60301
|
+
project_id:
|
|
60302
|
+
type: string
|
|
60303
|
+
default: ""
|
|
60304
|
+
widget: workspace-knowledge-project
|
|
60305
|
+
description: Workspace project whose published knowledge this workflow consults.
|
|
60306
|
+
subject:
|
|
60307
|
+
type: string
|
|
60308
|
+
default: ""
|
|
60309
|
+
description: Subject used to rank the project's knowledge pages.
|
|
60310
|
+
requires:
|
|
60311
|
+
- floless-workspace@0.2.x
|
|
60312
|
+
nodes:
|
|
60313
|
+
- id: kb
|
|
60314
|
+
agent: floless-workspace
|
|
60315
|
+
command: read-knowledge
|
|
60316
|
+
mode: read
|
|
60317
|
+
config:
|
|
60318
|
+
project-id: "{{ inputs.project_id }}"
|
|
60319
|
+
q: "{{ inputs.subject }}"
|
|
60320
|
+
- id: gate
|
|
60321
|
+
inline:
|
|
60322
|
+
kind: predicate
|
|
60323
|
+
description: Continue only when the knowledge-base read returned HTTP 200; organize the project's Knowledge step and try again if it cannot be read.
|
|
60324
|
+
code: "e.status == 200"
|
|
60325
|
+
connections:
|
|
60326
|
+
- { from: kb, to: gate }
|
|
60327
|
+
\`\`\`
|
|
60328
|
+
|
|
60329
|
+
This is a required structural edit, not optional advice: find the workflow's existing terminal report node, replace its prior incoming terminal connection with \`gate \u2192 <terminal-report-id>\`, and keep every upstream node that report still needs connected through the workflow. Do not leave \`kb \u2192 gate\` as a disconnected branch. Add report args for the consulted generation and top page, using exactly \`kb.body.generation.generationId\` and \`kb.body.pages[0].slug\`; guard each deep reference with \`{% if kb.body.generation %}\` and \`{% if kb.body.pages %}\` before resolving it, because minijinja raises before \`default()\` can run. Render those args in the terminal report as the generation and top-page citation. If this workflow has no terminal report that can visibly cite the read, stop and explain that instead of adding a disconnected pair. If the read returns no published KB or no match, keep the report honest and direct the user to Organize; do not claim the run was informed.`;
|
|
60330
|
+
}
|
|
60162
60331
|
if (req.type === "revision-read") {
|
|
60163
60332
|
const isInitialRead = !req.baseVersion || req.baseVersion <= 0;
|
|
60164
60333
|
const snaps = req.snapshots && req.snapshots.length ? `
|
|
@@ -60213,7 +60382,8 @@ var REQUEST_SKILL = {
|
|
|
60213
60382
|
"new-workflow": "floless-app-new-workflow",
|
|
60214
60383
|
// Project Knowledge Base: one self-contained skill drives both the organize lifecycle and adjusts.
|
|
60215
60384
|
"knowledge-organize": "floless-app-knowledge",
|
|
60216
|
-
"knowledge-adjust": "floless-app-knowledge"
|
|
60385
|
+
"knowledge-adjust": "floless-app-knowledge",
|
|
60386
|
+
"knowledge-consult": "floless-app-workflows"
|
|
60217
60387
|
};
|
|
60218
60388
|
function markerFor(req, base, body = instructionFor(req)) {
|
|
60219
60389
|
if (!body) return "";
|
|
@@ -60254,6 +60424,35 @@ function enrichedView(r, enrich, base = selfOrigin()) {
|
|
|
60254
60424
|
var import_node_fs27 = require("node:fs");
|
|
60255
60425
|
var import_node_path26 = require("node:path");
|
|
60256
60426
|
|
|
60427
|
+
// aware-managed-sidecars.ts
|
|
60428
|
+
var liveDeps = {
|
|
60429
|
+
inventory: () => aware.managedSidecarInventory(),
|
|
60430
|
+
repair: () => aware.repairInstalledManagedSidecars(),
|
|
60431
|
+
withExclusive: (fn) => withAwareExclusive(fn)
|
|
60432
|
+
};
|
|
60433
|
+
var needsRepair = (inventory) => inventory.sidecars.filter((sidecar) => sidecar.repairEligible).length;
|
|
60434
|
+
async function ensureManagedSidecarsForUserAction(deps = liveDeps) {
|
|
60435
|
+
let initial;
|
|
60436
|
+
try {
|
|
60437
|
+
initial = await deps.inventory();
|
|
60438
|
+
} catch (error) {
|
|
60439
|
+
if (error instanceof AwareUnsupportedError) return { supported: false, repaired: 0 };
|
|
60440
|
+
throw error;
|
|
60441
|
+
}
|
|
60442
|
+
if (needsRepair(initial) === 0) return { supported: true, repaired: 0 };
|
|
60443
|
+
return deps.withExclusive(async () => {
|
|
60444
|
+
const before = await deps.inventory();
|
|
60445
|
+
const count = needsRepair(before);
|
|
60446
|
+
if (count === 0) return { supported: true, repaired: 0 };
|
|
60447
|
+
const after = await deps.repair();
|
|
60448
|
+
const remaining2 = needsRepair(after);
|
|
60449
|
+
if (remaining2 > 0) {
|
|
60450
|
+
throw new AwareError(`AWARE left ${remaining2} managed runtime tool(s) needing repair.`);
|
|
60451
|
+
}
|
|
60452
|
+
return { supported: true, repaired: count };
|
|
60453
|
+
});
|
|
60454
|
+
}
|
|
60455
|
+
|
|
60257
60456
|
// ifc-frame.ts
|
|
60258
60457
|
var FILE_Z_UP = "z-up";
|
|
60259
60458
|
var FILE_Y_UP = "y-up";
|
|
@@ -60276,6 +60475,7 @@ var ConnectionImportError = class extends Error {
|
|
|
60276
60475
|
};
|
|
60277
60476
|
async function ensureConnectionReader() {
|
|
60278
60477
|
try {
|
|
60478
|
+
await ensureManagedSidecarsForUserAction();
|
|
60279
60479
|
await aware.ensureAgentInstalled(AGENT);
|
|
60280
60480
|
await aware.ensureConnectionReaderBridge();
|
|
60281
60481
|
} catch (e) {
|
|
@@ -63910,8 +64110,11 @@ var GEN_KEEP = 3;
|
|
|
63910
64110
|
var vaultDir = (id) => (0, import_node_path31.join)(projectKnowledgeDir(id), "vault");
|
|
63911
64111
|
var generationsDir = (id) => (0, import_node_path31.join)(vaultDir(id), "generations");
|
|
63912
64112
|
var currentGenerationPath = (id) => (0, import_node_path31.join)(vaultDir(id), "current-generation.json");
|
|
64113
|
+
function isGenerationId(value) {
|
|
64114
|
+
return typeof value === "string" && GENERATION_ID_RE.test(value);
|
|
64115
|
+
}
|
|
63913
64116
|
function assertGenerationId(generationId) {
|
|
63914
|
-
if (
|
|
64117
|
+
if (!isGenerationId(generationId)) {
|
|
63915
64118
|
throw new KnowledgeError("invalid generation id");
|
|
63916
64119
|
}
|
|
63917
64120
|
}
|
|
@@ -63960,6 +64163,9 @@ function currentGenerationWikiDir(id) {
|
|
|
63960
64163
|
return (0, import_node_fs33.existsSync)(dir) ? dir : null;
|
|
63961
64164
|
}
|
|
63962
64165
|
var WIKI_SLUG_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
64166
|
+
function isWikiSlug(value) {
|
|
64167
|
+
return typeof value === "string" && WIKI_SLUG_RE.test(value);
|
|
64168
|
+
}
|
|
63963
64169
|
var KB_MAX_NODES = 300;
|
|
63964
64170
|
var KB_MAX_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
63965
64171
|
var KB_MAX_VISITS = 5e3;
|
|
@@ -64588,7 +64794,15 @@ function registerKnowledgeRoutes(app) {
|
|
|
64588
64794
|
try {
|
|
64589
64795
|
const project = getProject(req.params.id);
|
|
64590
64796
|
if (!project) return reply.status(404).send({ ok: false, error: `unknown project: ${req.params.id}` });
|
|
64591
|
-
|
|
64797
|
+
let wikiDir;
|
|
64798
|
+
if (req.query.generation === void 0) {
|
|
64799
|
+
wikiDir = currentGenerationWikiDir(project.id);
|
|
64800
|
+
} else if (typeof req.query.generation === "string" && isGenerationId(req.query.generation)) {
|
|
64801
|
+
const requested = generationWikiDir(project.id, req.query.generation);
|
|
64802
|
+
wikiDir = (0, import_node_fs34.existsSync)(requested) ? requested : null;
|
|
64803
|
+
} else {
|
|
64804
|
+
return reply.status(400).send({ ok: false, error: "invalid generation id" });
|
|
64805
|
+
}
|
|
64592
64806
|
const pg = wikiDir ? readPage(wikiDir, req.params.slug) : null;
|
|
64593
64807
|
if (!pg) return reply.status(404).send({ ok: false, error: "page not found" });
|
|
64594
64808
|
return { ok: true, page: pg };
|
|
@@ -70075,6 +70289,7 @@ function writeReaderApp2(companionId, command, ifcPath, filter) {
|
|
|
70075
70289
|
}
|
|
70076
70290
|
async function ensureReferenceReader() {
|
|
70077
70291
|
try {
|
|
70292
|
+
await ensureManagedSidecarsForUserAction();
|
|
70078
70293
|
await aware.ensureAgentInstalled(AGENT2);
|
|
70079
70294
|
await aware.ensureConnectionReaderBridge();
|
|
70080
70295
|
} catch (e) {
|
|
@@ -76387,9 +76602,6 @@ function values(input) {
|
|
|
76387
76602
|
function optionalString(v) {
|
|
76388
76603
|
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
76389
76604
|
}
|
|
76390
|
-
function sameAppLineage(a, b) {
|
|
76391
|
-
return a === b || resolveTemplateId(a) === resolveTemplateId(b);
|
|
76392
|
-
}
|
|
76393
76605
|
function parseBool(v, fallback2) {
|
|
76394
76606
|
if (v === void 0) return fallback2;
|
|
76395
76607
|
if (Array.isArray(v)) return null;
|
|
@@ -76568,11 +76780,13 @@ function registerWorkspaceDataRoutes(app) {
|
|
|
76568
76780
|
const limit = parseIntParam(req.query.limit);
|
|
76569
76781
|
if (limit === null) return sendError(reply, 400, "invalid limit");
|
|
76570
76782
|
const q = optionalString(req.query.q);
|
|
76571
|
-
const
|
|
76572
|
-
if (!
|
|
76783
|
+
const generation = readCurrentGeneration(project.id);
|
|
76784
|
+
if (!generation) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
|
|
76785
|
+
const wikiDir = generationWikiDir(project.id, generation.generationId);
|
|
76786
|
+
if (!(0, import_node_fs48.existsSync)(wikiDir)) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
|
|
76573
76787
|
try {
|
|
76574
76788
|
const feed = readKnowledgeSummaries(wikiDir, { q, limit: limit ?? void 0 });
|
|
76575
|
-
return { ok: true, generation
|
|
76789
|
+
return { ok: true, generation, ...feed };
|
|
76576
76790
|
} catch (e) {
|
|
76577
76791
|
if (e instanceof KnowledgeError) return sendError(reply, knowledgeErrorStatus(e), e.message);
|
|
76578
76792
|
throw e;
|
|
@@ -76581,6 +76795,53 @@ function registerWorkspaceDataRoutes(app) {
|
|
|
76581
76795
|
);
|
|
76582
76796
|
}
|
|
76583
76797
|
|
|
76798
|
+
// app-id.ts
|
|
76799
|
+
var APP_ID4 = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
76800
|
+
function isSafeAppId2(value) {
|
|
76801
|
+
return typeof value === "string" && APP_ID4.test(value) && safeSegment(value);
|
|
76802
|
+
}
|
|
76803
|
+
|
|
76804
|
+
// contract-request-route.ts
|
|
76805
|
+
function registerContractRequestRoute(app, deps) {
|
|
76806
|
+
app.post(
|
|
76807
|
+
"/api/contract-request",
|
|
76808
|
+
{ bodyLimit: 25 * 1024 * 1024 },
|
|
76809
|
+
async (req, reply) => {
|
|
76810
|
+
const { appId, project, instruction, intent, target, snapshots } = req.body ?? {};
|
|
76811
|
+
if (!isSafeAppId2(appId)) {
|
|
76812
|
+
return reply.status(400).send({ ok: false, error: "invalid appId" });
|
|
76813
|
+
}
|
|
76814
|
+
if (typeof instruction !== "string" || !instruction) {
|
|
76815
|
+
return reply.status(400).send({ ok: false, error: "instruction required" });
|
|
76816
|
+
}
|
|
76817
|
+
let projectId;
|
|
76818
|
+
let requestAppId = appId;
|
|
76819
|
+
if (project !== void 0) {
|
|
76820
|
+
if (!isProjectId(project)) return reply.status(400).send({ ok: false, error: "invalid project id" });
|
|
76821
|
+
const targetProject = getProject(project);
|
|
76822
|
+
if (!targetProject) return reply.status(404).send({ ok: false, error: `unknown project: ${project}` });
|
|
76823
|
+
if (!sameAppLineage(appId, targetProject.app)) {
|
|
76824
|
+
return reply.status(404).send({ ok: false, error: `project "${targetProject.id}" belongs to app "${targetProject.app}", not "${appId}"` });
|
|
76825
|
+
}
|
|
76826
|
+
projectId = targetProject.id;
|
|
76827
|
+
requestAppId = targetProject.app;
|
|
76828
|
+
}
|
|
76829
|
+
let decoded;
|
|
76830
|
+
try {
|
|
76831
|
+
decoded = decodeSnapshots(snapshots);
|
|
76832
|
+
} catch (e) {
|
|
76833
|
+
return reply.status(400).send({ ok: false, error: e instanceof Error ? e.message : "bad snapshot" });
|
|
76834
|
+
}
|
|
76835
|
+
const request = addRequest(
|
|
76836
|
+
{ type: "tweak-contract", appId: requestAppId, ...projectId ? { project: projectId } : {}, instruction, ...intent ? { intent } : {}, ...target ? { target } : {} },
|
|
76837
|
+
decoded
|
|
76838
|
+
);
|
|
76839
|
+
deps.broadcast({ type: "request-added", request });
|
|
76840
|
+
return { ok: true, request: deps.requestView(request) };
|
|
76841
|
+
}
|
|
76842
|
+
);
|
|
76843
|
+
}
|
|
76844
|
+
|
|
76584
76845
|
// project-publication-state.ts
|
|
76585
76846
|
function classifyProjectPublicationState(appId, liveProjects) {
|
|
76586
76847
|
return liveProjects.some((project) => project.app === appId) ? "project-publication" : "project-publication-missing-project";
|
|
@@ -76737,17 +76998,79 @@ function registerMigrationCommitRoute(app, deps) {
|
|
|
76737
76998
|
var import_node_fs49 = require("node:fs");
|
|
76738
76999
|
var import_node_os22 = require("node:os");
|
|
76739
77000
|
var import_node_path44 = require("node:path");
|
|
77001
|
+
var WORKSPACE_MANIFEST_VERSION = "0.2.1";
|
|
77002
|
+
var OWNER_FILE = "floless-workspace.owner.json";
|
|
76740
77003
|
function awareHome() {
|
|
76741
77004
|
return process.env.AWARE_HOME || (0, import_node_path44.join)((0, import_node_os22.homedir)(), ".aware");
|
|
76742
77005
|
}
|
|
76743
77006
|
function workspaceAgentDir() {
|
|
76744
77007
|
return (0, import_node_path44.join)(awareHome(), "agents", "floless-workspace");
|
|
76745
77008
|
}
|
|
76746
|
-
function
|
|
77009
|
+
function ownerPath2(dir) {
|
|
77010
|
+
return (0, import_node_path44.join)(dir, OWNER_FILE);
|
|
77011
|
+
}
|
|
77012
|
+
function readOwner2(path) {
|
|
77013
|
+
try {
|
|
77014
|
+
const parsed = JSON.parse((0, import_node_fs49.readFileSync)(path, "utf8"));
|
|
77015
|
+
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 {
|
|
77016
|
+
pid: parsed.pid,
|
|
77017
|
+
port: parsed.port,
|
|
77018
|
+
manifestVersion: parsed.manifestVersion
|
|
77019
|
+
};
|
|
77020
|
+
} catch {
|
|
77021
|
+
}
|
|
77022
|
+
return null;
|
|
77023
|
+
}
|
|
77024
|
+
function processIsAlive(pid) {
|
|
77025
|
+
try {
|
|
77026
|
+
process.kill(pid, 0);
|
|
77027
|
+
return true;
|
|
77028
|
+
} catch (err2) {
|
|
77029
|
+
return err2.code === "EPERM";
|
|
77030
|
+
}
|
|
77031
|
+
}
|
|
77032
|
+
function syncWorkspaceAgentManifest(port, deps = {}) {
|
|
76747
77033
|
const dir = workspaceAgentDir();
|
|
76748
77034
|
(0, import_node_fs49.mkdirSync)(dir, { recursive: true });
|
|
77035
|
+
const ownPath = ownerPath2(dir);
|
|
77036
|
+
const pid = deps.pid ?? process.pid;
|
|
77037
|
+
const isAlive = deps.isProcessAlive ?? processIsAlive;
|
|
77038
|
+
const mine = { pid, port, manifestVersion: WORKSPACE_MANIFEST_VERSION };
|
|
77039
|
+
let previousOwner = null;
|
|
77040
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
77041
|
+
const current = readOwner2(ownPath);
|
|
77042
|
+
if (current && isAlive(current.pid)) {
|
|
77043
|
+
if (current.pid !== pid) {
|
|
77044
|
+
return { path: (0, import_node_path44.join)(dir, "manifest.yaml"), owner: current, outcome: "preserved-live-owner", previousOwner: current };
|
|
77045
|
+
}
|
|
77046
|
+
previousOwner = current;
|
|
77047
|
+
break;
|
|
77048
|
+
}
|
|
77049
|
+
previousOwner = current;
|
|
77050
|
+
if ((0, import_node_fs49.existsSync)(ownPath)) {
|
|
77051
|
+
try {
|
|
77052
|
+
(0, import_node_fs49.unlinkSync)(ownPath);
|
|
77053
|
+
} catch {
|
|
77054
|
+
continue;
|
|
77055
|
+
}
|
|
77056
|
+
}
|
|
77057
|
+
try {
|
|
77058
|
+
(0, import_node_fs49.writeFileSync)(ownPath, `${JSON.stringify(mine)}
|
|
77059
|
+
`, { encoding: "utf8", flag: "wx" });
|
|
77060
|
+
break;
|
|
77061
|
+
} catch (err2) {
|
|
77062
|
+
if (err2.code !== "EEXIST") throw err2;
|
|
77063
|
+
}
|
|
77064
|
+
}
|
|
77065
|
+
const claimed2 = readOwner2(ownPath);
|
|
77066
|
+
if (!claimed2 || claimed2.pid !== mine.pid || claimed2.port !== mine.port) {
|
|
77067
|
+
if (claimed2 && isAlive(claimed2.pid)) {
|
|
77068
|
+
return { path: (0, import_node_path44.join)(dir, "manifest.yaml"), owner: claimed2, outcome: "preserved-live-owner", previousOwner: claimed2 };
|
|
77069
|
+
}
|
|
77070
|
+
throw new Error("could not claim floless-workspace manifest ownership");
|
|
77071
|
+
}
|
|
76749
77072
|
const manifest = `agent: floless-workspace
|
|
76750
|
-
version:
|
|
77073
|
+
version: ${WORKSPACE_MANIFEST_VERSION}
|
|
76751
77074
|
sdk-target: 2.4.0
|
|
76752
77075
|
display-name: FloLess Workspace
|
|
76753
77076
|
description: |
|
|
@@ -76890,8 +77213,24 @@ commands:
|
|
|
76890
77213
|
body: object
|
|
76891
77214
|
`;
|
|
76892
77215
|
const path = (0, import_node_path44.join)(dir, "manifest.yaml");
|
|
76893
|
-
|
|
76894
|
-
|
|
77216
|
+
try {
|
|
77217
|
+
(0, import_node_fs49.writeFileSync)(path, manifest, "utf8");
|
|
77218
|
+
} catch (err2) {
|
|
77219
|
+
const current = readOwner2(ownPath);
|
|
77220
|
+
if (current?.pid === mine.pid && current.port === mine.port) {
|
|
77221
|
+
try {
|
|
77222
|
+
(0, import_node_fs49.unlinkSync)(ownPath);
|
|
77223
|
+
} catch {
|
|
77224
|
+
}
|
|
77225
|
+
}
|
|
77226
|
+
throw err2;
|
|
77227
|
+
}
|
|
77228
|
+
return {
|
|
77229
|
+
path,
|
|
77230
|
+
owner: mine,
|
|
77231
|
+
outcome: previousOwner ? "reclaimed-stale-owner" : "written",
|
|
77232
|
+
previousOwner
|
|
77233
|
+
};
|
|
76895
77234
|
}
|
|
76896
77235
|
|
|
76897
77236
|
// steel-diff.ts
|
|
@@ -78498,6 +78837,14 @@ function awareFailureMessage(e, fallback2) {
|
|
|
78498
78837
|
if (!message || INPUTS_TEMPFILE.test(message)) return fallback2;
|
|
78499
78838
|
return message;
|
|
78500
78839
|
}
|
|
78840
|
+
function agentUpdateFailureMessage(e, id) {
|
|
78841
|
+
const fallback2 = `Could not update \u201C${id}\u201D.`;
|
|
78842
|
+
const message = awareFailureMessage(e, fallback2);
|
|
78843
|
+
if (/^conflict:\s*agent\s+\S+\s+has version\s+.+?\s+installed,\s+which the registry does not publish\b/i.test(message)) {
|
|
78844
|
+
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.`;
|
|
78845
|
+
}
|
|
78846
|
+
return message;
|
|
78847
|
+
}
|
|
78501
78848
|
|
|
78502
78849
|
// scene-bake.ts
|
|
78503
78850
|
var import_node_fs51 = require("node:fs");
|
|
@@ -79717,9 +80064,9 @@ function nothingToApprove(contract) {
|
|
|
79717
80064
|
}
|
|
79718
80065
|
|
|
79719
80066
|
// app-lifecycle.ts
|
|
79720
|
-
var
|
|
79721
|
-
var
|
|
79722
|
-
var
|
|
80067
|
+
var import_node_fs57 = require("node:fs");
|
|
80068
|
+
var import_node_os26 = require("node:os");
|
|
80069
|
+
var import_node_path51 = require("node:path");
|
|
79723
80070
|
|
|
79724
80071
|
// routines.ts
|
|
79725
80072
|
var import_node_fs55 = require("node:fs");
|
|
@@ -80525,8 +80872,184 @@ async function stopScheduler() {
|
|
|
80525
80872
|
await stopAllSessions();
|
|
80526
80873
|
}
|
|
80527
80874
|
|
|
80875
|
+
// kb-pin-store.ts
|
|
80876
|
+
var import_node_fs56 = require("node:fs");
|
|
80877
|
+
var import_node_path50 = require("node:path");
|
|
80878
|
+
var import_node_os25 = require("node:os");
|
|
80879
|
+
var KbPinError = class extends Error {
|
|
80880
|
+
code;
|
|
80881
|
+
constructor(message, code) {
|
|
80882
|
+
super(message);
|
|
80883
|
+
this.name = "KbPinError";
|
|
80884
|
+
this.code = code;
|
|
80885
|
+
}
|
|
80886
|
+
};
|
|
80887
|
+
var pinsDir = () => (0, import_node_path50.join)(process.env.FLOLESS_HOME ?? (0, import_node_path50.join)((0, import_node_os25.homedir)(), ".floless"), "kb-pins");
|
|
80888
|
+
var withPinLock = (fn) => withLifecycleLock("internal-export", "kb-pin-store", fn);
|
|
80889
|
+
var KB_PIN_MAX_PAGES = 20;
|
|
80890
|
+
var KB_PIN_MAX_TITLE = 200;
|
|
80891
|
+
var ISO_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
80892
|
+
var isIsoTimestamp = (v) => {
|
|
80893
|
+
if (typeof v !== "string") return false;
|
|
80894
|
+
const m = ISO_RE.exec(v);
|
|
80895
|
+
if (!m) return false;
|
|
80896
|
+
const year = Number(m[1]);
|
|
80897
|
+
const month = Number(m[2]);
|
|
80898
|
+
const day2 = Number(m[3]);
|
|
80899
|
+
const hour2 = Number(m[4]);
|
|
80900
|
+
const minute = Number(m[5]);
|
|
80901
|
+
const second = Number(m[6]);
|
|
80902
|
+
const millis = Number((m[7] ?? "").padEnd(3, "0"));
|
|
80903
|
+
const offsetHour = Number(m[9] ?? 0);
|
|
80904
|
+
const offsetMinute = Number(m[10] ?? 0);
|
|
80905
|
+
if (offsetHour > 23 || offsetMinute > 59) return false;
|
|
80906
|
+
const calendar = /* @__PURE__ */ new Date(0);
|
|
80907
|
+
calendar.setUTCFullYear(year, month - 1, day2);
|
|
80908
|
+
calendar.setUTCHours(hour2, minute, second, millis);
|
|
80909
|
+
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));
|
|
80910
|
+
};
|
|
80911
|
+
function safeAppId(appId) {
|
|
80912
|
+
if (typeof appId !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(appId)) {
|
|
80913
|
+
throw new KbPinError(`invalid appId: ${String(appId)}`, "invalid-app");
|
|
80914
|
+
}
|
|
80915
|
+
return appId;
|
|
80916
|
+
}
|
|
80917
|
+
var isProjectId2 = (v) => typeof v === "string" && /^[a-z0-9][a-z0-9-]*$/.test(v);
|
|
80918
|
+
var pinPath = (appId) => (0, import_node_path50.join)(pinsDir(), `${safeAppId(appId)}.json`);
|
|
80919
|
+
function assertAppId(appId) {
|
|
80920
|
+
safeAppId(appId);
|
|
80921
|
+
}
|
|
80922
|
+
function normalizePages(pages) {
|
|
80923
|
+
if (!Array.isArray(pages)) throw new KbPinError("pages must be an array", "invalid-pages");
|
|
80924
|
+
if (pages.length > KB_PIN_MAX_PAGES) {
|
|
80925
|
+
throw new KbPinError(`pages must be at most ${KB_PIN_MAX_PAGES} entries`, "invalid-pages");
|
|
80926
|
+
}
|
|
80927
|
+
const seen = /* @__PURE__ */ new Set();
|
|
80928
|
+
const out = [];
|
|
80929
|
+
for (const page of pages) {
|
|
80930
|
+
const p = page;
|
|
80931
|
+
if (!p || typeof p !== "object") throw new KbPinError("each page must be an object", "invalid-pages");
|
|
80932
|
+
if (!isWikiSlug(p.slug)) throw new KbPinError(`invalid page slug: ${String(p.slug)}`, "invalid-pages");
|
|
80933
|
+
if (typeof p.title !== "string" || p.title.length > KB_PIN_MAX_TITLE) {
|
|
80934
|
+
throw new KbPinError(`invalid page title for "${p.slug}"`, "invalid-pages");
|
|
80935
|
+
}
|
|
80936
|
+
if (seen.has(p.slug)) continue;
|
|
80937
|
+
seen.add(p.slug);
|
|
80938
|
+
out.push({ slug: p.slug, title: p.title });
|
|
80939
|
+
}
|
|
80940
|
+
return out;
|
|
80941
|
+
}
|
|
80942
|
+
function readPinUnlocked(appId) {
|
|
80943
|
+
const p = pinPath(appId);
|
|
80944
|
+
if (!(0, import_node_fs56.existsSync)(p)) return null;
|
|
80945
|
+
try {
|
|
80946
|
+
const parsed = JSON.parse((0, import_node_fs56.readFileSync)(p, "utf8"));
|
|
80947
|
+
if (!parsed || typeof parsed !== "object") {
|
|
80948
|
+
console.warn(`kb-pin-store: ignoring schema-invalid pin at ${p} (not an object)`);
|
|
80949
|
+
return null;
|
|
80950
|
+
}
|
|
80951
|
+
if (!isProjectId2(parsed.projectId) || !isGenerationId(parsed.generationId) || !isIsoTimestamp(parsed.pinnedAt)) {
|
|
80952
|
+
console.warn(`kb-pin-store: ignoring schema-invalid pin at ${p} (bad projectId/generationId/pinnedAt)`);
|
|
80953
|
+
return null;
|
|
80954
|
+
}
|
|
80955
|
+
let pages;
|
|
80956
|
+
try {
|
|
80957
|
+
pages = normalizePages(parsed.pages);
|
|
80958
|
+
} catch (e) {
|
|
80959
|
+
console.warn(`kb-pin-store: ignoring schema-invalid pin at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
80960
|
+
return null;
|
|
80961
|
+
}
|
|
80962
|
+
return { projectId: parsed.projectId, generationId: parsed.generationId, pinnedAt: parsed.pinnedAt, pages };
|
|
80963
|
+
} catch (e) {
|
|
80964
|
+
console.warn(`kb-pin-store: ignoring unreadable pin at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
80965
|
+
return null;
|
|
80966
|
+
}
|
|
80967
|
+
}
|
|
80968
|
+
function readPin(appId) {
|
|
80969
|
+
return withPinLock(() => readPinUnlocked(appId));
|
|
80970
|
+
}
|
|
80971
|
+
function writePinUnlocked(appId, pin) {
|
|
80972
|
+
const p = pinPath(appId);
|
|
80973
|
+
if (!isProjectId2(pin.projectId)) {
|
|
80974
|
+
throw new KbPinError(`invalid project id: ${String(pin.projectId)}`, "invalid-project");
|
|
80975
|
+
}
|
|
80976
|
+
if (!isGenerationId(pin.generationId)) {
|
|
80977
|
+
throw new KbPinError(`invalid generation id: ${String(pin.generationId)}`, "invalid-generation");
|
|
80978
|
+
}
|
|
80979
|
+
const doc = {
|
|
80980
|
+
projectId: pin.projectId,
|
|
80981
|
+
generationId: pin.generationId,
|
|
80982
|
+
pinnedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
80983
|
+
pages: normalizePages(pin.pages)
|
|
80984
|
+
};
|
|
80985
|
+
(0, import_node_fs56.mkdirSync)((0, import_node_path50.dirname)(p), { recursive: true });
|
|
80986
|
+
writeJsonAtomic(p, doc);
|
|
80987
|
+
return doc;
|
|
80988
|
+
}
|
|
80989
|
+
function writePin(appId, pin) {
|
|
80990
|
+
return withPinLock(() => writePinUnlocked(appId, pin));
|
|
80991
|
+
}
|
|
80992
|
+
function movePinBytesUnlocked(fromAppId, toAppId) {
|
|
80993
|
+
const from = pinPath(fromAppId);
|
|
80994
|
+
const to = pinPath(toAppId);
|
|
80995
|
+
if (from === to || !(0, import_node_fs56.existsSync)(from)) return false;
|
|
80996
|
+
(0, import_node_fs56.mkdirSync)((0, import_node_path50.dirname)(to), { recursive: true });
|
|
80997
|
+
(0, import_node_fs56.renameSync)(from, to);
|
|
80998
|
+
return true;
|
|
80999
|
+
}
|
|
81000
|
+
function movePinBytes(fromAppId, toAppId) {
|
|
81001
|
+
return withPinLock(() => movePinBytesUnlocked(fromAppId, toAppId));
|
|
81002
|
+
}
|
|
81003
|
+
function dropPinBytesUnlocked(appId) {
|
|
81004
|
+
const p = pinPath(appId);
|
|
81005
|
+
if (!(0, import_node_fs56.existsSync)(p)) return false;
|
|
81006
|
+
(0, import_node_fs56.rmSync)(p, { force: true });
|
|
81007
|
+
return true;
|
|
81008
|
+
}
|
|
81009
|
+
function dropPinBytes(appId) {
|
|
81010
|
+
return withPinLock(() => dropPinBytesUnlocked(appId));
|
|
81011
|
+
}
|
|
81012
|
+
function repointProjectPinsUnlocked(fromProjectId, toProjectId) {
|
|
81013
|
+
if (!isProjectId2(fromProjectId) || !isProjectId2(toProjectId)) {
|
|
81014
|
+
throw new KbPinError("invalid project id for pin repoint", "invalid-project");
|
|
81015
|
+
}
|
|
81016
|
+
if (fromProjectId === toProjectId || !(0, import_node_fs56.existsSync)(pinsDir())) return 0;
|
|
81017
|
+
const targets = [];
|
|
81018
|
+
for (const entry2 of (0, import_node_fs56.readdirSync)(pinsDir(), { withFileTypes: true })) {
|
|
81019
|
+
if (!entry2.isFile() || !entry2.name.endsWith(".json")) continue;
|
|
81020
|
+
const appId = (0, import_node_path50.basename)(entry2.name, ".json");
|
|
81021
|
+
let pin;
|
|
81022
|
+
try {
|
|
81023
|
+
pin = readPinUnlocked(appId);
|
|
81024
|
+
} catch {
|
|
81025
|
+
continue;
|
|
81026
|
+
}
|
|
81027
|
+
if (!pin || pin.projectId !== fromProjectId) continue;
|
|
81028
|
+
targets.push({ path: pinPath(appId), pin });
|
|
81029
|
+
}
|
|
81030
|
+
const written = [];
|
|
81031
|
+
try {
|
|
81032
|
+
for (const target of targets) {
|
|
81033
|
+
writeJsonAtomic(target.path, { ...target.pin, projectId: toProjectId });
|
|
81034
|
+
written.push(target);
|
|
81035
|
+
}
|
|
81036
|
+
} catch (e) {
|
|
81037
|
+
for (const target of written.reverse()) {
|
|
81038
|
+
try {
|
|
81039
|
+
writeJsonAtomic(target.path, target.pin);
|
|
81040
|
+
} catch {
|
|
81041
|
+
}
|
|
81042
|
+
}
|
|
81043
|
+
throw e;
|
|
81044
|
+
}
|
|
81045
|
+
return targets.length;
|
|
81046
|
+
}
|
|
81047
|
+
function repointProjectPins(fromProjectId, toProjectId) {
|
|
81048
|
+
return withPinLock(() => repointProjectPinsUnlocked(fromProjectId, toProjectId));
|
|
81049
|
+
}
|
|
81050
|
+
|
|
80528
81051
|
// app-lifecycle.ts
|
|
80529
|
-
var
|
|
81052
|
+
var APP_ID5 = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
80530
81053
|
var AppLifecycleError = class extends Error {
|
|
80531
81054
|
status;
|
|
80532
81055
|
constructor(message, status) {
|
|
@@ -80536,17 +81059,27 @@ var AppLifecycleError = class extends Error {
|
|
|
80536
81059
|
}
|
|
80537
81060
|
};
|
|
80538
81061
|
function appsDir() {
|
|
80539
|
-
return process.env.AWARE_HOME ? (0,
|
|
81062
|
+
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
81063
|
}
|
|
80541
81064
|
function appDirPath(id) {
|
|
80542
|
-
return (0,
|
|
81065
|
+
return (0, import_node_path51.join)(appsDir(), id);
|
|
80543
81066
|
}
|
|
80544
81067
|
function appInstalled(id) {
|
|
80545
|
-
return
|
|
81068
|
+
return APP_ID5.test(id) && (0, import_node_fs57.existsSync)(appDirPath(id));
|
|
80546
81069
|
}
|
|
80547
81070
|
function logCascade(what, e) {
|
|
80548
81071
|
console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
|
|
80549
81072
|
}
|
|
81073
|
+
async function clearDestinationPin(newId) {
|
|
81074
|
+
try {
|
|
81075
|
+
await dropPinBytes(newId);
|
|
81076
|
+
} catch (e) {
|
|
81077
|
+
throw new AppLifecycleError(
|
|
81078
|
+
`could not clear stale knowledge provenance for "${newId}": ${e instanceof Error ? e.message : String(e)}`,
|
|
81079
|
+
500
|
|
81080
|
+
);
|
|
81081
|
+
}
|
|
81082
|
+
}
|
|
80550
81083
|
function mapAwareError(e) {
|
|
80551
81084
|
const code = e instanceof AwareError ? e.detail?.code : void 0;
|
|
80552
81085
|
if (code === 8) throw new AppLifecycleError("a workflow with that name already exists", 409);
|
|
@@ -80555,7 +81088,7 @@ function mapAwareError(e) {
|
|
|
80555
81088
|
throw e;
|
|
80556
81089
|
}
|
|
80557
81090
|
function assertNewId(newId) {
|
|
80558
|
-
if (!newId || !
|
|
81091
|
+
if (!newId || !APP_ID5.test(newId) || !safeSegment(newId)) {
|
|
80559
81092
|
throw new AppLifecycleError('name must be letters, digits, dot, dash or underscore (no spaces, slashes or "..")', 400);
|
|
80560
81093
|
}
|
|
80561
81094
|
}
|
|
@@ -80569,6 +81102,7 @@ async function renameApp(oldId, newId, deps = defaultDeps2) {
|
|
|
80569
81102
|
assertNewId(newId);
|
|
80570
81103
|
if (newId === oldId) throw new AppLifecycleError("that is already its name", 400);
|
|
80571
81104
|
if (appInstalled(newId)) throw new AppLifecycleError(`a workflow named "${newId}" already exists`, 409);
|
|
81105
|
+
await clearDestinationPin(newId);
|
|
80572
81106
|
const originRenameToken = await beginOriginRename(oldId, newId);
|
|
80573
81107
|
let compiled;
|
|
80574
81108
|
let originCompleted = false;
|
|
@@ -80623,6 +81157,11 @@ async function renameApp(oldId, newId, deps = defaultDeps2) {
|
|
|
80623
81157
|
} catch (e) {
|
|
80624
81158
|
logCascade("move contract", e);
|
|
80625
81159
|
}
|
|
81160
|
+
try {
|
|
81161
|
+
await movePinBytes(oldId, newId);
|
|
81162
|
+
} catch (e) {
|
|
81163
|
+
logCascade("move knowledge pin", e);
|
|
81164
|
+
}
|
|
80626
81165
|
let projectsStale;
|
|
80627
81166
|
try {
|
|
80628
81167
|
projectsStale = repointProjects(oldId, newId).skipped.length;
|
|
@@ -80636,6 +81175,7 @@ async function duplicateApp(srcId, newId, deps = defaultDeps2) {
|
|
|
80636
81175
|
if (!appInstalled(srcId)) throw new AppLifecycleError(`workflow not found: ${srcId}`, 404);
|
|
80637
81176
|
assertNewId(newId);
|
|
80638
81177
|
if (appInstalled(newId)) throw new AppLifecycleError(`a workflow named "${newId}" already exists`, 409);
|
|
81178
|
+
await clearDestinationPin(newId);
|
|
80639
81179
|
const originDuplicateToken = await beginOriginDuplicate(srcId, newId);
|
|
80640
81180
|
let compiled;
|
|
80641
81181
|
let originCompleted = false;
|
|
@@ -80726,6 +81266,80 @@ async function deleteApp(id, deps = defaultDeps2) {
|
|
|
80726
81266
|
} catch (e) {
|
|
80727
81267
|
logCascade("drop contract", e);
|
|
80728
81268
|
}
|
|
81269
|
+
try {
|
|
81270
|
+
await dropPinBytes(id);
|
|
81271
|
+
} catch (e) {
|
|
81272
|
+
logCascade("drop knowledge pin", e);
|
|
81273
|
+
}
|
|
81274
|
+
}
|
|
81275
|
+
|
|
81276
|
+
// kb-pin-routes.ts
|
|
81277
|
+
var import_node_fs58 = require("node:fs");
|
|
81278
|
+
function driftOf(pin) {
|
|
81279
|
+
const cur = readCurrentGeneration(pin.projectId);
|
|
81280
|
+
if (cur === null) return true;
|
|
81281
|
+
if (!(0, import_node_fs58.existsSync)(generationWikiDir(pin.projectId, cur.generationId))) return true;
|
|
81282
|
+
return cur.generationId !== pin.generationId;
|
|
81283
|
+
}
|
|
81284
|
+
function registerKbPinRoutes(app, deps) {
|
|
81285
|
+
app.get("/api/kb-pin/:appId", async (req, reply) => {
|
|
81286
|
+
try {
|
|
81287
|
+
const pin = await readPin(req.params.appId);
|
|
81288
|
+
return { ok: true, pin, drift: pin === null ? false : driftOf(pin) };
|
|
81289
|
+
} catch (e) {
|
|
81290
|
+
return sendError2(reply, e);
|
|
81291
|
+
}
|
|
81292
|
+
});
|
|
81293
|
+
app.put(
|
|
81294
|
+
"/api/kb-pin/:appId",
|
|
81295
|
+
async (req, reply) => {
|
|
81296
|
+
try {
|
|
81297
|
+
const { appId } = req.params;
|
|
81298
|
+
assertAppId(appId);
|
|
81299
|
+
const body = req.body ?? {};
|
|
81300
|
+
if (typeof body.projectId !== "string") {
|
|
81301
|
+
return reply.status(400).send({ ok: false, error: "projectId must be a string", code: "invalid-body" });
|
|
81302
|
+
}
|
|
81303
|
+
if (typeof body.generationId !== "string") {
|
|
81304
|
+
return reply.status(400).send({ ok: false, error: "generationId must be a string", code: "invalid-body" });
|
|
81305
|
+
}
|
|
81306
|
+
const projectId = body.projectId;
|
|
81307
|
+
const generationId = body.generationId;
|
|
81308
|
+
return await withLifecycleLock("app", appId, async () => {
|
|
81309
|
+
if (!appInstalled(appId)) {
|
|
81310
|
+
return reply.status(404).send({ ok: false, error: `unknown workflow: ${appId}`, code: "unknown-app" });
|
|
81311
|
+
}
|
|
81312
|
+
getProject(projectId);
|
|
81313
|
+
return withLifecycleLock("project", projectId, async () => {
|
|
81314
|
+
const project = getProject(projectId);
|
|
81315
|
+
if (!project) {
|
|
81316
|
+
return reply.status(404).send({ ok: false, error: `unknown project: ${projectId}`, code: "unknown-project" });
|
|
81317
|
+
}
|
|
81318
|
+
if (!sameAppLineage(appId, project.app)) {
|
|
81319
|
+
return reply.status(404).send({
|
|
81320
|
+
ok: false,
|
|
81321
|
+
error: `project ${projectId} does not belong to workflow ${appId}`,
|
|
81322
|
+
code: "project-app-mismatch"
|
|
81323
|
+
});
|
|
81324
|
+
}
|
|
81325
|
+
const pin = await writePin(appId, { projectId, generationId, pages: body.pages });
|
|
81326
|
+
deps.broadcast({ type: "kb-pin-changed", id: appId });
|
|
81327
|
+
return { ok: true, pin, drift: driftOf(pin) };
|
|
81328
|
+
});
|
|
81329
|
+
});
|
|
81330
|
+
} catch (e) {
|
|
81331
|
+
return sendError2(reply, e);
|
|
81332
|
+
}
|
|
81333
|
+
}
|
|
81334
|
+
);
|
|
81335
|
+
}
|
|
81336
|
+
function sendError2(reply, e) {
|
|
81337
|
+
if (e instanceof KbPinError) return reply.status(400).send({ ok: false, error: e.message, code: e.code });
|
|
81338
|
+
if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message, code: "invalid-project" });
|
|
81339
|
+
if (e instanceof KnowledgeError) {
|
|
81340
|
+
return reply.status(knowledgeErrorStatus(e)).send({ ok: false, error: e.message, code: e.code ?? "invalid-generation" });
|
|
81341
|
+
}
|
|
81342
|
+
throw e;
|
|
80729
81343
|
}
|
|
80730
81344
|
|
|
80731
81345
|
// route-gate.ts
|
|
@@ -80780,9 +81394,9 @@ function isGatedAwareRoute(url, method) {
|
|
|
80780
81394
|
|
|
80781
81395
|
// autostart.mjs
|
|
80782
81396
|
var import_node_child_process8 = require("node:child_process");
|
|
80783
|
-
var
|
|
80784
|
-
var
|
|
80785
|
-
var
|
|
81397
|
+
var import_node_fs59 = require("node:fs");
|
|
81398
|
+
var import_node_os27 = require("node:os");
|
|
81399
|
+
var import_node_path52 = require("node:path");
|
|
80786
81400
|
|
|
80787
81401
|
// teardown.mjs
|
|
80788
81402
|
var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
@@ -80894,8 +81508,8 @@ function removeLegacyRunKey() {
|
|
|
80894
81508
|
}
|
|
80895
81509
|
function logLine(msg) {
|
|
80896
81510
|
try {
|
|
80897
|
-
(0,
|
|
80898
|
-
(0,
|
|
81511
|
+
(0, import_node_fs59.mkdirSync)(logDir(), { recursive: true });
|
|
81512
|
+
(0, import_node_fs59.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
80899
81513
|
`);
|
|
80900
81514
|
} catch {
|
|
80901
81515
|
}
|
|
@@ -80903,8 +81517,8 @@ function logLine(msg) {
|
|
|
80903
81517
|
function registerAutostart(exePath) {
|
|
80904
81518
|
if (!isWin) return;
|
|
80905
81519
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
80906
|
-
const tmp = (0,
|
|
80907
|
-
(0,
|
|
81520
|
+
const tmp = (0, import_node_path52.join)((0, import_node_os27.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
81521
|
+
(0, import_node_fs59.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
80908
81522
|
try {
|
|
80909
81523
|
(0, import_node_child_process8.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
80910
81524
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -80915,7 +81529,7 @@ function registerAutostart(exePath) {
|
|
|
80915
81529
|
throw err2;
|
|
80916
81530
|
} finally {
|
|
80917
81531
|
try {
|
|
80918
|
-
(0,
|
|
81532
|
+
(0, import_node_fs59.rmSync)(tmp, { force: true });
|
|
80919
81533
|
} catch {
|
|
80920
81534
|
}
|
|
80921
81535
|
}
|
|
@@ -80950,26 +81564,26 @@ function unregisterAutostart() {
|
|
|
80950
81564
|
// updater.ts
|
|
80951
81565
|
var import_node_child_process9 = require("node:child_process");
|
|
80952
81566
|
var import_node_crypto31 = require("node:crypto");
|
|
80953
|
-
var
|
|
81567
|
+
var import_node_fs61 = require("node:fs");
|
|
80954
81568
|
var import_node_stream3 = require("node:stream");
|
|
80955
81569
|
var import_promises5 = require("node:stream/promises");
|
|
80956
|
-
var
|
|
81570
|
+
var import_node_path54 = require("node:path");
|
|
80957
81571
|
|
|
80958
81572
|
// post-update-marker.mjs
|
|
80959
|
-
var
|
|
80960
|
-
var
|
|
80961
|
-
var
|
|
81573
|
+
var import_node_fs60 = require("node:fs");
|
|
81574
|
+
var import_node_os28 = require("node:os");
|
|
81575
|
+
var import_node_path53 = require("node:path");
|
|
80962
81576
|
var FRESH_MS = 12e4;
|
|
80963
81577
|
function markerPath() {
|
|
80964
81578
|
const override = (process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim();
|
|
80965
81579
|
if (override) return override;
|
|
80966
|
-
const root5 = process.env.FLOLESS_HOME ?? (0,
|
|
80967
|
-
return (0,
|
|
81580
|
+
const root5 = process.env.FLOLESS_HOME ?? (0, import_node_path53.join)((0, import_node_os28.homedir)(), ".floless");
|
|
81581
|
+
return (0, import_node_path53.join)(root5, ".post-update");
|
|
80968
81582
|
}
|
|
80969
81583
|
function legacyMarkerPath() {
|
|
80970
81584
|
if ((process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim()) return null;
|
|
80971
81585
|
try {
|
|
80972
|
-
return (0,
|
|
81586
|
+
return (0, import_node_path53.join)((0, import_node_path53.dirname)((0, import_node_path53.dirname)(process.execPath)), ".floless-post-update");
|
|
80973
81587
|
} catch {
|
|
80974
81588
|
return null;
|
|
80975
81589
|
}
|
|
@@ -80979,7 +81593,7 @@ function writePostUpdateMarker() {
|
|
|
80979
81593
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
80980
81594
|
if (!p) continue;
|
|
80981
81595
|
try {
|
|
80982
|
-
(0,
|
|
81596
|
+
(0, import_node_fs60.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
|
|
80983
81597
|
wrote = true;
|
|
80984
81598
|
} catch {
|
|
80985
81599
|
}
|
|
@@ -80991,9 +81605,9 @@ function consumePostUpdateMarker() {
|
|
|
80991
81605
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
80992
81606
|
if (!p) continue;
|
|
80993
81607
|
try {
|
|
80994
|
-
if (!(0,
|
|
80995
|
-
const ageMs = Date.now() - (0,
|
|
80996
|
-
(0,
|
|
81608
|
+
if (!(0, import_node_fs60.existsSync)(p)) continue;
|
|
81609
|
+
const ageMs = Date.now() - (0, import_node_fs60.statSync)(p).mtimeMs;
|
|
81610
|
+
(0, import_node_fs60.rmSync)(p, { force: true });
|
|
80997
81611
|
if (ageMs < FRESH_MS) fresh = true;
|
|
80998
81612
|
} catch {
|
|
80999
81613
|
}
|
|
@@ -81010,13 +81624,13 @@ function currentVersion() {
|
|
|
81010
81624
|
return appVersion();
|
|
81011
81625
|
}
|
|
81012
81626
|
function installRoot() {
|
|
81013
|
-
return (0,
|
|
81627
|
+
return (0, import_node_path54.dirname)((0, import_node_path54.dirname)(process.execPath));
|
|
81014
81628
|
}
|
|
81015
81629
|
function updateExePath() {
|
|
81016
|
-
return (0,
|
|
81630
|
+
return (0, import_node_path54.join)(installRoot(), "Update.exe");
|
|
81017
81631
|
}
|
|
81018
81632
|
function packagesDir() {
|
|
81019
|
-
return (0,
|
|
81633
|
+
return (0, import_node_path54.join)(installRoot(), "packages");
|
|
81020
81634
|
}
|
|
81021
81635
|
function feedUrl() {
|
|
81022
81636
|
const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
|
|
@@ -81107,22 +81721,22 @@ async function checkForUpdate() {
|
|
|
81107
81721
|
}
|
|
81108
81722
|
async function sha1OfFile(path) {
|
|
81109
81723
|
const hash2 = (0, import_node_crypto31.createHash)("sha1");
|
|
81110
|
-
await (0, import_promises5.pipeline)((0,
|
|
81724
|
+
await (0, import_promises5.pipeline)((0, import_node_fs61.createReadStream)(path), hash2);
|
|
81111
81725
|
return hash2.digest("hex").toUpperCase();
|
|
81112
81726
|
}
|
|
81113
81727
|
async function downloadPackage(asset) {
|
|
81114
81728
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
81115
81729
|
const want = asset.SHA1.toUpperCase();
|
|
81116
81730
|
const dir = packagesDir();
|
|
81117
|
-
(0,
|
|
81118
|
-
const dest = (0,
|
|
81119
|
-
if ((0,
|
|
81731
|
+
(0, import_node_fs61.mkdirSync)(dir, { recursive: true });
|
|
81732
|
+
const dest = (0, import_node_path54.join)(dir, asset.FileName);
|
|
81733
|
+
if ((0, import_node_fs61.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
81120
81734
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
81121
81735
|
redirect: "follow",
|
|
81122
81736
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
81123
81737
|
});
|
|
81124
81738
|
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,
|
|
81739
|
+
await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs61.createWriteStream)(dest));
|
|
81126
81740
|
const got = await sha1OfFile(dest);
|
|
81127
81741
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
81128
81742
|
return dest;
|
|
@@ -81131,7 +81745,7 @@ async function applyUpdate(check, opts) {
|
|
|
81131
81745
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
81132
81746
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
81133
81747
|
const exe2 = updateExePath();
|
|
81134
|
-
if (!(0,
|
|
81748
|
+
if (!(0, import_node_fs61.existsSync)(exe2)) {
|
|
81135
81749
|
return { applied: false, message: `Update.exe not found at ${exe2} \u2014 is this a Velopack install?` };
|
|
81136
81750
|
}
|
|
81137
81751
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -81371,12 +81985,12 @@ function isTraceCorrupt(events) {
|
|
|
81371
81985
|
|
|
81372
81986
|
// launch.mjs
|
|
81373
81987
|
var import_node_child_process10 = require("node:child_process");
|
|
81374
|
-
var
|
|
81988
|
+
var import_node_path55 = require("node:path");
|
|
81375
81989
|
var import_node_url3 = require("node:url");
|
|
81376
|
-
var
|
|
81990
|
+
var import_node_fs62 = require("node:fs");
|
|
81377
81991
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
81378
81992
|
var import_node_readline = require("node:readline");
|
|
81379
|
-
var __dirname2 = (0,
|
|
81993
|
+
var __dirname2 = (0, import_node_path55.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
81380
81994
|
var PORT = Number(process.env.PORT ?? 4317);
|
|
81381
81995
|
var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
|
|
81382
81996
|
var BROWSER_URL = `http://floless.localhost:${PORT}`;
|
|
@@ -81454,8 +82068,8 @@ async function waitHealthy(timeoutMs = 3e4) {
|
|
|
81454
82068
|
function resolveServerStart() {
|
|
81455
82069
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
81456
82070
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
81457
|
-
const bundle = (0,
|
|
81458
|
-
if ((0,
|
|
82071
|
+
const bundle = (0, import_node_path55.join)(__dirname2, "dist", "floless-server.cjs");
|
|
82072
|
+
if ((0, import_node_fs62.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
81459
82073
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
81460
82074
|
}
|
|
81461
82075
|
function startServerDetached() {
|
|
@@ -81608,8 +82222,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
|
|
|
81608
82222
|
}
|
|
81609
82223
|
function killSupervisor({ tree = true } = {}) {
|
|
81610
82224
|
if (!isWin2) return;
|
|
81611
|
-
const isNpmChannel = /^node(\.exe)?$/i.test((0,
|
|
81612
|
-
const scriptMatch = isNpmChannel ? (0,
|
|
82225
|
+
const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path55.basename)(process.execPath));
|
|
82226
|
+
const scriptMatch = isNpmChannel ? (0, import_node_path55.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
|
|
81613
82227
|
const realExe = resolveRealInstallExe(process.execPath);
|
|
81614
82228
|
const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
|
|
81615
82229
|
const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
|
|
@@ -81780,7 +82394,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null, selfChannel = n
|
|
|
81780
82394
|
}
|
|
81781
82395
|
await action(parseTeardownFlags(flagArgv));
|
|
81782
82396
|
}
|
|
81783
|
-
var entry = (0,
|
|
82397
|
+
var entry = (0, import_node_path55.basename)(process.argv[1] ?? "").toLowerCase();
|
|
81784
82398
|
if (entry === "launch.mjs") {
|
|
81785
82399
|
runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
|
|
81786
82400
|
log(`error: ${e?.message ?? e}`);
|
|
@@ -81791,7 +82405,7 @@ if (entry === "launch.mjs") {
|
|
|
81791
82405
|
// aware-update.ts
|
|
81792
82406
|
var import_promises6 = require("node:fs/promises");
|
|
81793
82407
|
var import_node_crypto32 = require("node:crypto");
|
|
81794
|
-
var
|
|
82408
|
+
var import_node_path56 = require("node:path");
|
|
81795
82409
|
var REGISTRY_LATEST = "https://registry.npmjs.org/@aware-aeco/cli/latest";
|
|
81796
82410
|
var FEED_TIMEOUT_MS2 = 15e3;
|
|
81797
82411
|
var VERSION_TTL_MS = 5e3;
|
|
@@ -81807,8 +82421,8 @@ var nodeBridgeIo = { readdir: import_promises6.readdir, lstat: import_promises6.
|
|
|
81807
82421
|
var nodeBridgeVersionIo = { ...nodeBridgeIo, readFile: import_promises6.readFile };
|
|
81808
82422
|
var BRIDGE_VERSION_MAX_BYTES = 128;
|
|
81809
82423
|
function pathInside(root5, candidate) {
|
|
81810
|
-
const rel = (0,
|
|
81811
|
-
return rel === "" || !rel.startsWith("..") && !(0,
|
|
82424
|
+
const rel = (0, import_node_path56.relative)(root5, candidate);
|
|
82425
|
+
return rel === "" || !rel.startsWith("..") && !(0, import_node_path56.isAbsolute)(rel);
|
|
81812
82426
|
}
|
|
81813
82427
|
async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
|
|
81814
82428
|
let names;
|
|
@@ -81832,7 +82446,7 @@ async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
|
|
|
81832
82446
|
for (const host of AWARE_BRIDGE_HOSTS) {
|
|
81833
82447
|
const fileName = `aware-${host}.exe`;
|
|
81834
82448
|
if (!names.includes(fileName)) continue;
|
|
81835
|
-
const candidate = (0,
|
|
82449
|
+
const candidate = (0, import_node_path56.join)(bridgeDirectory, fileName);
|
|
81836
82450
|
try {
|
|
81837
82451
|
const stat4 = await io.lstat(candidate);
|
|
81838
82452
|
const canonical = await io.realpath(candidate);
|
|
@@ -81876,8 +82490,8 @@ async function persistentBridgeVersion(bridgeDirectory, host, io = nodeBridgeVer
|
|
|
81876
82490
|
throw error;
|
|
81877
82491
|
}
|
|
81878
82492
|
};
|
|
81879
|
-
const executable = (0,
|
|
81880
|
-
const marker = (0,
|
|
82493
|
+
const executable = (0, import_node_path56.join)(bridgeDirectory, `aware-${host}.exe`);
|
|
82494
|
+
const marker = (0, import_node_path56.join)(bridgeDirectory, `aware-${host}.version`);
|
|
81881
82495
|
try {
|
|
81882
82496
|
if (!await validateFile(executable) || !await validateFile(marker)) return null;
|
|
81883
82497
|
const bytes = await io.readFile(marker, "utf8");
|
|
@@ -81911,7 +82525,7 @@ function validateMarker(value) {
|
|
|
81911
82525
|
if (v.host != null && !isBridgeHost(v.host)) return null;
|
|
81912
82526
|
if (v.child != null) {
|
|
81913
82527
|
const child = v.child;
|
|
81914
|
-
if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0,
|
|
82528
|
+
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
82529
|
}
|
|
81916
82530
|
return {
|
|
81917
82531
|
// Normalised on read: a decoded schema-1 marker is handed to callers as a schema-2 value with
|
|
@@ -81931,7 +82545,7 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
|
81931
82545
|
const io = options.io ?? nodeMarkerIo;
|
|
81932
82546
|
const maxBytes = Math.min(options.maxBytes ?? MARKER_MAX_BYTES, MARKER_MAX_BYTES);
|
|
81933
82547
|
const randomId = options.randomId ?? import_node_crypto32.randomUUID;
|
|
81934
|
-
const directory = (0,
|
|
82548
|
+
const directory = (0, import_node_path56.dirname)(markerPath2);
|
|
81935
82549
|
return {
|
|
81936
82550
|
async read() {
|
|
81937
82551
|
let bytes;
|
|
@@ -81955,7 +82569,7 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
|
81955
82569
|
const bytes = JSON.stringify(valid);
|
|
81956
82570
|
if (Buffer.byteLength(bytes) > maxBytes) throw new Error("Refused to write an oversized AWARE maintenance marker.");
|
|
81957
82571
|
await io.mkdir(directory, { recursive: true, mode: 448 });
|
|
81958
|
-
const temp = (0,
|
|
82572
|
+
const temp = (0, import_node_path56.join)(directory, `.${(0, import_node_path56.basename)(markerPath2)}.${randomId()}.tmp`);
|
|
81959
82573
|
try {
|
|
81960
82574
|
await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
81961
82575
|
await io.rename(temp, markerPath2);
|
|
@@ -81989,7 +82603,7 @@ function validatePending(value) {
|
|
|
81989
82603
|
function createBridgePendingStore(pendingPath, options = {}) {
|
|
81990
82604
|
const io = options.io ?? nodeMarkerIo;
|
|
81991
82605
|
const randomId = options.randomId ?? import_node_crypto32.randomUUID;
|
|
81992
|
-
const directory = (0,
|
|
82606
|
+
const directory = (0, import_node_path56.dirname)(pendingPath);
|
|
81993
82607
|
return {
|
|
81994
82608
|
async read() {
|
|
81995
82609
|
let bytes;
|
|
@@ -82013,7 +82627,7 @@ function createBridgePendingStore(pendingPath, options = {}) {
|
|
|
82013
82627
|
throw new Error("Refused to write an oversized AWARE bridge-repair intent.");
|
|
82014
82628
|
}
|
|
82015
82629
|
await io.mkdir(directory, { recursive: true, mode: 448 });
|
|
82016
|
-
const temp = (0,
|
|
82630
|
+
const temp = (0, import_node_path56.join)(directory, `.${(0, import_node_path56.basename)(pendingPath)}.${randomId()}.tmp`);
|
|
82017
82631
|
try {
|
|
82018
82632
|
await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
82019
82633
|
await io.rename(temp, pendingPath);
|
|
@@ -82133,7 +82747,7 @@ async function checkAwareUpdate(bridgeDirectory) {
|
|
|
82133
82747
|
// aware-install-process.ts
|
|
82134
82748
|
var import_node_child_process11 = require("node:child_process");
|
|
82135
82749
|
var import_promises7 = require("node:fs/promises");
|
|
82136
|
-
var
|
|
82750
|
+
var import_node_path57 = require("node:path");
|
|
82137
82751
|
var import_node_util4 = require("node:util");
|
|
82138
82752
|
var execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process11.execFile);
|
|
82139
82753
|
var DEFAULT_INSTALL_TIMEOUT_MS = 10 * 6e4;
|
|
@@ -82161,7 +82775,7 @@ function killTree2(child) {
|
|
|
82161
82775
|
}
|
|
82162
82776
|
}
|
|
82163
82777
|
function safeExecutableIdentity(value) {
|
|
82164
|
-
const name = (0,
|
|
82778
|
+
const name = (0, import_node_path57.basename)(value.trim()).replace(/[^A-Za-z0-9._-]/g, "").slice(0, 128);
|
|
82165
82779
|
return name || "unknown";
|
|
82166
82780
|
}
|
|
82167
82781
|
async function maintenanceChildIdentity(pid) {
|
|
@@ -83113,10 +83727,10 @@ function registerDebugNodeRoute(app, deps) {
|
|
|
83113
83727
|
// terminal-run.ts
|
|
83114
83728
|
var import_node_child_process13 = require("node:child_process");
|
|
83115
83729
|
var import_node_child_process14 = require("node:child_process");
|
|
83116
|
-
var
|
|
83730
|
+
var import_node_fs65 = require("node:fs");
|
|
83117
83731
|
var import_node_crypto34 = require("node:crypto");
|
|
83118
|
-
var
|
|
83119
|
-
var
|
|
83732
|
+
var import_node_os31 = require("node:os");
|
|
83733
|
+
var import_node_path60 = require("node:path");
|
|
83120
83734
|
|
|
83121
83735
|
// run-contract.ts
|
|
83122
83736
|
var COMPLETION_SCHEMA = {
|
|
@@ -83171,11 +83785,11 @@ function terminalEvent(stdout) {
|
|
|
83171
83785
|
var import_node_child_process12 = require("node:child_process");
|
|
83172
83786
|
var import_node_util5 = require("node:util");
|
|
83173
83787
|
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,
|
|
83788
|
+
var import_node_fs63 = require("node:fs");
|
|
83789
|
+
var import_node_os29 = require("node:os");
|
|
83790
|
+
var import_node_path58 = require("node:path");
|
|
83791
|
+
var ROOT4 = () => process.env.FLOLESS_HOME ?? (0, import_node_path58.join)((0, import_node_os29.homedir)(), ".floless");
|
|
83792
|
+
var LEASE_DIR = () => (0, import_node_path58.join)(ROOT4(), "run-leases");
|
|
83179
83793
|
var WIN = process.platform === "win32";
|
|
83180
83794
|
var LeaseHeldError = class extends Error {
|
|
83181
83795
|
constructor(holder) {
|
|
@@ -83186,15 +83800,15 @@ var LeaseHeldError = class extends Error {
|
|
|
83186
83800
|
};
|
|
83187
83801
|
var serverStartedAt = Math.round(Date.now() - process.uptime() * 1e3);
|
|
83188
83802
|
function canonicalDir(p) {
|
|
83189
|
-
const real =
|
|
83190
|
-
if (!(0,
|
|
83191
|
-
return real.length > 1 && real.endsWith(
|
|
83803
|
+
const real = import_node_fs63.realpathSync.native((0, import_node_path58.resolve)(p));
|
|
83804
|
+
if (!(0, import_node_fs63.statSync)(real).isDirectory()) throw new Error(`not a directory: ${p}`);
|
|
83805
|
+
return real.length > 1 && real.endsWith(import_node_path58.sep) ? real.slice(0, -1) : real;
|
|
83192
83806
|
}
|
|
83193
83807
|
function isInside(parent, child) {
|
|
83194
83808
|
const norm = (s) => WIN ? s.toLowerCase() : s;
|
|
83195
83809
|
const p = norm(parent);
|
|
83196
83810
|
const c = norm(child);
|
|
83197
|
-
return c === p || c.startsWith(p.endsWith(
|
|
83811
|
+
return c === p || c.startsWith(p.endsWith(import_node_path58.sep) ? p : p + import_node_path58.sep);
|
|
83198
83812
|
}
|
|
83199
83813
|
function leaseKey(canonicalCwd) {
|
|
83200
83814
|
const k = WIN ? canonicalCwd.toLowerCase() : canonicalCwd;
|
|
@@ -83202,7 +83816,7 @@ function leaseKey(canonicalCwd) {
|
|
|
83202
83816
|
}
|
|
83203
83817
|
function readLeaseFile(file) {
|
|
83204
83818
|
try {
|
|
83205
|
-
const parsed = JSON.parse((0,
|
|
83819
|
+
const parsed = JSON.parse((0, import_node_fs63.readFileSync)(file, "utf8"));
|
|
83206
83820
|
const l = parsed;
|
|
83207
83821
|
if (typeof l?.leaseId !== "string" || typeof l.token !== "string" || typeof l.cwd !== "string") return null;
|
|
83208
83822
|
if (typeof l.requestId !== "string" || typeof l.generation !== "number") return null;
|
|
@@ -83213,8 +83827,8 @@ function readLeaseFile(file) {
|
|
|
83213
83827
|
}
|
|
83214
83828
|
function claimLease(input) {
|
|
83215
83829
|
const cwd = canonicalDir(input.cwd);
|
|
83216
|
-
(0,
|
|
83217
|
-
const file = (0,
|
|
83830
|
+
(0, import_node_fs63.mkdirSync)(LEASE_DIR(), { recursive: true, mode: 448 });
|
|
83831
|
+
const file = (0, import_node_path58.join)(LEASE_DIR(), leaseKey(cwd));
|
|
83218
83832
|
const lease = {
|
|
83219
83833
|
leaseId: (0, import_node_crypto33.randomUUID)(),
|
|
83220
83834
|
// 32 bytes of CSPRNG. This is an authorization token, not a correlation id — it is the only
|
|
@@ -83236,18 +83850,18 @@ function claimLease(input) {
|
|
|
83236
83850
|
resolvedAt: null
|
|
83237
83851
|
};
|
|
83238
83852
|
try {
|
|
83239
|
-
(0,
|
|
83853
|
+
(0, import_node_fs63.writeFileSync)(file, JSON.stringify(lease, null, 2), { flag: "wx", mode: 384 });
|
|
83240
83854
|
return lease;
|
|
83241
83855
|
} catch (err2) {
|
|
83242
83856
|
if (err2?.code !== "EEXIST") throw err2;
|
|
83243
83857
|
const holder = readLeaseFile(file);
|
|
83244
83858
|
if (holder) throw new LeaseHeldError(holder);
|
|
83245
83859
|
try {
|
|
83246
|
-
(0,
|
|
83860
|
+
(0, import_node_fs63.rmSync)(file);
|
|
83247
83861
|
} catch {
|
|
83248
83862
|
}
|
|
83249
83863
|
try {
|
|
83250
|
-
(0,
|
|
83864
|
+
(0, import_node_fs63.writeFileSync)(file, JSON.stringify(lease, null, 2), { flag: "wx", mode: 384 });
|
|
83251
83865
|
return lease;
|
|
83252
83866
|
} catch (retryErr) {
|
|
83253
83867
|
if (retryErr?.code !== "EEXIST") throw retryErr;
|
|
@@ -83259,8 +83873,8 @@ function claimLease(input) {
|
|
|
83259
83873
|
}
|
|
83260
83874
|
function listLeases() {
|
|
83261
83875
|
const dir = LEASE_DIR();
|
|
83262
|
-
if (!(0,
|
|
83263
|
-
return (0,
|
|
83876
|
+
if (!(0, import_node_fs63.existsSync)(dir)) return [];
|
|
83877
|
+
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
83878
|
}
|
|
83265
83879
|
function getLease(leaseId) {
|
|
83266
83880
|
return listLeases().find((l) => l.leaseId === leaseId) ?? null;
|
|
@@ -83276,27 +83890,27 @@ function leaseForToken(token2) {
|
|
|
83276
83890
|
}
|
|
83277
83891
|
function patchLease(leaseId, generation, patch2) {
|
|
83278
83892
|
const dir = LEASE_DIR();
|
|
83279
|
-
if (!(0,
|
|
83280
|
-
for (const f of (0,
|
|
83281
|
-
const file = (0,
|
|
83893
|
+
if (!(0, import_node_fs63.existsSync)(dir)) return null;
|
|
83894
|
+
for (const f of (0, import_node_fs63.readdirSync)(dir).filter((n) => n.endsWith(".json"))) {
|
|
83895
|
+
const file = (0, import_node_path58.join)(dir, f);
|
|
83282
83896
|
const cur = readLeaseFile(file);
|
|
83283
83897
|
if (!cur || cur.leaseId !== leaseId) continue;
|
|
83284
83898
|
if (cur.generation !== generation) return null;
|
|
83285
83899
|
const next = { ...cur, ...patch2, leaseId: cur.leaseId, token: cur.token, generation: cur.generation };
|
|
83286
|
-
(0,
|
|
83900
|
+
(0, import_node_fs63.writeFileSync)(file, JSON.stringify(next, null, 2), { mode: 384 });
|
|
83287
83901
|
return next;
|
|
83288
83902
|
}
|
|
83289
83903
|
return null;
|
|
83290
83904
|
}
|
|
83291
83905
|
function releaseLease(leaseId) {
|
|
83292
83906
|
const dir = LEASE_DIR();
|
|
83293
|
-
if (!(0,
|
|
83294
|
-
for (const f of (0,
|
|
83295
|
-
const file = (0,
|
|
83907
|
+
if (!(0, import_node_fs63.existsSync)(dir)) return false;
|
|
83908
|
+
for (const f of (0, import_node_fs63.readdirSync)(dir).filter((n) => n.endsWith(".json"))) {
|
|
83909
|
+
const file = (0, import_node_path58.join)(dir, f);
|
|
83296
83910
|
const cur = readLeaseFile(file);
|
|
83297
83911
|
if (cur?.leaseId !== leaseId) continue;
|
|
83298
83912
|
try {
|
|
83299
|
-
(0,
|
|
83913
|
+
(0, import_node_fs63.rmSync)(file);
|
|
83300
83914
|
} catch {
|
|
83301
83915
|
}
|
|
83302
83916
|
return true;
|
|
@@ -83368,9 +83982,9 @@ function sameProcess(observed, pid, procStartedAt) {
|
|
|
83368
83982
|
}
|
|
83369
83983
|
|
|
83370
83984
|
// terminal-runtime.ts
|
|
83371
|
-
var
|
|
83372
|
-
var
|
|
83373
|
-
var
|
|
83985
|
+
var import_node_fs64 = require("node:fs");
|
|
83986
|
+
var import_node_os30 = require("node:os");
|
|
83987
|
+
var import_node_path59 = require("node:path");
|
|
83374
83988
|
var WIN2 = process.platform === "win32";
|
|
83375
83989
|
var exe = (name) => WIN2 ? `${name}.exe` : name;
|
|
83376
83990
|
var RUNTIMES = [
|
|
@@ -83381,7 +83995,7 @@ var RUNTIMES = [
|
|
|
83381
83995
|
command: "claude",
|
|
83382
83996
|
// Measured: the native installer puts it in ~/.local/bin, NOT under npm root -g.
|
|
83383
83997
|
// npm package, when that is how it was installed: @anthropic-ai/claude-code.
|
|
83384
|
-
candidates: () => [(0,
|
|
83998
|
+
candidates: () => [(0, import_node_path59.join)((0, import_node_os30.homedir)(), ".local", "bin", exe("claude")), ...npmShims("claude")]
|
|
83385
83999
|
},
|
|
83386
84000
|
{
|
|
83387
84001
|
id: "codex",
|
|
@@ -83390,7 +84004,7 @@ var RUNTIMES = [
|
|
|
83390
84004
|
command: "codex",
|
|
83391
84005
|
// Measured: %LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe.
|
|
83392
84006
|
candidates: () => [
|
|
83393
|
-
WIN2 && process.env.LOCALAPPDATA ? (0,
|
|
84007
|
+
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
84008
|
...npmShims("codex")
|
|
83395
84009
|
// npm package, when installed that way: @openai/codex
|
|
83396
84010
|
]
|
|
@@ -83403,23 +84017,23 @@ var RUNTIMES = [
|
|
|
83403
84017
|
// NOT MEASURED — no OpenCode on the machine this was written against, so these are the
|
|
83404
84018
|
// documented locations and unproven. The E2E that first enables OpenCode's arm has to confirm
|
|
83405
84019
|
// them on a machine that has it; until then a false `not-found` here is the expected failure.
|
|
83406
|
-
candidates: () => [(0,
|
|
84020
|
+
candidates: () => [(0, import_node_path59.join)((0, import_node_os30.homedir)(), ".opencode", "bin", exe("opencode")), ...npmShims("opencode")]
|
|
83407
84021
|
}
|
|
83408
84022
|
];
|
|
83409
84023
|
function npmShims(bin) {
|
|
83410
|
-
if (WIN2) return process.env.APPDATA ? [(0,
|
|
84024
|
+
if (WIN2) return process.env.APPDATA ? [(0, import_node_path59.join)(process.env.APPDATA, "npm", `${bin}.cmd`)] : [];
|
|
83411
84025
|
return [
|
|
83412
|
-
(0,
|
|
83413
|
-
(0,
|
|
83414
|
-
(0,
|
|
84026
|
+
(0, import_node_path59.join)((0, import_node_os30.homedir)(), ".npm-global", "bin", bin),
|
|
84027
|
+
(0, import_node_path59.join)("/usr", "local", "bin", bin),
|
|
84028
|
+
(0, import_node_path59.join)("/opt", "homebrew", "bin", bin)
|
|
83415
84029
|
// Apple-silicon Homebrew
|
|
83416
84030
|
];
|
|
83417
84031
|
}
|
|
83418
84032
|
function usableBinary(p) {
|
|
83419
84033
|
try {
|
|
83420
|
-
const st = (0,
|
|
84034
|
+
const st = (0, import_node_fs64.statSync)(p);
|
|
83421
84035
|
if (!st.isFile() || st.size === 0) return false;
|
|
83422
|
-
if (!WIN2) (0,
|
|
84036
|
+
if (!WIN2) (0, import_node_fs64.accessSync)(p, import_node_fs64.constants.X_OK);
|
|
83423
84037
|
return true;
|
|
83424
84038
|
} catch {
|
|
83425
84039
|
return false;
|
|
@@ -83441,17 +84055,17 @@ function detectRuntimes(opts) {
|
|
|
83441
84055
|
function refreshRuntimes() {
|
|
83442
84056
|
_cache2 = null;
|
|
83443
84057
|
}
|
|
83444
|
-
var settingsPath = () => (0,
|
|
84058
|
+
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
84059
|
function readSettings() {
|
|
83446
84060
|
try {
|
|
83447
|
-
const raw = JSON.parse((0,
|
|
84061
|
+
const raw = JSON.parse((0, import_node_fs64.readFileSync)(settingsPath(), "utf8"));
|
|
83448
84062
|
return raw && typeof raw === "object" ? raw : {};
|
|
83449
84063
|
} catch {
|
|
83450
84064
|
return {};
|
|
83451
84065
|
}
|
|
83452
84066
|
}
|
|
83453
84067
|
function writeSettings(patch2) {
|
|
83454
|
-
(0,
|
|
84068
|
+
(0, import_node_fs64.mkdirSync)((0, import_node_path59.dirname)(settingsPath()), { recursive: true });
|
|
83455
84069
|
writeJsonAtomic(settingsPath(), { ...readSettings(), ...patch2 });
|
|
83456
84070
|
}
|
|
83457
84071
|
function readProviderSetting() {
|
|
@@ -83483,12 +84097,12 @@ function nominateFolder(projectKey, folder) {
|
|
|
83483
84097
|
throw new FolderError(`That folder doesn\u2019t exist, or isn\u2019t a folder: ${raw}`);
|
|
83484
84098
|
}
|
|
83485
84099
|
try {
|
|
83486
|
-
(0,
|
|
84100
|
+
(0, import_node_fs64.accessSync)(canonical, import_node_fs64.constants.W_OK);
|
|
83487
84101
|
} catch {
|
|
83488
84102
|
throw new FolderError(`floless can\u2019t write in that folder: ${canonical}`);
|
|
83489
84103
|
}
|
|
83490
|
-
const own3 = process.env.FLOLESS_HOME ?? (0,
|
|
83491
|
-
if ((0,
|
|
84104
|
+
const own3 = process.env.FLOLESS_HOME ?? (0, import_node_path59.join)((0, import_node_os30.homedir)(), ".floless");
|
|
84105
|
+
if ((0, import_node_fs64.existsSync)(own3) && isInside(canonicalDir(own3), canonical)) {
|
|
83492
84106
|
throw new FolderError("That\u2019s floless\u2019s own data folder. Pick a folder where your work lives.");
|
|
83493
84107
|
}
|
|
83494
84108
|
if (projectKey) {
|
|
@@ -83519,7 +84133,7 @@ function buildSpawnPlan(input) {
|
|
|
83519
84133
|
}
|
|
83520
84134
|
let file;
|
|
83521
84135
|
try {
|
|
83522
|
-
file =
|
|
84136
|
+
file = import_node_fs64.realpathSync.native(found.path);
|
|
83523
84137
|
if (!usableBinary(file)) throw new Error("not usable");
|
|
83524
84138
|
} catch {
|
|
83525
84139
|
return { ok: false, reason: "Claude Code moved or was uninstalled since floless last looked. Try again." };
|
|
@@ -83657,17 +84271,17 @@ async function finish(deps, lease, patch2) {
|
|
|
83657
84271
|
if (contained) releaseLease(lease.leaseId);
|
|
83658
84272
|
else console.error(`[terminal-run] could not prove the tree for lease ${lease.leaseId} is gone \u2014 lease held`);
|
|
83659
84273
|
}
|
|
83660
|
-
var mcpDir = () => (0,
|
|
83661
|
-
var mcpPath = (leaseId) => (0,
|
|
84274
|
+
var mcpDir = () => (0, import_node_path60.join)(process.env.FLOLESS_HOME ?? (0, import_node_path60.join)((0, import_node_os31.homedir)(), ".floless"), "run-mcp");
|
|
84275
|
+
var mcpPath = (leaseId) => (0, import_node_path60.join)(mcpDir(), `${leaseId}.json`);
|
|
83662
84276
|
function writeMcpConfig(lease) {
|
|
83663
|
-
(0,
|
|
84277
|
+
(0, import_node_fs65.mkdirSync)(mcpDir(), { recursive: true });
|
|
83664
84278
|
const p = mcpPath(lease.leaseId);
|
|
83665
|
-
(0,
|
|
84279
|
+
(0, import_node_fs65.writeFileSync)(p, JSON.stringify(mcpConfigFor(lease.token, selfOrigin()), null, 2), { mode: 384 });
|
|
83666
84280
|
return p;
|
|
83667
84281
|
}
|
|
83668
84282
|
function cleanupMcpConfig(leaseId) {
|
|
83669
84283
|
try {
|
|
83670
|
-
(0,
|
|
84284
|
+
(0, import_node_fs65.rmSync)(mcpPath(leaseId));
|
|
83671
84285
|
} catch {
|
|
83672
84286
|
}
|
|
83673
84287
|
}
|
|
@@ -83992,9 +84606,9 @@ async function stopAllRuns(deps) {
|
|
|
83992
84606
|
}
|
|
83993
84607
|
|
|
83994
84608
|
// skill-sync.ts
|
|
83995
|
-
var
|
|
83996
|
-
var
|
|
83997
|
-
var
|
|
84609
|
+
var import_node_fs66 = require("node:fs");
|
|
84610
|
+
var import_node_os32 = require("node:os");
|
|
84611
|
+
var import_node_path61 = require("node:path");
|
|
83998
84612
|
var import_node_url4 = require("node:url");
|
|
83999
84613
|
var import_yaml11 = __toESM(require_dist6(), 1);
|
|
84000
84614
|
|
|
@@ -84041,30 +84655,30 @@ function selectShippedSkillNames(names) {
|
|
|
84041
84655
|
}
|
|
84042
84656
|
|
|
84043
84657
|
// skill-sync.ts
|
|
84044
|
-
var __dirname3 = (0,
|
|
84658
|
+
var __dirname3 = (0, import_node_path61.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
|
|
84045
84659
|
function bundledSkillsRoot() {
|
|
84046
84660
|
const candidates = [
|
|
84047
|
-
(0,
|
|
84048
|
-
(0,
|
|
84049
|
-
(0,
|
|
84661
|
+
(0, import_node_path61.join)(__dirname3, "skills"),
|
|
84662
|
+
(0, import_node_path61.join)((0, import_node_path61.dirname)(process.execPath), "skills"),
|
|
84663
|
+
(0, import_node_path61.join)(__dirname3, "..", ".claude", "skills")
|
|
84050
84664
|
];
|
|
84051
|
-
return candidates.find((p) => (0,
|
|
84665
|
+
return candidates.find((p) => (0, import_node_fs66.existsSync)(p)) ?? null;
|
|
84052
84666
|
}
|
|
84053
84667
|
function targetConfigDirs() {
|
|
84054
84668
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
84055
84669
|
if (override) {
|
|
84056
84670
|
return override.split(";").map((d) => d.trim()).filter(Boolean).map((dir) => ({ runtime: "custom", dir }));
|
|
84057
84671
|
}
|
|
84058
|
-
const home = (0,
|
|
84672
|
+
const home = (0, import_node_os32.homedir)();
|
|
84059
84673
|
return [
|
|
84060
|
-
{ runtime: "claude", dir: (0,
|
|
84061
|
-
{ runtime: "codex", dir: (0,
|
|
84062
|
-
{ runtime: "opencode", dir: (0,
|
|
84674
|
+
{ runtime: "claude", dir: (0, import_node_path61.join)(home, ".claude") },
|
|
84675
|
+
{ runtime: "codex", dir: (0, import_node_path61.join)(home, ".codex") },
|
|
84676
|
+
{ runtime: "opencode", dir: (0, import_node_path61.join)(home, ".opencode") }
|
|
84063
84677
|
];
|
|
84064
84678
|
}
|
|
84065
84679
|
function skillVersion(skillMdPath) {
|
|
84066
84680
|
try {
|
|
84067
|
-
const text3 = (0,
|
|
84681
|
+
const text3 = (0, import_node_fs66.readFileSync)(skillMdPath, "utf8");
|
|
84068
84682
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
|
|
84069
84683
|
if (!m || m[1] === void 0) return null;
|
|
84070
84684
|
const fm = (0, import_yaml11.parse)(m[1]);
|
|
@@ -84104,21 +84718,21 @@ function decideAction(installed, bundled) {
|
|
|
84104
84718
|
function bundledSkills(root5) {
|
|
84105
84719
|
let entries2 = [];
|
|
84106
84720
|
try {
|
|
84107
|
-
entries2 = selectShippedSkillNames((0,
|
|
84721
|
+
entries2 = selectShippedSkillNames((0, import_node_fs66.readdirSync)(root5));
|
|
84108
84722
|
} catch {
|
|
84109
84723
|
return [];
|
|
84110
84724
|
}
|
|
84111
84725
|
const out = [];
|
|
84112
84726
|
for (const name of entries2) {
|
|
84113
|
-
const dir = (0,
|
|
84727
|
+
const dir = (0, import_node_path61.join)(root5, name);
|
|
84114
84728
|
let isDir = false;
|
|
84115
84729
|
try {
|
|
84116
|
-
isDir = (0,
|
|
84730
|
+
isDir = (0, import_node_fs66.statSync)(dir).isDirectory();
|
|
84117
84731
|
} catch {
|
|
84118
84732
|
isDir = false;
|
|
84119
84733
|
}
|
|
84120
84734
|
if (!isDir) continue;
|
|
84121
|
-
const v = skillVersion((0,
|
|
84735
|
+
const v = skillVersion((0, import_node_path61.join)(dir, "SKILL.md"));
|
|
84122
84736
|
if (!v) continue;
|
|
84123
84737
|
out.push({ name, dir, version: v });
|
|
84124
84738
|
}
|
|
@@ -84131,17 +84745,17 @@ function syncSkills() {
|
|
|
84131
84745
|
const skills = bundledSkills(root5);
|
|
84132
84746
|
if (!skills.length) return results;
|
|
84133
84747
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
84134
|
-
if (!(0,
|
|
84135
|
-
const skillsDir = (0,
|
|
84748
|
+
if (!(0, import_node_fs66.existsSync)(cfg)) continue;
|
|
84749
|
+
const skillsDir = (0, import_node_path61.join)(cfg, "skills");
|
|
84136
84750
|
for (const s of skills) {
|
|
84137
|
-
const dest = (0,
|
|
84138
|
-
const installedMd = (0,
|
|
84139
|
-
const installed = (0,
|
|
84751
|
+
const dest = (0, import_node_path61.join)(skillsDir, s.name);
|
|
84752
|
+
const installedMd = (0, import_node_path61.join)(dest, "SKILL.md");
|
|
84753
|
+
const installed = (0, import_node_fs66.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
84140
84754
|
const action = decideAction(installed, s.version);
|
|
84141
84755
|
if (action === "installed" || action === "updated") {
|
|
84142
84756
|
try {
|
|
84143
|
-
if (action === "updated") (0,
|
|
84144
|
-
(0,
|
|
84757
|
+
if (action === "updated") (0, import_node_fs66.rmSync)(dest, { recursive: true, force: true });
|
|
84758
|
+
(0, import_node_fs66.cpSync)(s.dir, dest, { recursive: true });
|
|
84145
84759
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
84146
84760
|
} catch {
|
|
84147
84761
|
}
|
|
@@ -84154,9 +84768,9 @@ function syncSkills() {
|
|
|
84154
84768
|
}
|
|
84155
84769
|
|
|
84156
84770
|
// watch.ts
|
|
84157
|
-
var
|
|
84158
|
-
var
|
|
84159
|
-
var
|
|
84771
|
+
var import_node_os33 = require("node:os");
|
|
84772
|
+
var import_node_path63 = require("node:path");
|
|
84773
|
+
var import_node_fs67 = require("node:fs");
|
|
84160
84774
|
|
|
84161
84775
|
// node_modules/chokidar/esm/index.js
|
|
84162
84776
|
var import_fs2 = require("fs");
|
|
@@ -84167,7 +84781,7 @@ var sysPath2 = __toESM(require("path"), 1);
|
|
|
84167
84781
|
// node_modules/readdirp/esm/index.js
|
|
84168
84782
|
var import_promises8 = require("node:fs/promises");
|
|
84169
84783
|
var import_node_stream4 = require("node:stream");
|
|
84170
|
-
var
|
|
84784
|
+
var import_node_path62 = require("node:path");
|
|
84171
84785
|
var EntryTypes = {
|
|
84172
84786
|
FILE_TYPE: "files",
|
|
84173
84787
|
DIR_TYPE: "directories",
|
|
@@ -84242,7 +84856,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
84242
84856
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
84243
84857
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
84244
84858
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
84245
|
-
this._root = (0,
|
|
84859
|
+
this._root = (0, import_node_path62.resolve)(root5);
|
|
84246
84860
|
this._isDirent = !opts.alwaysStat;
|
|
84247
84861
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
84248
84862
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
@@ -84311,10 +84925,10 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
84311
84925
|
}
|
|
84312
84926
|
async _formatEntry(dirent, path) {
|
|
84313
84927
|
let entry2;
|
|
84314
|
-
const
|
|
84928
|
+
const basename15 = this._isDirent ? dirent.name : dirent;
|
|
84315
84929
|
try {
|
|
84316
|
-
const fullPath = (0,
|
|
84317
|
-
entry2 = { path: (0,
|
|
84930
|
+
const fullPath = (0, import_node_path62.resolve)((0, import_node_path62.join)(path, basename15));
|
|
84931
|
+
entry2 = { path: (0, import_node_path62.relative)(this._root, fullPath), fullPath, basename: basename15 };
|
|
84318
84932
|
entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
84319
84933
|
} catch (err2) {
|
|
84320
84934
|
this._onError(err2);
|
|
@@ -84348,7 +84962,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
84348
84962
|
}
|
|
84349
84963
|
if (entryRealPathStats.isDirectory()) {
|
|
84350
84964
|
const len = entryRealPath.length;
|
|
84351
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
84965
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path62.sep) {
|
|
84352
84966
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
84353
84967
|
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
84354
84968
|
return this._onError(recursiveError);
|
|
@@ -84853,9 +85467,9 @@ var NodeFsHandler = class {
|
|
|
84853
85467
|
_watchWithNodeFs(path, listener) {
|
|
84854
85468
|
const opts = this.fsw.options;
|
|
84855
85469
|
const directory = sysPath.dirname(path);
|
|
84856
|
-
const
|
|
85470
|
+
const basename15 = sysPath.basename(path);
|
|
84857
85471
|
const parent = this.fsw._getWatchedDir(directory);
|
|
84858
|
-
parent.add(
|
|
85472
|
+
parent.add(basename15);
|
|
84859
85473
|
const absolutePath = sysPath.resolve(path);
|
|
84860
85474
|
const options = {
|
|
84861
85475
|
persistent: opts.persistent
|
|
@@ -84865,7 +85479,7 @@ var NodeFsHandler = class {
|
|
|
84865
85479
|
let closer;
|
|
84866
85480
|
if (opts.usePolling) {
|
|
84867
85481
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
84868
|
-
options.interval = enableBin && isBinaryPath(
|
|
85482
|
+
options.interval = enableBin && isBinaryPath(basename15) ? opts.binaryInterval : opts.interval;
|
|
84869
85483
|
closer = setFsWatchFileListener(path, absolutePath, options, {
|
|
84870
85484
|
listener,
|
|
84871
85485
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -84887,11 +85501,11 @@ var NodeFsHandler = class {
|
|
|
84887
85501
|
if (this.fsw.closed) {
|
|
84888
85502
|
return;
|
|
84889
85503
|
}
|
|
84890
|
-
const
|
|
84891
|
-
const
|
|
84892
|
-
const parent = this.fsw._getWatchedDir(
|
|
85504
|
+
const dirname28 = sysPath.dirname(file);
|
|
85505
|
+
const basename15 = sysPath.basename(file);
|
|
85506
|
+
const parent = this.fsw._getWatchedDir(dirname28);
|
|
84893
85507
|
let prevStats = stats;
|
|
84894
|
-
if (parent.has(
|
|
85508
|
+
if (parent.has(basename15))
|
|
84895
85509
|
return;
|
|
84896
85510
|
const listener = async (path, newStats) => {
|
|
84897
85511
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
@@ -84916,9 +85530,9 @@ var NodeFsHandler = class {
|
|
|
84916
85530
|
prevStats = newStats2;
|
|
84917
85531
|
}
|
|
84918
85532
|
} catch (error) {
|
|
84919
|
-
this.fsw._remove(
|
|
85533
|
+
this.fsw._remove(dirname28, basename15);
|
|
84920
85534
|
}
|
|
84921
|
-
} else if (parent.has(
|
|
85535
|
+
} else if (parent.has(basename15)) {
|
|
84922
85536
|
const at = newStats.atimeMs;
|
|
84923
85537
|
const mt = newStats.mtimeMs;
|
|
84924
85538
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
|
@@ -85856,33 +86470,33 @@ function appIdFromLogPath(path) {
|
|
|
85856
86470
|
return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
|
|
85857
86471
|
}
|
|
85858
86472
|
function samePath(a, b) {
|
|
85859
|
-
const ra = (0,
|
|
85860
|
-
const rb = (0,
|
|
86473
|
+
const ra = (0, import_node_path63.resolve)(a);
|
|
86474
|
+
const rb = (0, import_node_path63.resolve)(b);
|
|
85861
86475
|
return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
|
|
85862
86476
|
}
|
|
85863
86477
|
function underDir(path, dir) {
|
|
85864
|
-
const rp = (0,
|
|
85865
|
-
const rd = (0,
|
|
86478
|
+
const rp = (0, import_node_path63.resolve)(path);
|
|
86479
|
+
const rd = (0, import_node_path63.resolve)(dir);
|
|
85866
86480
|
const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
|
|
85867
|
-
return p === d || p.startsWith(d +
|
|
86481
|
+
return p === d || p.startsWith(d + import_node_path63.sep);
|
|
85868
86482
|
}
|
|
85869
86483
|
function startWatcher() {
|
|
85870
|
-
const awareDir = process.env.AWARE_HOME ?? (0,
|
|
85871
|
-
const credentialsDir = (0,
|
|
85872
|
-
if (!(0,
|
|
86484
|
+
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path63.join)((0, import_node_os33.homedir)(), ".aware");
|
|
86485
|
+
const credentialsDir = (0, import_node_path63.join)(awareDir, "credentials");
|
|
86486
|
+
if (!(0, import_node_fs67.existsSync)(credentialsDir)) {
|
|
85873
86487
|
try {
|
|
85874
|
-
(0,
|
|
86488
|
+
(0, import_node_fs67.mkdirSync)(credentialsDir, { recursive: true });
|
|
85875
86489
|
} catch {
|
|
85876
86490
|
}
|
|
85877
86491
|
}
|
|
85878
|
-
if (!(0,
|
|
86492
|
+
if (!(0, import_node_fs67.existsSync)(uiDir)) {
|
|
85879
86493
|
try {
|
|
85880
|
-
(0,
|
|
86494
|
+
(0, import_node_fs67.mkdirSync)(uiDir, { recursive: true });
|
|
85881
86495
|
} catch {
|
|
85882
86496
|
}
|
|
85883
86497
|
}
|
|
85884
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0,
|
|
85885
|
-
if ((0,
|
|
86498
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path63.join)(awareDir, d)).filter((p) => (0, import_node_fs67.existsSync)(p));
|
|
86499
|
+
if ((0, import_node_fs67.existsSync)(uiDir)) targets.push(uiDir);
|
|
85886
86500
|
if (targets.length === 0) {
|
|
85887
86501
|
return null;
|
|
85888
86502
|
}
|
|
@@ -85911,11 +86525,11 @@ function startWatcher() {
|
|
|
85911
86525
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
85912
86526
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
85913
86527
|
broadcast({ type: "fs-change", kind, event, path });
|
|
85914
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
86528
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs67.existsSync)(path)) {
|
|
85915
86529
|
const id = appIdFromLogPath(path);
|
|
85916
86530
|
if (!id) return;
|
|
85917
86531
|
try {
|
|
85918
|
-
broadcast({ type: "trace-file", id, runId: path.split(
|
|
86532
|
+
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
86533
|
} catch {
|
|
85920
86534
|
}
|
|
85921
86535
|
}
|
|
@@ -85924,10 +86538,10 @@ function startWatcher() {
|
|
|
85924
86538
|
}
|
|
85925
86539
|
|
|
85926
86540
|
// index.ts
|
|
85927
|
-
var __dirname4 = (0,
|
|
85928
|
-
var WEB_ROOT = [(0,
|
|
85929
|
-
(p) => (0,
|
|
85930
|
-
) ?? (0,
|
|
86541
|
+
var __dirname4 = (0, import_node_path64.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
|
|
86542
|
+
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(
|
|
86543
|
+
(p) => (0, import_node_fs68.existsSync)(p)
|
|
86544
|
+
) ?? (0, import_node_path64.join)(__dirname4, "..", "web");
|
|
85931
86545
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
85932
86546
|
var HOST = "127.0.0.1";
|
|
85933
86547
|
var crashHandlersInstalled = false;
|
|
@@ -85943,7 +86557,7 @@ function installCrashHandlers() {
|
|
|
85943
86557
|
${stack}
|
|
85944
86558
|
`;
|
|
85945
86559
|
try {
|
|
85946
|
-
(0,
|
|
86560
|
+
(0, import_node_fs68.appendFileSync)(logFilePath(), line);
|
|
85947
86561
|
} catch {
|
|
85948
86562
|
}
|
|
85949
86563
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -86038,12 +86652,12 @@ async function startServer() {
|
|
|
86038
86652
|
skip: process.env.AWARE_SKIP_BOOTSTRAP === "1",
|
|
86039
86653
|
logWarn: (msg, fields) => app.log.warn(fields, msg)
|
|
86040
86654
|
};
|
|
86041
|
-
const AWARE_BRIDGE_DIRECTORY = (0,
|
|
86655
|
+
const AWARE_BRIDGE_DIRECTORY = (0, import_node_path64.join)((0, import_node_os34.homedir)(), ".aware", "bridges");
|
|
86042
86656
|
const awareMaintenance = createMaintenanceMarkerStore(
|
|
86043
|
-
(0,
|
|
86657
|
+
(0, import_node_path64.join)((0, import_node_os34.homedir)(), ".floless", "aware-maintenance.json")
|
|
86044
86658
|
);
|
|
86045
86659
|
const awareBridgePending = createBridgePendingStore(
|
|
86046
|
-
(0,
|
|
86660
|
+
(0, import_node_path64.join)((0, import_node_os34.homedir)(), ".floless", "aware-bridge-pending.json")
|
|
86047
86661
|
);
|
|
86048
86662
|
async function staleBridgesForInstalledRuntime() {
|
|
86049
86663
|
const target = aware.npmVersion();
|
|
@@ -86127,7 +86741,11 @@ async function startServer() {
|
|
|
86127
86741
|
signal: context.signal,
|
|
86128
86742
|
onChild: context.childStarted
|
|
86129
86743
|
}),
|
|
86130
|
-
refreshRuntime: () =>
|
|
86744
|
+
refreshRuntime: () => {
|
|
86745
|
+
refreshInvoker();
|
|
86746
|
+
disarmAutoBridgeRepair();
|
|
86747
|
+
scheduleAutoBridgeRepair();
|
|
86748
|
+
},
|
|
86131
86749
|
invalidateVersion: invalidateAwareVersion,
|
|
86132
86750
|
probeRuntime: () => aware.npmVersion(),
|
|
86133
86751
|
smokeRuntime: async () => aware.smoke(),
|
|
@@ -86223,11 +86841,43 @@ async function startServer() {
|
|
|
86223
86841
|
function disarmAutoBridgeRepair() {
|
|
86224
86842
|
detachAutoRepairIdleWatch?.();
|
|
86225
86843
|
detachAutoRepairIdleWatch = null;
|
|
86844
|
+
autoRepairScheduled = false;
|
|
86845
|
+
}
|
|
86846
|
+
async function staleManagedSidecarsForInstalledRuntime() {
|
|
86847
|
+
try {
|
|
86848
|
+
const inventory = await aware.managedSidecarInventory();
|
|
86849
|
+
return inventory.sidecars.filter((sidecar) => sidecar.repairEligible).length;
|
|
86850
|
+
} catch (error) {
|
|
86851
|
+
if (error instanceof AwareUnsupportedError) return null;
|
|
86852
|
+
throw error;
|
|
86853
|
+
}
|
|
86226
86854
|
}
|
|
86227
86855
|
async function attemptAutoBridgeRepair() {
|
|
86228
86856
|
if (autoRepairInFlight || SKIP_AUTO_BRIDGE_REPAIR) return;
|
|
86229
86857
|
autoRepairInFlight = true;
|
|
86230
86858
|
try {
|
|
86859
|
+
const managedSidecarsNeedingRepair = await staleManagedSidecarsForInstalledRuntime();
|
|
86860
|
+
if (managedSidecarsNeedingRepair === 0) {
|
|
86861
|
+
disarmAutoBridgeRepair();
|
|
86862
|
+
return;
|
|
86863
|
+
}
|
|
86864
|
+
if (managedSidecarsNeedingRepair !== null) {
|
|
86865
|
+
const outcome2 = await tryWithAwareExclusiveIfIdle("auto", async () => {
|
|
86866
|
+
const before = await aware.managedSidecarInventory();
|
|
86867
|
+
if (!before.sidecars.some((sidecar) => sidecar.repairEligible)) return;
|
|
86868
|
+
const after = await aware.repairInstalledManagedSidecars();
|
|
86869
|
+
const remaining2 = after.sidecars.filter((sidecar) => sidecar.repairEligible);
|
|
86870
|
+
if (remaining2.length) {
|
|
86871
|
+
throw new Error(`AWARE left ${remaining2.length} managed runtime tool(s) needing repair.`);
|
|
86872
|
+
}
|
|
86873
|
+
app.log.info(
|
|
86874
|
+
{ repaired: before.sidecars.filter((sidecar) => sidecar.repairEligible).length },
|
|
86875
|
+
"repaired stale AWARE managed runtime tools"
|
|
86876
|
+
);
|
|
86877
|
+
});
|
|
86878
|
+
if (outcome2.ran) disarmAutoBridgeRepair();
|
|
86879
|
+
return;
|
|
86880
|
+
}
|
|
86231
86881
|
if (!await staleBridgesForInstalledRuntime()) {
|
|
86232
86882
|
disarmAutoBridgeRepair();
|
|
86233
86883
|
return;
|
|
@@ -86599,16 +87249,17 @@ async function startServer() {
|
|
|
86599
87249
|
const bdir = backupDir(id, fromVersion, Date.now());
|
|
86600
87250
|
let backedUp = false;
|
|
86601
87251
|
try {
|
|
86602
|
-
(0,
|
|
86603
|
-
(0,
|
|
87252
|
+
(0, import_node_fs68.mkdirSync)((0, import_node_path64.dirname)(bdir), { recursive: true });
|
|
87253
|
+
(0, import_node_fs68.cpSync)(appDirPath2, bdir, { recursive: true });
|
|
86604
87254
|
backedUp = true;
|
|
86605
|
-
(0,
|
|
87255
|
+
(0, import_node_fs68.cpSync)(templatePath, srcPath);
|
|
86606
87256
|
if (id !== templateId) stampSourceAppId(srcPath, id);
|
|
86607
87257
|
if (contract != null) {
|
|
86608
87258
|
bakeContractIntoApp(srcPath, contract);
|
|
86609
87259
|
await bakeDownstream(srcPath, id, contract);
|
|
86610
87260
|
}
|
|
86611
87261
|
await aware.compile(srcPath);
|
|
87262
|
+
await dropPinBytes(id);
|
|
86612
87263
|
return { backupPath: bdir };
|
|
86613
87264
|
} catch (e) {
|
|
86614
87265
|
const msg = e instanceof Error ? e.message : String(e);
|
|
@@ -86616,8 +87267,8 @@ async function startServer() {
|
|
|
86616
87267
|
throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
|
|
86617
87268
|
}
|
|
86618
87269
|
try {
|
|
86619
|
-
(0,
|
|
86620
|
-
(0,
|
|
87270
|
+
(0, import_node_fs68.rmSync)(appDirPath2, { recursive: true, force: true });
|
|
87271
|
+
(0, import_node_fs68.cpSync)(bdir, appDirPath2, { recursive: true });
|
|
86621
87272
|
} catch (re) {
|
|
86622
87273
|
const rmsg = re instanceof Error ? re.message : String(re);
|
|
86623
87274
|
throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
|
|
@@ -86629,7 +87280,7 @@ async function startServer() {
|
|
|
86629
87280
|
function readSwapContract(id, verb) {
|
|
86630
87281
|
const gerund = verb === "update" ? "updating" : "restoring";
|
|
86631
87282
|
const contract = readAcceptedForRequest(id, void 0);
|
|
86632
|
-
if (contract == null && (0,
|
|
87283
|
+
if (contract == null && (0, import_node_fs68.existsSync)(contractPath(id))) {
|
|
86633
87284
|
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
87285
|
}
|
|
86635
87286
|
if (contract != null && !validateContract(contract).valid) {
|
|
@@ -86701,7 +87352,14 @@ async function startServer() {
|
|
|
86701
87352
|
const res = await run2();
|
|
86702
87353
|
result = { type: "agent-install-result", action, id, ok: true, installed: res.installed ?? id };
|
|
86703
87354
|
} catch (err2) {
|
|
86704
|
-
|
|
87355
|
+
const fallback2 = `Could not ${action} \u201C${id}\u201D.`;
|
|
87356
|
+
result = {
|
|
87357
|
+
type: "agent-install-result",
|
|
87358
|
+
action,
|
|
87359
|
+
id,
|
|
87360
|
+
ok: false,
|
|
87361
|
+
error: action === "update" ? agentUpdateFailureMessage(err2, id) : awareFailureMessage(err2, fallback2)
|
|
87362
|
+
};
|
|
86705
87363
|
} finally {
|
|
86706
87364
|
agentJobsInFlight.delete(id);
|
|
86707
87365
|
}
|
|
@@ -86798,7 +87456,8 @@ async function startServer() {
|
|
|
86798
87456
|
};
|
|
86799
87457
|
const requestContractType = (r, memo) => {
|
|
86800
87458
|
if (r.type !== "revision-read" || !r.appId || !r.project) return void 0;
|
|
86801
|
-
|
|
87459
|
+
const project = getProject(r.project);
|
|
87460
|
+
if (!project || !sameAppLineage(r.appId, project.app)) return void 0;
|
|
86802
87461
|
return storedContractType(r.appId, r.project, memo);
|
|
86803
87462
|
};
|
|
86804
87463
|
const requestProjectName = (r, memo) => {
|
|
@@ -86862,7 +87521,12 @@ async function startServer() {
|
|
|
86862
87521
|
{ kind: "project", key: req.params.id }
|
|
86863
87522
|
);
|
|
86864
87523
|
const before = getProject(req.params.id);
|
|
86865
|
-
const project = renameProject(req.params.id, req.body?.name)
|
|
87524
|
+
const project = await renameProject(req.params.id, req.body?.name, async (fromId, toId) => {
|
|
87525
|
+
await repointProjectPins(fromId, toId);
|
|
87526
|
+
return async () => {
|
|
87527
|
+
await repointProjectPins(toId, fromId);
|
|
87528
|
+
};
|
|
87529
|
+
});
|
|
86866
87530
|
if (!before) {
|
|
86867
87531
|
req.log.error({ id: req.params.id }, "rename: pre-read missing \u2014 other tabs cannot reconcile this rename");
|
|
86868
87532
|
} else if (before.id !== project.id) {
|
|
@@ -86957,7 +87621,7 @@ async function startServer() {
|
|
|
86957
87621
|
}
|
|
86958
87622
|
let data;
|
|
86959
87623
|
try {
|
|
86960
|
-
data = (0,
|
|
87624
|
+
data = (0, import_node_fs68.readFileSync)(thumb.path);
|
|
86961
87625
|
} catch {
|
|
86962
87626
|
return reply.status(404).send({ ok: false, error: "no thumbnail" });
|
|
86963
87627
|
}
|
|
@@ -87325,7 +87989,7 @@ async function startServer() {
|
|
|
87325
87989
|
const { source, contract } = consumeExportHandle(req.body.sourceHandle, project.id, project.uuid);
|
|
87326
87990
|
const safeLabel = source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-");
|
|
87327
87991
|
const filename = uniqueProjectExportFilename(project.id, `${exportFileBase(project.id, project.app)}-${safeLabel}.flo-contract.json`);
|
|
87328
|
-
const savedTo = (0,
|
|
87992
|
+
const savedTo = (0, import_node_path64.join)(projectExportsDir(project.id), filename);
|
|
87329
87993
|
durableCanonicalJson(savedTo, {
|
|
87330
87994
|
schema: 1,
|
|
87331
87995
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -87381,6 +88045,7 @@ async function startServer() {
|
|
|
87381
88045
|
registerRevisionRoutes(app);
|
|
87382
88046
|
registerSteelPrepassRoute(app, { getProject, clearApproval, broadcast });
|
|
87383
88047
|
registerKnowledgeRoutes(app);
|
|
88048
|
+
registerKbPinRoutes(app, { broadcast });
|
|
87384
88049
|
function projectAppMismatch(appId, project) {
|
|
87385
88050
|
const p = getProject(project);
|
|
87386
88051
|
if (!p) return `unknown project: ${project}`;
|
|
@@ -87489,9 +88154,9 @@ async function startServer() {
|
|
|
87489
88154
|
const bad = projectAppMismatch(req.params.appId, project);
|
|
87490
88155
|
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
87491
88156
|
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,
|
|
88157
|
+
const file = (0, import_node_path64.join)((0, import_node_path64.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
|
|
88158
|
+
if (!(0, import_node_fs68.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
|
|
88159
|
+
return reply.type("image/svg+xml").send((0, import_node_fs68.readFileSync)(file, "utf8"));
|
|
87495
88160
|
}
|
|
87496
88161
|
);
|
|
87497
88162
|
app.put(
|
|
@@ -87980,7 +88645,7 @@ async function startServer() {
|
|
|
87980
88645
|
}
|
|
87981
88646
|
const statedAt = (filename) => {
|
|
87982
88647
|
try {
|
|
87983
|
-
const st = (0,
|
|
88648
|
+
const st = (0, import_node_fs68.statSync)((0, import_node_path64.join)(dir, filename));
|
|
87984
88649
|
return st.isFile() ? st.mtime.toISOString() : null;
|
|
87985
88650
|
} catch {
|
|
87986
88651
|
return null;
|
|
@@ -87990,14 +88655,14 @@ async function startServer() {
|
|
|
87990
88655
|
const rows2 = (byKind.get(kind) ?? []).map((receipt) => ({
|
|
87991
88656
|
variant: receipt.variant ?? null,
|
|
87992
88657
|
filename: receipt.filename,
|
|
87993
|
-
path: (0,
|
|
88658
|
+
path: (0, import_node_path64.join)(dir, receipt.filename),
|
|
87994
88659
|
exportedAt: statedAt(receipt.filename)
|
|
87995
88660
|
})).sort((a, b) => String(b.exportedAt ?? "").localeCompare(String(a.exportedAt ?? "")));
|
|
87996
88661
|
const headline = rows2[0];
|
|
87997
88662
|
return {
|
|
87998
88663
|
kind,
|
|
87999
88664
|
filename: headline?.filename ?? legacy,
|
|
88000
|
-
path: headline?.path ?? (0,
|
|
88665
|
+
path: headline?.path ?? (0, import_node_path64.join)(dir, legacy),
|
|
88001
88666
|
exportedAt: headline?.exportedAt ?? null,
|
|
88002
88667
|
...rows2.length ? { variants: rows2 } : {}
|
|
88003
88668
|
};
|
|
@@ -88145,7 +88810,7 @@ async function startServer() {
|
|
|
88145
88810
|
}
|
|
88146
88811
|
if (!hasExportableSceneRecords(scene)) return reply.status(422).send({ ok: false, error: emptyError, skipped });
|
|
88147
88812
|
const filename = `${exportFileBase(project, appId)}${explicitExportSourceSuffix(input)}.ifc`;
|
|
88148
|
-
const finalPath = (0,
|
|
88813
|
+
const finalPath = (0, import_node_path64.join)(project ? projectExportsDir(project) : (0, import_node_path64.dirname)(bomExportPath(appId, "csv")), filename);
|
|
88149
88814
|
const priorProjectIfc = project ? listProjectExportReceipts(project).find((row) => row.kind === "ifc") : void 0;
|
|
88150
88815
|
const tempPath = requestIfcTempPath(finalPath);
|
|
88151
88816
|
try {
|
|
@@ -88153,10 +88818,10 @@ async function startServer() {
|
|
|
88153
88818
|
scene,
|
|
88154
88819
|
"output-path": tempPath
|
|
88155
88820
|
});
|
|
88156
|
-
if (!(0,
|
|
88821
|
+
if (!(0, import_node_fs68.existsSync)(tempPath) || (0, import_node_fs68.statSync)(tempPath).size === 0) {
|
|
88157
88822
|
throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
|
|
88158
88823
|
}
|
|
88159
|
-
const artifactBytes = (0,
|
|
88824
|
+
const artifactBytes = (0, import_node_fs68.readFileSync)(tempPath);
|
|
88160
88825
|
const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
|
|
88161
88826
|
index: parseStepData(artifactBytes),
|
|
88162
88827
|
bytes: artifactBytes
|
|
@@ -88212,7 +88877,7 @@ async function startServer() {
|
|
|
88212
88877
|
ok: false,
|
|
88213
88878
|
error: awareFailureMessage(error, "IFC export failed"),
|
|
88214
88879
|
...reason ? { reason } : {},
|
|
88215
|
-
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0,
|
|
88880
|
+
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs68.existsSync)(finalPath)
|
|
88216
88881
|
});
|
|
88217
88882
|
} finally {
|
|
88218
88883
|
cleanupIfcTemp(tempPath);
|
|
@@ -88259,10 +88924,10 @@ async function startServer() {
|
|
|
88259
88924
|
const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
|
|
88260
88925
|
if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
|
|
88261
88926
|
const path = resolveProjectExportReceiptPath(project, receipt);
|
|
88262
|
-
if (!path || !(0,
|
|
88927
|
+
if (!path || !(0, import_node_fs68.existsSync)(path)) {
|
|
88263
88928
|
return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
|
|
88264
88929
|
}
|
|
88265
|
-
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0,
|
|
88930
|
+
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs68.readFileSync)(path));
|
|
88266
88931
|
});
|
|
88267
88932
|
const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
|
|
88268
88933
|
app.post("/api/contract/:appId/render", async (req, reply) => {
|
|
@@ -88323,8 +88988,8 @@ async function startServer() {
|
|
|
88323
88988
|
}
|
|
88324
88989
|
const kind = output === "turntable" ? "render-mp4" : "render-png";
|
|
88325
88990
|
const extension = output === "turntable" ? ".mp4" : ".png";
|
|
88326
|
-
const scratch = (0,
|
|
88327
|
-
const ifcPath = (0,
|
|
88991
|
+
const scratch = (0, import_node_fs68.mkdtempSync)((0, import_node_path64.join)((0, import_node_os34.tmpdir)(), "floless-render-"));
|
|
88992
|
+
const ifcPath = (0, import_node_path64.join)(scratch, "model.ifc");
|
|
88328
88993
|
const rendered = [];
|
|
88329
88994
|
const progress = (stage, extra = {}) => {
|
|
88330
88995
|
try {
|
|
@@ -88335,13 +89000,13 @@ async function startServer() {
|
|
|
88335
89000
|
try {
|
|
88336
89001
|
progress("preparing");
|
|
88337
89002
|
await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
|
|
88338
|
-
if (!(0,
|
|
89003
|
+
if (!(0, import_node_fs68.existsSync)(ifcPath) || (0, import_node_fs68.statSync)(ifcPath).size === 0) {
|
|
88339
89004
|
throw new Error("AWARE reported a successful IFC write but produced no file to render");
|
|
88340
89005
|
}
|
|
88341
89006
|
const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
|
|
88342
89007
|
for (const [i, viewpoint] of viewpoints.entries()) {
|
|
88343
89008
|
progress("rendering", { viewpoint, index: i + 1, output });
|
|
88344
|
-
const artifactPath = (0,
|
|
89009
|
+
const artifactPath = (0, import_node_path64.join)(scratch, `render-${viewpoint}${extension}`);
|
|
88345
89010
|
const receipt = await aware.agentInvoke(RENDER_AGENT_ID, output === "turntable" ? "render.turntable" : "render.still", {
|
|
88346
89011
|
"ifc-path": ifcPath,
|
|
88347
89012
|
"output-path": artifactPath,
|
|
@@ -88353,10 +89018,10 @@ async function startServer() {
|
|
|
88353
89018
|
environment: "studio",
|
|
88354
89019
|
...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
|
|
88355
89020
|
}, { timeoutMs: renderBudgetMs });
|
|
88356
|
-
if (!(0,
|
|
89021
|
+
if (!(0, import_node_fs68.existsSync)(artifactPath) || (0, import_node_fs68.statSync)(artifactPath).size === 0) {
|
|
88357
89022
|
throw new Error(`the ${viewpoint} render reported success but produced no image`);
|
|
88358
89023
|
}
|
|
88359
|
-
const bytes = (0,
|
|
89024
|
+
const bytes = (0, import_node_fs68.readFileSync)(artifactPath);
|
|
88360
89025
|
const sourceSuffix = "source" in projectSnapshot && projectSnapshot.source ? `-${projectSnapshot.source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-")}` : "";
|
|
88361
89026
|
const preferred = `${exportFileBase(project, appId)}-${viewpoint}${sourceSuffix}${extension}`;
|
|
88362
89027
|
const filename = uniqueProjectExportFilename(project, preferred);
|
|
@@ -88394,7 +89059,7 @@ async function startServer() {
|
|
|
88394
89059
|
// Kept for a single-viewpoint caller so the existing shape still reads naturally.
|
|
88395
89060
|
filename: rendered[0]?.filename,
|
|
88396
89061
|
viewpoint: rendered[0]?.viewpoint,
|
|
88397
|
-
savedTo: rendered[0] ? (0,
|
|
89062
|
+
savedTo: rendered[0] ? (0, import_node_path64.join)(projectExportsDir(project), rendered[0].filename) : void 0
|
|
88398
89063
|
};
|
|
88399
89064
|
} catch (error) {
|
|
88400
89065
|
const reason = awareStderr(error);
|
|
@@ -88412,7 +89077,7 @@ async function startServer() {
|
|
|
88412
89077
|
rendered
|
|
88413
89078
|
});
|
|
88414
89079
|
} finally {
|
|
88415
|
-
(0,
|
|
89080
|
+
(0, import_node_fs68.rmSync)(scratch, { recursive: true, force: true });
|
|
88416
89081
|
}
|
|
88417
89082
|
}, {
|
|
88418
89083
|
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
@@ -88650,10 +89315,10 @@ async function startServer() {
|
|
|
88650
89315
|
}
|
|
88651
89316
|
const preferredFilename = `${exportFileBase(project, appId)}-bom${explicitExportSourceSuffix(input.source)}.${format}`;
|
|
88652
89317
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
88653
|
-
const outPath = project ? (0,
|
|
88654
|
-
const dir = (0,
|
|
89318
|
+
const outPath = project ? (0, import_node_path64.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
|
|
89319
|
+
const dir = (0, import_node_path64.dirname)(outPath);
|
|
88655
89320
|
try {
|
|
88656
|
-
(0,
|
|
89321
|
+
(0, import_node_fs68.mkdirSync)(dir, { recursive: true });
|
|
88657
89322
|
const kind = BOM_EXPORT_KIND[format];
|
|
88658
89323
|
let text3 = null;
|
|
88659
89324
|
let buf;
|
|
@@ -88681,8 +89346,8 @@ async function startServer() {
|
|
|
88681
89346
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
88682
89347
|
contractHash: projectSnapshot.contractHash
|
|
88683
89348
|
}, buf);
|
|
88684
|
-
} else if (text3 != null) (0,
|
|
88685
|
-
else (0,
|
|
89349
|
+
} else if (text3 != null) (0, import_node_fs68.writeFileSync)(outPath, text3, "utf8");
|
|
89350
|
+
else (0, import_node_fs68.writeFileSync)(outPath, buf);
|
|
88686
89351
|
return {
|
|
88687
89352
|
ok: true,
|
|
88688
89353
|
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 +89385,9 @@ async function startServer() {
|
|
|
88720
89385
|
const svg = contractToSvg(cleaned);
|
|
88721
89386
|
const preferredFilename = `${exportFileBase(project, appId)}${explicitExportSourceSuffix(input)}.svg`;
|
|
88722
89387
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
88723
|
-
const outPath = project ? (0,
|
|
89388
|
+
const outPath = project ? (0, import_node_path64.join)(projectExportsDir(project), filename) : (0, import_node_path64.join)(appPath(appId), filename);
|
|
88724
89389
|
try {
|
|
88725
|
-
(0,
|
|
89390
|
+
(0, import_node_fs68.mkdirSync)((0, import_node_path64.dirname)(outPath), { recursive: true });
|
|
88726
89391
|
if (project && projectSnapshot) {
|
|
88727
89392
|
publishProjectExportArtifact(project, {
|
|
88728
89393
|
kind: "svg",
|
|
@@ -88733,7 +89398,7 @@ async function startServer() {
|
|
|
88733
89398
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
88734
89399
|
contractHash: projectSnapshot.contractHash
|
|
88735
89400
|
}, Buffer.from(svg, "utf8"));
|
|
88736
|
-
} else (0,
|
|
89401
|
+
} else (0, import_node_fs68.writeFileSync)(outPath, svg, "utf8");
|
|
88737
89402
|
return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
|
|
88738
89403
|
} catch (e) {
|
|
88739
89404
|
app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
|
|
@@ -88879,12 +89544,12 @@ async function startServer() {
|
|
|
88879
89544
|
if (!id && !sourcePath) return reply.status(400).send({ ok: false, error: "id or sourcePath required" });
|
|
88880
89545
|
const explicitInstalledId = (() => {
|
|
88881
89546
|
if (!sourcePath) return null;
|
|
88882
|
-
const awareRoot = process.env.AWARE_HOME || (0,
|
|
88883
|
-
const rel = (0,
|
|
89547
|
+
const awareRoot = process.env.AWARE_HOME || (0, import_node_path64.join)((0, import_node_os34.homedir)(), ".aware");
|
|
89548
|
+
const rel = (0, import_node_path64.relative)((0, import_node_path64.resolve)(awareRoot, "apps"), (0, import_node_path64.resolve)(sourcePath));
|
|
88884
89549
|
const segments = rel.split(/[\\/]/);
|
|
88885
89550
|
if (segments.length !== 2 || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(segments[0])) return null;
|
|
88886
89551
|
try {
|
|
88887
|
-
return (0,
|
|
89552
|
+
return (0, import_node_path64.resolve)(readApp(segments[0]).source.path) === (0, import_node_path64.resolve)(sourcePath) ? segments[0] : null;
|
|
88888
89553
|
} catch {
|
|
88889
89554
|
return null;
|
|
88890
89555
|
}
|
|
@@ -88915,11 +89580,22 @@ async function startServer() {
|
|
|
88915
89580
|
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
89581
|
}
|
|
88917
89582
|
await deleteOrigin(id);
|
|
88918
|
-
const stageRoot = (0, import_node_fs66.mkdtempSync)((0, import_node_path63.join)((0, import_node_os33.tmpdir)(), "floless-import-"));
|
|
88919
89583
|
try {
|
|
88920
|
-
|
|
88921
|
-
|
|
88922
|
-
|
|
89584
|
+
await dropPinBytes(id);
|
|
89585
|
+
} catch (e) {
|
|
89586
|
+
app.log.error({ err: e, id }, "could not drop stale knowledge pin before import");
|
|
89587
|
+
return reply.status(500).send({
|
|
89588
|
+
ok: false,
|
|
89589
|
+
error: "Could not clear stale knowledge provenance before import. Close anything using that file and try again.",
|
|
89590
|
+
code: "kb_pin_cleanup_failed",
|
|
89591
|
+
id
|
|
89592
|
+
});
|
|
89593
|
+
}
|
|
89594
|
+
const stageRoot = (0, import_node_fs68.mkdtempSync)((0, import_node_path64.join)((0, import_node_os34.tmpdir)(), "floless-import-"));
|
|
89595
|
+
try {
|
|
89596
|
+
const stageDir = (0, import_node_path64.join)(stageRoot, id);
|
|
89597
|
+
(0, import_node_fs68.mkdirSync)(stageDir);
|
|
89598
|
+
(0, import_node_fs68.writeFileSync)((0, import_node_path64.join)(stageDir, `${id}.flo`), content);
|
|
88923
89599
|
await aware.install(stageDir);
|
|
88924
89600
|
} catch (err2) {
|
|
88925
89601
|
try {
|
|
@@ -88930,7 +89606,7 @@ async function startServer() {
|
|
|
88930
89606
|
const reason = awareStderr(err2);
|
|
88931
89607
|
return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
|
|
88932
89608
|
} finally {
|
|
88933
|
-
(0,
|
|
89609
|
+
(0, import_node_fs68.rmSync)(stageRoot, { recursive: true, force: true });
|
|
88934
89610
|
}
|
|
88935
89611
|
broadcast({ type: "apps-changed", id });
|
|
88936
89612
|
return { ok: true, id };
|
|
@@ -88946,13 +89622,13 @@ async function startServer() {
|
|
|
88946
89622
|
}
|
|
88947
89623
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
88948
89624
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
88949
|
-
const tmpRoot = (0,
|
|
88950
|
-
const backupDir2 = (0,
|
|
88951
|
-
const bakeDir = (0,
|
|
88952
|
-
(0,
|
|
88953
|
-
(0,
|
|
89625
|
+
const tmpRoot = (0, import_node_fs68.mkdtempSync)((0, import_node_path64.join)((0, import_node_os34.tmpdir)(), "floless-bake-"));
|
|
89626
|
+
const backupDir2 = (0, import_node_path64.join)(tmpRoot, `${id}-backup`);
|
|
89627
|
+
const bakeDir = (0, import_node_path64.join)(tmpRoot, id);
|
|
89628
|
+
(0, import_node_fs68.cpSync)(appDir(id), backupDir2, { recursive: true });
|
|
89629
|
+
(0, import_node_fs68.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
88954
89630
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
88955
|
-
(0,
|
|
89631
|
+
(0, import_node_fs68.writeFileSync)((0, import_node_path64.join)(bakeDir, floName), baked);
|
|
88956
89632
|
let appInstalled2 = true;
|
|
88957
89633
|
try {
|
|
88958
89634
|
await aware.uninstall(id);
|
|
@@ -88974,18 +89650,18 @@ async function startServer() {
|
|
|
88974
89650
|
throw installErr;
|
|
88975
89651
|
}
|
|
88976
89652
|
try {
|
|
88977
|
-
await aware.compile((0,
|
|
89653
|
+
await aware.compile((0, import_node_path64.join)(appDir(id), floName));
|
|
88978
89654
|
} catch (compileErr) {
|
|
88979
89655
|
app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
|
|
88980
89656
|
}
|
|
88981
89657
|
broadcast({ type: "baked", id });
|
|
88982
89658
|
return { ok: true, id, agent: id, inputs };
|
|
88983
89659
|
} finally {
|
|
88984
|
-
if (appInstalled2) (0,
|
|
89660
|
+
if (appInstalled2) (0, import_node_fs68.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
88985
89661
|
}
|
|
88986
89662
|
});
|
|
88987
89663
|
});
|
|
88988
|
-
const graftAgentsDir = () => (0,
|
|
89664
|
+
const graftAgentsDir = () => (0, import_node_path64.join)((0, import_node_os34.homedir)(), ".aware", "agents");
|
|
88989
89665
|
app.post("/api/graft/match", async (req, reply) => {
|
|
88990
89666
|
const { glob } = req.body ?? {};
|
|
88991
89667
|
if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
|
|
@@ -89002,7 +89678,7 @@ async function startServer() {
|
|
|
89002
89678
|
if (!sourceKind || !sourceRef) {
|
|
89003
89679
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
89004
89680
|
}
|
|
89005
|
-
const tempHome = (0,
|
|
89681
|
+
const tempHome = (0, import_node_fs68.mkdtempSync)((0, import_node_path64.join)((0, import_node_os34.tmpdir)(), "floless-graft-"));
|
|
89006
89682
|
let result;
|
|
89007
89683
|
try {
|
|
89008
89684
|
result = await aware.build({
|
|
@@ -89015,19 +89691,19 @@ async function startServer() {
|
|
|
89015
89691
|
awareHome: tempHome
|
|
89016
89692
|
});
|
|
89017
89693
|
} catch (err2) {
|
|
89018
|
-
(0,
|
|
89694
|
+
(0, import_node_fs68.rmSync)(tempHome, { recursive: true, force: true });
|
|
89019
89695
|
const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
|
|
89020
89696
|
return reply.status(422).send({ ok: false, error: msg });
|
|
89021
89697
|
}
|
|
89022
89698
|
const manifest = readStagedManifest(result.agentDir);
|
|
89023
89699
|
if (!manifest) {
|
|
89024
|
-
(0,
|
|
89700
|
+
(0, import_node_fs68.rmSync)(tempHome, { recursive: true, force: true });
|
|
89025
89701
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
89026
89702
|
}
|
|
89027
89703
|
const token2 = (0, import_node_crypto35.randomUUID)();
|
|
89028
89704
|
registerStage(token2, tempHome, result.agentId);
|
|
89029
89705
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token2);
|
|
89030
|
-
if ((0,
|
|
89706
|
+
if ((0, import_node_fs68.existsSync)((0, import_node_path64.join)(graftAgentsDir(), result.agentId))) {
|
|
89031
89707
|
preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
89032
89708
|
}
|
|
89033
89709
|
return { ok: true, preview: preview2 };
|
|
@@ -89046,7 +89722,7 @@ async function startServer() {
|
|
|
89046
89722
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
89047
89723
|
return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
|
|
89048
89724
|
}
|
|
89049
|
-
(0,
|
|
89725
|
+
(0, import_node_fs68.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
89050
89726
|
throw err2;
|
|
89051
89727
|
}
|
|
89052
89728
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -89329,18 +90005,18 @@ async function startServer() {
|
|
|
89329
90005
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
89330
90006
|
const n = Number.parseInt(req.params.n, 10);
|
|
89331
90007
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
89332
|
-
if (!p || !(0,
|
|
90008
|
+
if (!p || !(0, import_node_fs68.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
89333
90009
|
const ext = p.split(".").pop().toLowerCase();
|
|
89334
90010
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
|
|
89335
90011
|
reply.header("Cache-Control", "no-store");
|
|
89336
|
-
return (0,
|
|
90012
|
+
return (0, import_node_fs68.readFileSync)(p);
|
|
89337
90013
|
});
|
|
89338
90014
|
app.post(
|
|
89339
90015
|
"/api/tweak",
|
|
89340
90016
|
{ bodyLimit: 25 * 1024 * 1024 },
|
|
89341
90017
|
async (req, reply) => {
|
|
89342
90018
|
const { appId, nodeId, instruction, snapshots } = req.body ?? {};
|
|
89343
|
-
if (!appId || !nodeId || !instruction) {
|
|
90019
|
+
if (!isSafeAppId2(appId) || !nodeId || !instruction) {
|
|
89344
90020
|
return reply.status(400).send({ ok: false, error: "appId, nodeId, instruction required" });
|
|
89345
90021
|
}
|
|
89346
90022
|
let decoded;
|
|
@@ -89354,28 +90030,7 @@ async function startServer() {
|
|
|
89354
90030
|
return { ok: true, request: requestView2(request) };
|
|
89355
90031
|
}
|
|
89356
90032
|
);
|
|
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
|
-
);
|
|
90033
|
+
registerContractRequestRoute(app, { broadcast, requestView: requestView2 });
|
|
89379
90034
|
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
90035
|
app.post(
|
|
89381
90036
|
"/api/rebake",
|
|
@@ -89385,7 +90040,7 @@ async function startServer() {
|
|
|
89385
90040
|
async (req, reply) => {
|
|
89386
90041
|
const { appId, inputName, instruction, snapshots } = req.body ?? {};
|
|
89387
90042
|
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" });
|
|
90043
|
+
if (!isSafeAppId2(appId)) return reply.status(400).send({ ok: false, error: "a valid appId is required" });
|
|
89389
90044
|
let decoded;
|
|
89390
90045
|
try {
|
|
89391
90046
|
decoded = decodeSnapshots(snapshots);
|
|
@@ -89477,7 +90132,7 @@ async function startServer() {
|
|
|
89477
90132
|
);
|
|
89478
90133
|
app.post("/api/use-template", async (req, reply) => {
|
|
89479
90134
|
const { appId, templateId } = req.body ?? {};
|
|
89480
|
-
if (!appId || !templateId) return reply.status(400).send({ ok: false, error: "appId and templateId required" });
|
|
90135
|
+
if (!isSafeAppId2(appId) || !templateId) return reply.status(400).send({ ok: false, error: "a valid appId and templateId are required" });
|
|
89481
90136
|
const template = getTemplate(templateId);
|
|
89482
90137
|
if (!template) return reply.status(404).send({ ok: false, error: "template not found" });
|
|
89483
90138
|
const request = addRequest({ type: "use-template", appId, templateId, template });
|
|
@@ -89486,11 +90141,18 @@ async function startServer() {
|
|
|
89486
90141
|
});
|
|
89487
90142
|
app.post("/api/guide", async (req, reply) => {
|
|
89488
90143
|
const { appId } = req.body ?? {};
|
|
89489
|
-
if (!appId) return reply.status(400).send({ ok: false, error: "appId required" });
|
|
90144
|
+
if (!isSafeAppId2(appId)) return reply.status(400).send({ ok: false, error: "a valid appId is required" });
|
|
89490
90145
|
const request = addRequest({ type: "guide", appId });
|
|
89491
90146
|
broadcast({ type: "request-added", request });
|
|
89492
90147
|
return { ok: true, request: requestView2(request) };
|
|
89493
90148
|
});
|
|
90149
|
+
app.post("/api/knowledge-consult", async (req, reply) => {
|
|
90150
|
+
const { appId } = req.body ?? {};
|
|
90151
|
+
if (!appId) return reply.status(400).send({ ok: false, error: "appId required" });
|
|
90152
|
+
const request = addRequest({ type: "knowledge-consult", appId });
|
|
90153
|
+
broadcast({ type: "request-added", request });
|
|
90154
|
+
return { ok: true, request: requestView2(request) };
|
|
90155
|
+
});
|
|
89494
90156
|
app.post("/api/guide-new", async (_req, _reply) => {
|
|
89495
90157
|
const request = addRequest({ type: "new-workflow" });
|
|
89496
90158
|
broadcast({ type: "request-added", request });
|
|
@@ -89593,7 +90255,7 @@ ${v.prompt}` : "";
|
|
|
89593
90255
|
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
89594
90256
|
let finishedAt2 = null;
|
|
89595
90257
|
try {
|
|
89596
|
-
finishedAt2 = (0,
|
|
90258
|
+
finishedAt2 = (0, import_node_fs68.statSync)(latest.path).mtime.toISOString();
|
|
89597
90259
|
} catch {
|
|
89598
90260
|
finishedAt2 = null;
|
|
89599
90261
|
}
|
|
@@ -89603,7 +90265,7 @@ ${v.prompt}` : "";
|
|
|
89603
90265
|
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
89604
90266
|
if (!finishedAt) {
|
|
89605
90267
|
try {
|
|
89606
|
-
finishedAt = (0,
|
|
90268
|
+
finishedAt = (0, import_node_fs68.statSync)(latest.path).mtime.toISOString();
|
|
89607
90269
|
} catch {
|
|
89608
90270
|
finishedAt = null;
|
|
89609
90271
|
}
|
|
@@ -89742,8 +90404,13 @@ ${v.prompt}` : "";
|
|
|
89742
90404
|
await app.listen({ port: PORT2, host: HOST });
|
|
89743
90405
|
app.log.info(`floless.app on http://${HOST}:${PORT2} (aware npm ${getBootstrapState().awareVersion ?? "unresolved"})`);
|
|
89744
90406
|
try {
|
|
89745
|
-
const
|
|
89746
|
-
|
|
90407
|
+
const manifest = syncWorkspaceAgentManifest(PORT2);
|
|
90408
|
+
const logFields = { manifestPath: manifest.path, owner: manifest.owner, previousOwner: manifest.previousOwner };
|
|
90409
|
+
if (manifest.outcome === "preserved-live-owner") {
|
|
90410
|
+
app.log.info(logFields, "preserved floless-workspace AWARE agent manifest owned by a live server");
|
|
90411
|
+
} else {
|
|
90412
|
+
app.log.info({ ...logFields, outcome: manifest.outcome }, "wrote floless-workspace AWARE agent manifest");
|
|
90413
|
+
}
|
|
89747
90414
|
} catch (err2) {
|
|
89748
90415
|
app.log.warn({ err: String(err2) }, "workspace agent manifest sync failed (non-fatal)");
|
|
89749
90416
|
}
|