@floless/app 0.10.0 → 0.12.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 +824 -340
- package/dist/skills/floless-app-ui/SKILL.md +131 -0
- package/dist/web/app.css +164 -0
- package/dist/web/aware.js +92 -4
- package/dist/web/index.html +52 -4
- package/dist/web/panels.js +660 -0
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -294,41 +294,41 @@ var require_queue = __commonJS({
|
|
|
294
294
|
queue2.drained = drained;
|
|
295
295
|
return queue2;
|
|
296
296
|
function push(value) {
|
|
297
|
-
var p = new Promise(function(
|
|
297
|
+
var p = new Promise(function(resolve5, reject) {
|
|
298
298
|
pushCb(value, function(err, result) {
|
|
299
299
|
if (err) {
|
|
300
300
|
reject(err);
|
|
301
301
|
return;
|
|
302
302
|
}
|
|
303
|
-
|
|
303
|
+
resolve5(result);
|
|
304
304
|
});
|
|
305
305
|
});
|
|
306
306
|
p.catch(noop);
|
|
307
307
|
return p;
|
|
308
308
|
}
|
|
309
309
|
function unshift(value) {
|
|
310
|
-
var p = new Promise(function(
|
|
310
|
+
var p = new Promise(function(resolve5, reject) {
|
|
311
311
|
unshiftCb(value, function(err, result) {
|
|
312
312
|
if (err) {
|
|
313
313
|
reject(err);
|
|
314
314
|
return;
|
|
315
315
|
}
|
|
316
|
-
|
|
316
|
+
resolve5(result);
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
319
|
p.catch(noop);
|
|
320
320
|
return p;
|
|
321
321
|
}
|
|
322
322
|
function drained() {
|
|
323
|
-
var p = new Promise(function(
|
|
323
|
+
var p = new Promise(function(resolve5) {
|
|
324
324
|
process.nextTick(function() {
|
|
325
325
|
if (queue2.idle()) {
|
|
326
|
-
|
|
326
|
+
resolve5();
|
|
327
327
|
} else {
|
|
328
328
|
var previousDrain = queue2.drain;
|
|
329
329
|
queue2.drain = function() {
|
|
330
330
|
if (typeof previousDrain === "function") previousDrain();
|
|
331
|
-
|
|
331
|
+
resolve5();
|
|
332
332
|
queue2.drain = previousDrain;
|
|
333
333
|
};
|
|
334
334
|
}
|
|
@@ -671,8 +671,8 @@ var require_create_promise = __commonJS({
|
|
|
671
671
|
reject: null,
|
|
672
672
|
promise: null
|
|
673
673
|
};
|
|
674
|
-
obj.promise = new Promise((
|
|
675
|
-
obj.resolve =
|
|
674
|
+
obj.promise = new Promise((resolve5, reject) => {
|
|
675
|
+
obj.resolve = resolve5;
|
|
676
676
|
obj.reject = reject;
|
|
677
677
|
});
|
|
678
678
|
return obj;
|
|
@@ -941,11 +941,11 @@ var require_thenify = __commonJS({
|
|
|
941
941
|
return;
|
|
942
942
|
}
|
|
943
943
|
debug("thenify");
|
|
944
|
-
return (
|
|
944
|
+
return (resolve5, reject) => {
|
|
945
945
|
const p = this._loadRegistered();
|
|
946
946
|
return p.then(() => {
|
|
947
947
|
this[kThenifyDoNotWrap] = true;
|
|
948
|
-
return
|
|
948
|
+
return resolve5(this._server);
|
|
949
949
|
}, reject);
|
|
950
950
|
};
|
|
951
951
|
}
|
|
@@ -1082,12 +1082,12 @@ var require_boot = __commonJS({
|
|
|
1082
1082
|
inherits(Boot, EE);
|
|
1083
1083
|
if ("asyncDispose" in Symbol) {
|
|
1084
1084
|
Boot.prototype[Symbol.asyncDispose] = function() {
|
|
1085
|
-
return new Promise((
|
|
1085
|
+
return new Promise((resolve5, reject) => {
|
|
1086
1086
|
this.close((err) => {
|
|
1087
1087
|
if (err) {
|
|
1088
1088
|
return reject(err);
|
|
1089
1089
|
}
|
|
1090
|
-
|
|
1090
|
+
resolve5();
|
|
1091
1091
|
});
|
|
1092
1092
|
});
|
|
1093
1093
|
};
|
|
@@ -1234,12 +1234,12 @@ var require_boot = __commonJS({
|
|
|
1234
1234
|
throw new AVV_ERR_CALLBACK_NOT_FN("close", typeof func);
|
|
1235
1235
|
}
|
|
1236
1236
|
} else {
|
|
1237
|
-
promise = new Promise(function(
|
|
1237
|
+
promise = new Promise(function(resolve5, reject) {
|
|
1238
1238
|
func = function(err) {
|
|
1239
1239
|
if (err) {
|
|
1240
1240
|
return reject(err);
|
|
1241
1241
|
}
|
|
1242
|
-
|
|
1242
|
+
resolve5();
|
|
1243
1243
|
};
|
|
1244
1244
|
});
|
|
1245
1245
|
}
|
|
@@ -1259,7 +1259,7 @@ var require_boot = __commonJS({
|
|
|
1259
1259
|
queueMicrotask(this.start.bind(this));
|
|
1260
1260
|
return;
|
|
1261
1261
|
}
|
|
1262
|
-
return new Promise((
|
|
1262
|
+
return new Promise((resolve5, reject) => {
|
|
1263
1263
|
this._readyQ.push(readyPromiseCB);
|
|
1264
1264
|
this.start();
|
|
1265
1265
|
const relativeContext = this._current[0].server;
|
|
@@ -1267,7 +1267,7 @@ var require_boot = __commonJS({
|
|
|
1267
1267
|
if (err) {
|
|
1268
1268
|
reject(err);
|
|
1269
1269
|
} else {
|
|
1270
|
-
|
|
1270
|
+
resolve5(relativeContext);
|
|
1271
1271
|
}
|
|
1272
1272
|
process.nextTick(done);
|
|
1273
1273
|
}
|
|
@@ -2542,8 +2542,8 @@ var require_promise = __commonJS({
|
|
|
2542
2542
|
var { kTestInternals } = require_symbols2();
|
|
2543
2543
|
function withResolvers() {
|
|
2544
2544
|
let res, rej;
|
|
2545
|
-
const promise = new Promise((
|
|
2546
|
-
res =
|
|
2545
|
+
const promise = new Promise((resolve5, reject) => {
|
|
2546
|
+
res = resolve5;
|
|
2547
2547
|
rej = reject;
|
|
2548
2548
|
});
|
|
2549
2549
|
return { promise, resolve: res, reject: rej };
|
|
@@ -2642,15 +2642,15 @@ var require_server = __commonJS({
|
|
|
2642
2642
|
if (cb === void 0) {
|
|
2643
2643
|
const listening = listenPromise.call(this, server, listenOptions);
|
|
2644
2644
|
return listening.then((address) => {
|
|
2645
|
-
const { promise, resolve:
|
|
2645
|
+
const { promise, resolve: resolve5 } = PonyPromise.withResolvers();
|
|
2646
2646
|
if (host === "localhost") {
|
|
2647
2647
|
multipleBindings.call(this, server, httpHandler, options, listenOptions, () => {
|
|
2648
2648
|
this[kState].listening = true;
|
|
2649
|
-
|
|
2649
|
+
resolve5(address);
|
|
2650
2650
|
onListenHookRunner(this);
|
|
2651
2651
|
});
|
|
2652
2652
|
} else {
|
|
2653
|
-
|
|
2653
|
+
resolve5(address);
|
|
2654
2654
|
onListenHookRunner(this);
|
|
2655
2655
|
}
|
|
2656
2656
|
return promise;
|
|
@@ -2777,7 +2777,7 @@ var require_server = __commonJS({
|
|
|
2777
2777
|
}
|
|
2778
2778
|
return this.ready().then(() => {
|
|
2779
2779
|
if (this[kState].aborted) return;
|
|
2780
|
-
const { promise, resolve:
|
|
2780
|
+
const { promise, resolve: resolve5, reject } = PonyPromise.withResolvers();
|
|
2781
2781
|
const errEventHandler = (err) => {
|
|
2782
2782
|
cleanup();
|
|
2783
2783
|
this[kState].listening = false;
|
|
@@ -2786,7 +2786,7 @@ var require_server = __commonJS({
|
|
|
2786
2786
|
const listeningEventHandler = () => {
|
|
2787
2787
|
cleanup();
|
|
2788
2788
|
this[kState].listening = true;
|
|
2789
|
-
|
|
2789
|
+
resolve5(logServerAddress.call(
|
|
2790
2790
|
this,
|
|
2791
2791
|
server,
|
|
2792
2792
|
listenOptions.listenTextResolver || defaultResolveServerListeningText
|
|
@@ -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 } = require("worker_threads");
|
|
5492
|
-
var { join:
|
|
5492
|
+
var { join: join21 } = 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"] || join21(__dirname, "lib", "worker.js");
|
|
5544
5544
|
const worker = new Worker(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: createRequire4 } = require("module");
|
|
6009
|
-
var { existsSync:
|
|
6009
|
+
var { existsSync: existsSync19 } = require("node:fs");
|
|
6010
6010
|
var getCallers = require_caller();
|
|
6011
|
-
var { join:
|
|
6011
|
+
var { join: join21, isAbsolute: isAbsolute2, sep: sep3 } = require("node:path");
|
|
6012
6012
|
var { fileURLToPath: fileURLToPath4 } = require("node:url");
|
|
6013
6013
|
var sleep = 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 isAbsolute2(path) && !
|
|
6083
|
+
return isAbsolute2(path) && !existsSync19(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"] || join21(__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 (pipeline2) {
|
|
6182
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
6182
|
+
target = bundlerOverrides["pino-worker"] || join21(__dirname, "worker.js");
|
|
6183
6183
|
options.pipelines = [pipeline2.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 join21(__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 join21 = ",";
|
|
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
|
+
join21 = `,
|
|
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 += join21;
|
|
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 += `${join21}"... ${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
|
+
join21 = `,
|
|
7235
7235
|
${indentation}`;
|
|
7236
7236
|
whitespace = " ";
|
|
7237
7237
|
}
|
|
@@ -7245,13 +7245,13 @@ ${indentation}`;
|
|
|
7245
7245
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
7246
7246
|
if (tmp !== void 0) {
|
|
7247
7247
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
7248
|
-
separator =
|
|
7248
|
+
separator = join21;
|
|
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 = join21;
|
|
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 join21 = ",";
|
|
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
|
+
join21 = `,
|
|
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 += join21;
|
|
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 += `${join21}"... ${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
|
+
join21 = `,
|
|
7336
7336
|
${indentation}`;
|
|
7337
7337
|
whitespace = " ";
|
|
7338
7338
|
}
|
|
@@ -7341,7 +7341,7 @@ ${indentation}`;
|
|
|
7341
7341
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
7342
7342
|
if (tmp !== void 0) {
|
|
7343
7343
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
7344
|
-
separator =
|
|
7344
|
+
separator = join21;
|
|
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 join22 = `,
|
|
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 += join22;
|
|
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 += `${join22}"... ${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 join21 = `,
|
|
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, join21, maximumBreadth);
|
|
7438
7438
|
keys = keys.slice(value.length);
|
|
7439
7439
|
maximumPropertiesToStringify -= value.length;
|
|
7440
|
-
separator =
|
|
7440
|
+
separator = join21;
|
|
7441
7441
|
}
|
|
7442
7442
|
if (deterministic) {
|
|
7443
7443
|
keys = sort(keys, comparator);
|
|
@@ -7448,13 +7448,13 @@ ${indentation}`;
|
|
|
7448
7448
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
7449
7449
|
if (tmp !== void 0) {
|
|
7450
7450
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
7451
|
-
separator =
|
|
7451
|
+
separator = join21;
|
|
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 = join21;
|
|
7458
7458
|
}
|
|
7459
7459
|
if (separator !== "") {
|
|
7460
7460
|
res = `
|
|
@@ -15309,7 +15309,7 @@ var require_compile = __commonJS({
|
|
|
15309
15309
|
const schOrFunc = root.refs[ref];
|
|
15310
15310
|
if (schOrFunc)
|
|
15311
15311
|
return schOrFunc;
|
|
15312
|
-
let _sch =
|
|
15312
|
+
let _sch = resolve5.call(this, root, ref);
|
|
15313
15313
|
if (_sch === void 0) {
|
|
15314
15314
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
15315
15315
|
const { schemaId } = this.opts;
|
|
@@ -15336,7 +15336,7 @@ var require_compile = __commonJS({
|
|
|
15336
15336
|
function sameSchemaEnv(s1, s2) {
|
|
15337
15337
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
15338
15338
|
}
|
|
15339
|
-
function
|
|
15339
|
+
function resolve5(root, ref) {
|
|
15340
15340
|
let sch;
|
|
15341
15341
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
15342
15342
|
ref = sch;
|
|
@@ -15967,7 +15967,7 @@ var require_fast_uri = __commonJS({
|
|
|
15967
15967
|
}
|
|
15968
15968
|
return uri;
|
|
15969
15969
|
}
|
|
15970
|
-
function
|
|
15970
|
+
function resolve5(baseURI, relativeURI, options) {
|
|
15971
15971
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
15972
15972
|
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
15973
15973
|
schemelessOptions.skipEscape = true;
|
|
@@ -16225,7 +16225,7 @@ var require_fast_uri = __commonJS({
|
|
|
16225
16225
|
var fastUri = {
|
|
16226
16226
|
SCHEMES,
|
|
16227
16227
|
normalize: normalize2,
|
|
16228
|
-
resolve:
|
|
16228
|
+
resolve: resolve5,
|
|
16229
16229
|
resolveComponent,
|
|
16230
16230
|
equal,
|
|
16231
16231
|
serialize,
|
|
@@ -32061,7 +32061,7 @@ var require_parse_url = __commonJS({
|
|
|
32061
32061
|
var require_form_data = __commonJS({
|
|
32062
32062
|
"node_modules/light-my-request/lib/form-data.js"(exports2, module2) {
|
|
32063
32063
|
"use strict";
|
|
32064
|
-
var { randomUUID:
|
|
32064
|
+
var { randomUUID: randomUUID5 } = require("node:crypto");
|
|
32065
32065
|
var { Readable: Readable3 } = require("node:stream");
|
|
32066
32066
|
var textEncoder;
|
|
32067
32067
|
function isFormDataLike(payload) {
|
|
@@ -32069,7 +32069,7 @@ var require_form_data = __commonJS({
|
|
|
32069
32069
|
}
|
|
32070
32070
|
function formDataToStream(formdata) {
|
|
32071
32071
|
textEncoder = textEncoder ?? new TextEncoder();
|
|
32072
|
-
const boundary = `----formdata-${
|
|
32072
|
+
const boundary = `----formdata-${randomUUID5()}`;
|
|
32073
32073
|
const prefix = `--${boundary}\r
|
|
32074
32074
|
Content-Disposition: form-data`;
|
|
32075
32075
|
const escape2 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
|
@@ -33572,9 +33572,9 @@ var require_light_my_request = __commonJS({
|
|
|
33572
33572
|
const res = new Response(req, callback);
|
|
33573
33573
|
return makeRequest(dispatchFunc, server, req, res);
|
|
33574
33574
|
} else {
|
|
33575
|
-
return new Promise((
|
|
33575
|
+
return new Promise((resolve5, reject) => {
|
|
33576
33576
|
const req = new RequestConstructor(options);
|
|
33577
|
-
const res = new Response(req,
|
|
33577
|
+
const res = new Response(req, resolve5, reject);
|
|
33578
33578
|
makeRequest(dispatchFunc, server, req, res);
|
|
33579
33579
|
});
|
|
33580
33580
|
}
|
|
@@ -37706,10 +37706,10 @@ var require_commonjs4 = __commonJS({
|
|
|
37706
37706
|
* Return a void Promise that resolves once the stream ends.
|
|
37707
37707
|
*/
|
|
37708
37708
|
async promise() {
|
|
37709
|
-
return new Promise((
|
|
37709
|
+
return new Promise((resolve5, reject) => {
|
|
37710
37710
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
37711
37711
|
this.on("error", (er) => reject(er));
|
|
37712
|
-
this.on("end", () =>
|
|
37712
|
+
this.on("end", () => resolve5());
|
|
37713
37713
|
});
|
|
37714
37714
|
}
|
|
37715
37715
|
/**
|
|
@@ -37733,7 +37733,7 @@ var require_commonjs4 = __commonJS({
|
|
|
37733
37733
|
return Promise.resolve({ done: false, value: res });
|
|
37734
37734
|
if (this[EOF])
|
|
37735
37735
|
return stop();
|
|
37736
|
-
let
|
|
37736
|
+
let resolve5;
|
|
37737
37737
|
let reject;
|
|
37738
37738
|
const onerr = (er) => {
|
|
37739
37739
|
this.off("data", ondata);
|
|
@@ -37747,19 +37747,19 @@ var require_commonjs4 = __commonJS({
|
|
|
37747
37747
|
this.off("end", onend);
|
|
37748
37748
|
this.off(DESTROYED, ondestroy);
|
|
37749
37749
|
this.pause();
|
|
37750
|
-
|
|
37750
|
+
resolve5({ value, done: !!this[EOF] });
|
|
37751
37751
|
};
|
|
37752
37752
|
const onend = () => {
|
|
37753
37753
|
this.off("error", onerr);
|
|
37754
37754
|
this.off("data", ondata);
|
|
37755
37755
|
this.off(DESTROYED, ondestroy);
|
|
37756
37756
|
stop();
|
|
37757
|
-
|
|
37757
|
+
resolve5({ done: true, value: void 0 });
|
|
37758
37758
|
};
|
|
37759
37759
|
const ondestroy = () => onerr(new Error("stream destroyed"));
|
|
37760
37760
|
return new Promise((res2, rej) => {
|
|
37761
37761
|
reject = rej;
|
|
37762
|
-
|
|
37762
|
+
resolve5 = res2;
|
|
37763
37763
|
this.once(DESTROYED, ondestroy);
|
|
37764
37764
|
this.once("error", onerr);
|
|
37765
37765
|
this.once("end", onend);
|
|
@@ -38779,9 +38779,9 @@ var require_commonjs5 = __commonJS({
|
|
|
38779
38779
|
if (this.#asyncReaddirInFlight) {
|
|
38780
38780
|
await this.#asyncReaddirInFlight;
|
|
38781
38781
|
} else {
|
|
38782
|
-
let
|
|
38782
|
+
let resolve5 = () => {
|
|
38783
38783
|
};
|
|
38784
|
-
this.#asyncReaddirInFlight = new Promise((res) =>
|
|
38784
|
+
this.#asyncReaddirInFlight = new Promise((res) => resolve5 = res);
|
|
38785
38785
|
try {
|
|
38786
38786
|
for (const e of await this.#fs.promises.readdir(fullpath, {
|
|
38787
38787
|
withFileTypes: true
|
|
@@ -38794,7 +38794,7 @@ var require_commonjs5 = __commonJS({
|
|
|
38794
38794
|
children.provisional = 0;
|
|
38795
38795
|
}
|
|
38796
38796
|
this.#asyncReaddirInFlight = void 0;
|
|
38797
|
-
|
|
38797
|
+
resolve5();
|
|
38798
38798
|
}
|
|
38799
38799
|
return children.slice(0, children.provisional);
|
|
38800
38800
|
}
|
|
@@ -41991,9 +41991,9 @@ var require_send = __commonJS({
|
|
|
41991
41991
|
var { parseTokenList } = require_parseTokenList();
|
|
41992
41992
|
var { createHttpError } = require_createHttpError();
|
|
41993
41993
|
var extname2 = path.extname;
|
|
41994
|
-
var
|
|
41994
|
+
var join21 = path.join;
|
|
41995
41995
|
var normalize2 = path.normalize;
|
|
41996
|
-
var
|
|
41996
|
+
var resolve5 = path.resolve;
|
|
41997
41997
|
var sep3 = path.sep;
|
|
41998
41998
|
var Readable3 = stream.Readable;
|
|
41999
41999
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
@@ -42040,7 +42040,7 @@ var require_send = __commonJS({
|
|
|
42040
42040
|
const lastModified = options.lastModified !== void 0 ? Boolean(options.lastModified) : true;
|
|
42041
42041
|
const maxage = normalizeMaxAge(options.maxAge ?? options.maxage);
|
|
42042
42042
|
const maxContentRangeChunkSize = options.maxContentRangeChunkSize !== void 0 ? Number(options.maxContentRangeChunkSize) : null;
|
|
42043
|
-
const root = options.root ?
|
|
42043
|
+
const root = options.root ? resolve5(options.root) : null;
|
|
42044
42044
|
const highWaterMark = Number.isSafeInteger(options.highWaterMark) && options.highWaterMark > 0 ? options.highWaterMark : null;
|
|
42045
42045
|
return {
|
|
42046
42046
|
acceptRanges,
|
|
@@ -42078,14 +42078,14 @@ var require_send = __commonJS({
|
|
|
42078
42078
|
return { statusCode: 403 };
|
|
42079
42079
|
}
|
|
42080
42080
|
parts = path2.split(sep3);
|
|
42081
|
-
path2 = normalize2(
|
|
42081
|
+
path2 = normalize2(join21(root, path2));
|
|
42082
42082
|
} else {
|
|
42083
42083
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
42084
42084
|
debug('malicious path "%s"', path2);
|
|
42085
42085
|
return { statusCode: 403 };
|
|
42086
42086
|
}
|
|
42087
42087
|
parts = normalize2(path2).split(sep3);
|
|
42088
|
-
path2 =
|
|
42088
|
+
path2 = resolve5(path2);
|
|
42089
42089
|
}
|
|
42090
42090
|
return { path: path2, parts };
|
|
42091
42091
|
}
|
|
@@ -42181,9 +42181,9 @@ var require_send = __commonJS({
|
|
|
42181
42181
|
);
|
|
42182
42182
|
}
|
|
42183
42183
|
function tryStat(path2) {
|
|
42184
|
-
return new Promise((
|
|
42184
|
+
return new Promise((resolve6) => {
|
|
42185
42185
|
fs.stat(path2, function onstat(error, stat4) {
|
|
42186
|
-
|
|
42186
|
+
resolve6({ error, stat: stat4 });
|
|
42187
42187
|
});
|
|
42188
42188
|
});
|
|
42189
42189
|
}
|
|
@@ -42361,7 +42361,7 @@ var require_send = __commonJS({
|
|
|
42361
42361
|
let err;
|
|
42362
42362
|
for (let i = 0; i < options.index.length; i++) {
|
|
42363
42363
|
const index = options.index[i];
|
|
42364
|
-
const p =
|
|
42364
|
+
const p = join21(path2, index);
|
|
42365
42365
|
const { error, stat: stat4 } = await tryStat(p);
|
|
42366
42366
|
if (error) {
|
|
42367
42367
|
err = error;
|
|
@@ -43012,7 +43012,7 @@ var require_static = __commonJS({
|
|
|
43012
43012
|
"use strict";
|
|
43013
43013
|
var path = require("node:path");
|
|
43014
43014
|
var { fileURLToPath: fileURLToPath4 } = require("node:url");
|
|
43015
|
-
var { statSync:
|
|
43015
|
+
var { statSync: statSync7 } = require("node:fs");
|
|
43016
43016
|
var { glob } = require_commonjs6();
|
|
43017
43017
|
var fp = require_plugin2();
|
|
43018
43018
|
var send = require_send2();
|
|
@@ -43375,7 +43375,7 @@ var require_static = __commonJS({
|
|
|
43375
43375
|
}
|
|
43376
43376
|
let pathStat;
|
|
43377
43377
|
try {
|
|
43378
|
-
pathStat =
|
|
43378
|
+
pathStat = statSync7(rootPath);
|
|
43379
43379
|
} catch (e) {
|
|
43380
43380
|
if (e.code === "ENOENT") {
|
|
43381
43381
|
fastify.log.warn(`"root" path "${rootPath}" must exist`);
|
|
@@ -43399,7 +43399,7 @@ var require_static = __commonJS({
|
|
|
43399
43399
|
return indexFiles.find((filename) => {
|
|
43400
43400
|
const p = path.join(root, pathname, filename);
|
|
43401
43401
|
try {
|
|
43402
|
-
const stats =
|
|
43402
|
+
const stats = statSync7(p);
|
|
43403
43403
|
return !stats.isDirectory();
|
|
43404
43404
|
} catch {
|
|
43405
43405
|
return false;
|
|
@@ -50827,9 +50827,9 @@ var import_node_readline2 = require("node:readline");
|
|
|
50827
50827
|
|
|
50828
50828
|
// index.ts
|
|
50829
50829
|
var import_node_url3 = require("node:url");
|
|
50830
|
-
var
|
|
50831
|
-
var
|
|
50832
|
-
var
|
|
50830
|
+
var import_node_path19 = require("node:path");
|
|
50831
|
+
var import_node_os13 = require("node:os");
|
|
50832
|
+
var import_node_fs20 = require("node:fs");
|
|
50833
50833
|
var import_node_child_process6 = require("node:child_process");
|
|
50834
50834
|
|
|
50835
50835
|
// log.mjs
|
|
@@ -50878,6 +50878,7 @@ var import_node_child_process = require("node:child_process");
|
|
|
50878
50878
|
var import_node_fs4 = require("node:fs");
|
|
50879
50879
|
var import_node_path3 = require("node:path");
|
|
50880
50880
|
var import_node_os3 = require("node:os");
|
|
50881
|
+
var import_node_crypto2 = require("node:crypto");
|
|
50881
50882
|
var import_node_module = require("node:module");
|
|
50882
50883
|
|
|
50883
50884
|
// app-reader.ts
|
|
@@ -51183,6 +51184,12 @@ var AwareError = class extends Error {
|
|
|
51183
51184
|
}
|
|
51184
51185
|
detail;
|
|
51185
51186
|
};
|
|
51187
|
+
var AwareUnsupportedError = class extends AwareError {
|
|
51188
|
+
constructor(message, detail) {
|
|
51189
|
+
super(message, detail);
|
|
51190
|
+
this.name = "AwareUnsupportedError";
|
|
51191
|
+
}
|
|
51192
|
+
};
|
|
51186
51193
|
function resolveInvoker() {
|
|
51187
51194
|
const envDir = process.env.AWARE_CLI_DIR;
|
|
51188
51195
|
if (envDir && (0, import_node_fs4.existsSync)((0, import_node_path3.join)(envDir, "scripts/bin/aware.js"))) {
|
|
@@ -51225,7 +51232,7 @@ function runRaw(args, onSpawn) {
|
|
|
51225
51232
|
if (bad !== void 0) throw new AwareError(`refusing to pass unsafe argument to shell: ${bad}`);
|
|
51226
51233
|
}
|
|
51227
51234
|
const argv = [...preArgs, ...args];
|
|
51228
|
-
return new Promise((
|
|
51235
|
+
return new Promise((resolve5, reject) => {
|
|
51229
51236
|
const child = (0, import_node_child_process.spawn)(bin, argv, { shell: invoker.shell, windowsHide: true });
|
|
51230
51237
|
onSpawn?.(child);
|
|
51231
51238
|
let stdout = "";
|
|
@@ -51243,7 +51250,7 @@ function runRaw(args, onSpawn) {
|
|
|
51243
51250
|
});
|
|
51244
51251
|
child.on("close", (code) => {
|
|
51245
51252
|
clearTimeout(timer);
|
|
51246
|
-
|
|
51253
|
+
resolve5({ code: code ?? -1, stdout, stderr });
|
|
51247
51254
|
});
|
|
51248
51255
|
});
|
|
51249
51256
|
}
|
|
@@ -51257,7 +51264,7 @@ function runRawWithEnv(args, env2, timeoutMs) {
|
|
|
51257
51264
|
}
|
|
51258
51265
|
const argv = [...preArgs, ...args];
|
|
51259
51266
|
const limit = timeoutMs ?? RUN_TIMEOUT_MS;
|
|
51260
|
-
return new Promise((
|
|
51267
|
+
return new Promise((resolve5, reject) => {
|
|
51261
51268
|
const child = (0, import_node_child_process.spawn)(bin, argv, { shell: invoker.shell, windowsHide: true, env: env2 ?? process.env });
|
|
51262
51269
|
let stdout = "";
|
|
51263
51270
|
let stderr = "";
|
|
@@ -51274,7 +51281,7 @@ function runRawWithEnv(args, env2, timeoutMs) {
|
|
|
51274
51281
|
});
|
|
51275
51282
|
child.on("close", (code) => {
|
|
51276
51283
|
clearTimeout(timer);
|
|
51277
|
-
|
|
51284
|
+
resolve5({ code: code ?? -1, stdout, stderr });
|
|
51278
51285
|
});
|
|
51279
51286
|
});
|
|
51280
51287
|
}
|
|
@@ -51324,7 +51331,7 @@ async function execTekla(code, opts = {}) {
|
|
|
51324
51331
|
args: opts.args ?? {}
|
|
51325
51332
|
});
|
|
51326
51333
|
const timeoutMs = opts.debug ? 15 * 6e4 : RUN_TIMEOUT_MS;
|
|
51327
|
-
return new Promise((
|
|
51334
|
+
return new Promise((resolve5, reject) => {
|
|
51328
51335
|
const child = (0, import_node_child_process.spawn)(bin, ["exec", "--version", version, "--json-stdin"], { windowsHide: true });
|
|
51329
51336
|
let stdout = "";
|
|
51330
51337
|
let stderr = "";
|
|
@@ -51352,7 +51359,7 @@ async function execTekla(code, opts = {}) {
|
|
|
51352
51359
|
})
|
|
51353
51360
|
);
|
|
51354
51361
|
}
|
|
51355
|
-
|
|
51362
|
+
resolve5(parsed);
|
|
51356
51363
|
});
|
|
51357
51364
|
child.stdin.write(payload);
|
|
51358
51365
|
child.stdin.end();
|
|
@@ -51423,17 +51430,31 @@ function latestTracePath(id, logsRoot = LOGS_DIR) {
|
|
|
51423
51430
|
}
|
|
51424
51431
|
return best ? best.path : null;
|
|
51425
51432
|
}
|
|
51426
|
-
function
|
|
51433
|
+
function readTail(path, maxBytes) {
|
|
51434
|
+
const size = (0, import_node_fs4.statSync)(path).size;
|
|
51435
|
+
if (size <= maxBytes) return { text: (0, import_node_fs4.readFileSync)(path, "utf8"), truncated: false };
|
|
51436
|
+
const fd = (0, import_node_fs4.openSync)(path, "r");
|
|
51437
|
+
try {
|
|
51438
|
+
const buf = Buffer.alloc(maxBytes);
|
|
51439
|
+
const read = (0, import_node_fs4.readSync)(fd, buf, 0, maxBytes, size - maxBytes);
|
|
51440
|
+
const nl = buf.indexOf(10, 0);
|
|
51441
|
+
const start = nl >= 0 && nl + 1 <= read ? nl + 1 : 0;
|
|
51442
|
+
return { text: buf.subarray(start, read).toString("utf8"), truncated: true };
|
|
51443
|
+
} finally {
|
|
51444
|
+
(0, import_node_fs4.closeSync)(fd);
|
|
51445
|
+
}
|
|
51446
|
+
}
|
|
51447
|
+
function readLatestTrace(id, logsRoot = LOGS_DIR, maxBytes) {
|
|
51427
51448
|
const p = latestTracePath(id, logsRoot);
|
|
51428
51449
|
if (!p) return null;
|
|
51429
|
-
let
|
|
51450
|
+
let read;
|
|
51430
51451
|
try {
|
|
51431
|
-
|
|
51452
|
+
read = maxBytes && maxBytes > 0 ? readTail(p, maxBytes) : { text: (0, import_node_fs4.readFileSync)(p, "utf8"), truncated: false };
|
|
51432
51453
|
} catch {
|
|
51433
51454
|
return null;
|
|
51434
51455
|
}
|
|
51435
51456
|
const runId = p.split(/[\\/]/).pop()?.replace(/\.jsonl$/, "") ?? "";
|
|
51436
|
-
return { runId, path: p, text };
|
|
51457
|
+
return { runId, path: p, text: read.text, truncated: read.truncated };
|
|
51437
51458
|
}
|
|
51438
51459
|
function startTrigger(id, opts = {}) {
|
|
51439
51460
|
assertId(id);
|
|
@@ -51611,6 +51632,19 @@ function parseAgentInstallOutput(stdout) {
|
|
|
51611
51632
|
function isAgentInstalled(agents, id) {
|
|
51612
51633
|
return agents.some((a) => a.id === id);
|
|
51613
51634
|
}
|
|
51635
|
+
function agentInvokeArgv(agent, command, inputsRef) {
|
|
51636
|
+
assertId(agent);
|
|
51637
|
+
if (!APP_ID.test(command)) throw new AwareError(`invalid agent command: ${JSON.stringify(command)}`);
|
|
51638
|
+
const args = ["agent", "invoke", agent, command];
|
|
51639
|
+
if (inputsRef !== void 0) args.push("--inputs", inputsRef);
|
|
51640
|
+
return args;
|
|
51641
|
+
}
|
|
51642
|
+
function isInvokeUnsupported(detail) {
|
|
51643
|
+
if (!detail || typeof detail !== "object") return false;
|
|
51644
|
+
const d = detail;
|
|
51645
|
+
const text = [d.stdout, d.stderr].filter((s) => typeof s === "string").join("\n");
|
|
51646
|
+
return /unrecognized subcommand|unknown subcommand/i.test(text);
|
|
51647
|
+
}
|
|
51614
51648
|
var inFlightConnects = /* @__PURE__ */ new Map();
|
|
51615
51649
|
function cancelAllConnects() {
|
|
51616
51650
|
for (const cancel of inFlightConnects.values()) cancel();
|
|
@@ -51623,7 +51657,7 @@ function connectDeviceCode(id, onEvent) {
|
|
|
51623
51657
|
if (!bin) throw new AwareError("aware CLI invoker not resolved");
|
|
51624
51658
|
inFlightConnects.get(id)?.();
|
|
51625
51659
|
const argv = [...preArgs, "connect", id, "--device-code", "--json"];
|
|
51626
|
-
return new Promise((
|
|
51660
|
+
return new Promise((resolve5, reject) => {
|
|
51627
51661
|
const child = (0, import_node_child_process.spawn)(bin, argv, { shell: invoker.shell, windowsHide: true });
|
|
51628
51662
|
let buf = "";
|
|
51629
51663
|
let gotPrompt = false;
|
|
@@ -51649,7 +51683,7 @@ function connectDeviceCode(id, onEvent) {
|
|
|
51649
51683
|
}
|
|
51650
51684
|
if (!gotPrompt && obj.phase === "prompt" && typeof obj.user_code === "string") {
|
|
51651
51685
|
gotPrompt = true;
|
|
51652
|
-
|
|
51686
|
+
resolve5({ prompt: obj, cancel });
|
|
51653
51687
|
} else {
|
|
51654
51688
|
onEvent(obj);
|
|
51655
51689
|
}
|
|
@@ -51733,6 +51767,43 @@ var aware = {
|
|
|
51733
51767
|
const { data } = await runJson(["agent", "describe", assertId(id)]);
|
|
51734
51768
|
return data;
|
|
51735
51769
|
},
|
|
51770
|
+
/**
|
|
51771
|
+
* Invoke a BUILTIN agent command directly (`aware agent invoke <agent> <command>
|
|
51772
|
+
* --inputs @file --json`, CLI ≥ 0.63) and return the envelope's `data` — e.g.
|
|
51773
|
+
* `agentInvoke('ui','validate',{descriptor})` for Custom Panels validation.
|
|
51774
|
+
* Inputs always travel via a temp file (`--inputs @path`): inline JSON would trip
|
|
51775
|
+
* the shell-injection guard on the bare-PATH Windows fallback (quotes/braces are
|
|
51776
|
+
* SHELL_META) and a large descriptor could blow cmd.exe's argv limit. Throws
|
|
51777
|
+
* AwareUnsupportedError on a pre-0.63 CLI so callers can degrade ("update AWARE").
|
|
51778
|
+
*/
|
|
51779
|
+
async agentInvoke(agent, command, inputs) {
|
|
51780
|
+
let inputsFile = null;
|
|
51781
|
+
try {
|
|
51782
|
+
let ref;
|
|
51783
|
+
if (inputs !== void 0) {
|
|
51784
|
+
inputsFile = (0, import_node_path3.join)((0, import_node_os3.tmpdir)(), `floless-agent-inputs-${(0, import_node_crypto2.randomUUID)()}.json`);
|
|
51785
|
+
(0, import_node_fs4.writeFileSync)(inputsFile, JSON.stringify(inputs));
|
|
51786
|
+
ref = `@${inputsFile}`;
|
|
51787
|
+
}
|
|
51788
|
+
const { data } = await runJson(agentInvokeArgv(agent, command, ref));
|
|
51789
|
+
return data;
|
|
51790
|
+
} catch (err) {
|
|
51791
|
+
if (err instanceof AwareError && isInvokeUnsupported(err.detail)) {
|
|
51792
|
+
throw new AwareUnsupportedError(
|
|
51793
|
+
`aware CLI does not support \`agent invoke\` (needs \u2265 0.63) \u2014 update AWARE`,
|
|
51794
|
+
err.detail
|
|
51795
|
+
);
|
|
51796
|
+
}
|
|
51797
|
+
throw err;
|
|
51798
|
+
} finally {
|
|
51799
|
+
if (inputsFile) {
|
|
51800
|
+
try {
|
|
51801
|
+
(0, import_node_fs4.rmSync)(inputsFile);
|
|
51802
|
+
} catch {
|
|
51803
|
+
}
|
|
51804
|
+
}
|
|
51805
|
+
}
|
|
51806
|
+
},
|
|
51736
51807
|
/**
|
|
51737
51808
|
* Graft: build an agent from a foreign source (`aware build agent --from-*`).
|
|
51738
51809
|
* When `awareHome` is set the spawn writes into that staging dir (AWARE_HOME is
|
|
@@ -51875,6 +51946,170 @@ var aware = {
|
|
|
51875
51946
|
connectList
|
|
51876
51947
|
};
|
|
51877
51948
|
|
|
51949
|
+
// extensions-store.ts
|
|
51950
|
+
var import_node_fs5 = require("node:fs");
|
|
51951
|
+
var import_node_os4 = require("node:os");
|
|
51952
|
+
var import_node_path4 = require("node:path");
|
|
51953
|
+
var ROOT = process.env.FLOLESS_HOME ?? (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".floless");
|
|
51954
|
+
var uiDir = (0, import_node_path4.join)(ROOT, "ui");
|
|
51955
|
+
var extensionsFile = (0, import_node_path4.join)(uiDir, "extensions.json");
|
|
51956
|
+
var HISTORY_DIR = (0, import_node_path4.join)(uiDir, "history");
|
|
51957
|
+
var HISTORY_KEEP = 20;
|
|
51958
|
+
function ensureUiDir() {
|
|
51959
|
+
if (!(0, import_node_fs5.existsSync)(uiDir)) (0, import_node_fs5.mkdirSync)(uiDir, { recursive: true });
|
|
51960
|
+
}
|
|
51961
|
+
function ensureHistoryDir() {
|
|
51962
|
+
if (!(0, import_node_fs5.existsSync)(HISTORY_DIR)) (0, import_node_fs5.mkdirSync)(HISTORY_DIR, { recursive: true });
|
|
51963
|
+
}
|
|
51964
|
+
function readExtensionsText() {
|
|
51965
|
+
try {
|
|
51966
|
+
return (0, import_node_fs5.readFileSync)(extensionsFile, "utf8");
|
|
51967
|
+
} catch {
|
|
51968
|
+
return null;
|
|
51969
|
+
}
|
|
51970
|
+
}
|
|
51971
|
+
function readExtensions() {
|
|
51972
|
+
const text = readExtensionsText();
|
|
51973
|
+
if (text === null) return null;
|
|
51974
|
+
try {
|
|
51975
|
+
const parsed = JSON.parse(text);
|
|
51976
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
51977
|
+
} catch {
|
|
51978
|
+
return null;
|
|
51979
|
+
}
|
|
51980
|
+
}
|
|
51981
|
+
function descriptorPanels(d) {
|
|
51982
|
+
if (!d || !Array.isArray(d.panels)) return [];
|
|
51983
|
+
return d.panels.filter((p) => !!p && typeof p === "object" && !Array.isArray(p));
|
|
51984
|
+
}
|
|
51985
|
+
function panelsCountOf(text) {
|
|
51986
|
+
try {
|
|
51987
|
+
const parsed = JSON.parse(text);
|
|
51988
|
+
return parsed && typeof parsed === "object" && Array.isArray(parsed.panels) ? parsed.panels.length : 0;
|
|
51989
|
+
} catch {
|
|
51990
|
+
return 0;
|
|
51991
|
+
}
|
|
51992
|
+
}
|
|
51993
|
+
function historyFileName(now) {
|
|
51994
|
+
const base = now.toISOString().replace(/[:.]/g, "-");
|
|
51995
|
+
let name = `${base}.json`;
|
|
51996
|
+
for (let i = 2; (0, import_node_fs5.existsSync)((0, import_node_path4.join)(HISTORY_DIR, name)); i++) name = `${base}-${i}.json`;
|
|
51997
|
+
return name;
|
|
51998
|
+
}
|
|
51999
|
+
function timestampFromName(file) {
|
|
52000
|
+
const m = /^(\d{4}-\d{2}-\d{2})T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z(?:-\d+)?\.json$/.exec(file);
|
|
52001
|
+
return m ? `${m[1]}T${m[2]}:${m[3]}:${m[4]}.${m[5]}Z` : null;
|
|
52002
|
+
}
|
|
52003
|
+
function historyFiles() {
|
|
52004
|
+
if (!(0, import_node_fs5.existsSync)(HISTORY_DIR)) return [];
|
|
52005
|
+
try {
|
|
52006
|
+
return (0, import_node_fs5.readdirSync)(HISTORY_DIR).filter((f) => f.endsWith(".json")).sort();
|
|
52007
|
+
} catch {
|
|
52008
|
+
return [];
|
|
52009
|
+
}
|
|
52010
|
+
}
|
|
52011
|
+
function pruneHistory() {
|
|
52012
|
+
const files = historyFiles();
|
|
52013
|
+
for (const f of files.slice(0, Math.max(0, files.length - HISTORY_KEEP))) {
|
|
52014
|
+
try {
|
|
52015
|
+
(0, import_node_fs5.rmSync)((0, import_node_path4.join)(HISTORY_DIR, f));
|
|
52016
|
+
} catch {
|
|
52017
|
+
}
|
|
52018
|
+
}
|
|
52019
|
+
}
|
|
52020
|
+
function snapshotExtensions(content) {
|
|
52021
|
+
const text = content !== void 0 ? content : readExtensionsText();
|
|
52022
|
+
if (text === null) return null;
|
|
52023
|
+
const files = historyFiles();
|
|
52024
|
+
const newest = files[files.length - 1];
|
|
52025
|
+
if (newest) {
|
|
52026
|
+
try {
|
|
52027
|
+
if ((0, import_node_fs5.readFileSync)((0, import_node_path4.join)(HISTORY_DIR, newest), "utf8") === text) return (0, import_node_path4.join)(HISTORY_DIR, newest);
|
|
52028
|
+
} catch {
|
|
52029
|
+
}
|
|
52030
|
+
}
|
|
52031
|
+
ensureHistoryDir();
|
|
52032
|
+
const path = (0, import_node_path4.join)(HISTORY_DIR, historyFileName(/* @__PURE__ */ new Date()));
|
|
52033
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
52034
|
+
(0, import_node_fs5.writeFileSync)(tmp, text);
|
|
52035
|
+
(0, import_node_fs5.renameSync)(tmp, path);
|
|
52036
|
+
pruneHistory();
|
|
52037
|
+
return path;
|
|
52038
|
+
}
|
|
52039
|
+
function listHistory() {
|
|
52040
|
+
return historyFiles().reverse().map((f) => {
|
|
52041
|
+
let ts = timestampFromName(f);
|
|
52042
|
+
if (!ts) {
|
|
52043
|
+
try {
|
|
52044
|
+
ts = (0, import_node_fs5.statSync)((0, import_node_path4.join)(HISTORY_DIR, f)).mtime.toISOString();
|
|
52045
|
+
} catch {
|
|
52046
|
+
ts = "";
|
|
52047
|
+
}
|
|
52048
|
+
}
|
|
52049
|
+
let count = 0;
|
|
52050
|
+
try {
|
|
52051
|
+
count = panelsCountOf((0, import_node_fs5.readFileSync)((0, import_node_path4.join)(HISTORY_DIR, f), "utf8"));
|
|
52052
|
+
} catch {
|
|
52053
|
+
}
|
|
52054
|
+
return { timestamp: ts ?? "", panelsCount: count };
|
|
52055
|
+
});
|
|
52056
|
+
}
|
|
52057
|
+
function writeExtensionsText(text) {
|
|
52058
|
+
ensureUiDir();
|
|
52059
|
+
const tmp = `${extensionsFile}.${process.pid}.tmp`;
|
|
52060
|
+
(0, import_node_fs5.writeFileSync)(tmp, text);
|
|
52061
|
+
(0, import_node_fs5.renameSync)(tmp, extensionsFile);
|
|
52062
|
+
}
|
|
52063
|
+
function undoExtensions() {
|
|
52064
|
+
const current = readExtensionsText();
|
|
52065
|
+
const files = historyFiles().reverse();
|
|
52066
|
+
let target = null;
|
|
52067
|
+
for (const f of files) {
|
|
52068
|
+
try {
|
|
52069
|
+
const text = (0, import_node_fs5.readFileSync)((0, import_node_path4.join)(HISTORY_DIR, f), "utf8");
|
|
52070
|
+
if (text !== current) {
|
|
52071
|
+
target = text;
|
|
52072
|
+
break;
|
|
52073
|
+
}
|
|
52074
|
+
} catch {
|
|
52075
|
+
}
|
|
52076
|
+
}
|
|
52077
|
+
if (target === null) return { restored: false, descriptor: readExtensions() };
|
|
52078
|
+
if (current !== null) snapshotExtensions(current);
|
|
52079
|
+
writeExtensionsText(target);
|
|
52080
|
+
return { restored: true, descriptor: readExtensions() };
|
|
52081
|
+
}
|
|
52082
|
+
function resetExtensions() {
|
|
52083
|
+
const current = readExtensionsText();
|
|
52084
|
+
if (current === null) return { reset: false };
|
|
52085
|
+
snapshotExtensions(current);
|
|
52086
|
+
try {
|
|
52087
|
+
(0, import_node_fs5.rmSync)(extensionsFile);
|
|
52088
|
+
} catch {
|
|
52089
|
+
}
|
|
52090
|
+
return { reset: true };
|
|
52091
|
+
}
|
|
52092
|
+
|
|
52093
|
+
// ui-validation.ts
|
|
52094
|
+
function isUiAgentMissing(err) {
|
|
52095
|
+
if (!(err instanceof AwareError)) return /not installed/i.test(String(err));
|
|
52096
|
+
const detail = err.detail ?? {};
|
|
52097
|
+
const stdout = typeof detail.stdout === "string" ? detail.stdout : "";
|
|
52098
|
+
const stderr = typeof detail.stderr === "string" ? detail.stderr : "";
|
|
52099
|
+
const text = `${err.message} ${stdout} ${stderr}`;
|
|
52100
|
+
return /not installed/i.test(text);
|
|
52101
|
+
}
|
|
52102
|
+
function classifyValidateError(err) {
|
|
52103
|
+
if (err instanceof AwareUnsupportedError) {
|
|
52104
|
+
return { valid: null, note: "aware CLI without ui agent \u2014 update AWARE" };
|
|
52105
|
+
}
|
|
52106
|
+
if (isUiAgentMissing(err)) {
|
|
52107
|
+
return { valid: null, note: "AWARE ui agent is installing \u2014 this validates itself in a moment", installing: true };
|
|
52108
|
+
}
|
|
52109
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
52110
|
+
return { valid: false, errors: [`Validation failed: ${msg}`], unexpected: true };
|
|
52111
|
+
}
|
|
52112
|
+
|
|
51878
52113
|
// bootstrap.ts
|
|
51879
52114
|
var VERSION_RE = /^\d+(\.\d+)*(-[0-9A-Za-z.-]+)?$/;
|
|
51880
52115
|
function isValidVersion(v) {
|
|
@@ -51960,13 +52195,13 @@ function runBootstrap(deps) {
|
|
|
51960
52195
|
}
|
|
51961
52196
|
|
|
51962
52197
|
// licensing.ts
|
|
51963
|
-
var
|
|
51964
|
-
var
|
|
51965
|
-
var
|
|
52198
|
+
var import_node_fs6 = require("node:fs");
|
|
52199
|
+
var import_node_path5 = require("node:path");
|
|
52200
|
+
var import_node_os5 = require("node:os");
|
|
51966
52201
|
var import_node_child_process2 = require("node:child_process");
|
|
51967
|
-
var
|
|
52202
|
+
var import_node_crypto3 = require("node:crypto");
|
|
51968
52203
|
var import_node_module2 = require("node:module");
|
|
51969
|
-
var
|
|
52204
|
+
var import_node_os6 = require("node:os");
|
|
51970
52205
|
var ENVS = {
|
|
51971
52206
|
production: { apiBase: "https://api.floless.io/api", webBase: "https://floless.io" },
|
|
51972
52207
|
staging: { apiBase: "https://api.stage.floless.io/api", webBase: "https://stage.floless.io" }
|
|
@@ -51978,6 +52213,18 @@ function env() {
|
|
|
51978
52213
|
webBase: process.env.FLOLESS_WEB_BASE || base.webBase
|
|
51979
52214
|
};
|
|
51980
52215
|
}
|
|
52216
|
+
function isLoopback(host) {
|
|
52217
|
+
return host === "127.0.0.1" || host === "localhost" || host === "::1" || host.endsWith(".localhost");
|
|
52218
|
+
}
|
|
52219
|
+
var TRUSTED_API_ORIGINS = /* @__PURE__ */ new Set(["https://api.floless.io", "https://api.stage.floless.io"]);
|
|
52220
|
+
function isTrustedFlolessHost(url) {
|
|
52221
|
+
try {
|
|
52222
|
+
const u = new URL(url);
|
|
52223
|
+
return isLoopback(u.hostname) || TRUSTED_API_ORIGINS.has(u.origin);
|
|
52224
|
+
} catch {
|
|
52225
|
+
return false;
|
|
52226
|
+
}
|
|
52227
|
+
}
|
|
51981
52228
|
var OFFLINE_GRACE_MS = 24 * 60 * 60 * 1e3;
|
|
51982
52229
|
var MEM_CACHE_MS = 60 * 1e3;
|
|
51983
52230
|
var REFRESH_SKEW_MS = 60 * 1e3;
|
|
@@ -51990,26 +52237,26 @@ function isSea() {
|
|
|
51990
52237
|
}
|
|
51991
52238
|
function storeDir() {
|
|
51992
52239
|
if (process.env.FLOLESS_LICENSE_DIR) return process.env.FLOLESS_LICENSE_DIR;
|
|
51993
|
-
if (isSea() && process.env.LOCALAPPDATA) return (0,
|
|
51994
|
-
return (0,
|
|
52240
|
+
if (isSea() && process.env.LOCALAPPDATA) return (0, import_node_path5.join)(process.env.LOCALAPPDATA, "FlolessApp-data");
|
|
52241
|
+
return (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".aware");
|
|
51995
52242
|
}
|
|
51996
|
-
var tokenPath = () => (0,
|
|
51997
|
-
var cachePath = () => (0,
|
|
52243
|
+
var tokenPath = () => (0, import_node_path5.join)(storeDir(), "floless-license.json");
|
|
52244
|
+
var cachePath = () => (0, import_node_path5.join)(storeDir(), "floless-license-cache.json");
|
|
51998
52245
|
var _migrated = false;
|
|
51999
52246
|
function migrateLegacyStore() {
|
|
52000
52247
|
if (_migrated) return;
|
|
52001
52248
|
_migrated = true;
|
|
52002
52249
|
if (process.env.FLOLESS_LICENSE_DIR || !(isSea() && process.env.LOCALAPPDATA)) return;
|
|
52003
|
-
const oldDir = (0,
|
|
52250
|
+
const oldDir = (0, import_node_path5.join)(process.env.LOCALAPPDATA, "FlolessApp");
|
|
52004
52251
|
const newDir = storeDir();
|
|
52005
52252
|
if (oldDir === newDir) return;
|
|
52006
52253
|
for (const f of ["floless-license.json", "floless-license-cache.json", "floless-install-id"]) {
|
|
52007
52254
|
try {
|
|
52008
|
-
const oldP = (0,
|
|
52009
|
-
const newP = (0,
|
|
52010
|
-
if ((0,
|
|
52011
|
-
(0,
|
|
52012
|
-
(0,
|
|
52255
|
+
const oldP = (0, import_node_path5.join)(oldDir, f);
|
|
52256
|
+
const newP = (0, import_node_path5.join)(newDir, f);
|
|
52257
|
+
if ((0, import_node_fs6.existsSync)(oldP) && !(0, import_node_fs6.existsSync)(newP)) {
|
|
52258
|
+
(0, import_node_fs6.mkdirSync)(newDir, { recursive: true });
|
|
52259
|
+
(0, import_node_fs6.copyFileSync)(oldP, newP);
|
|
52013
52260
|
}
|
|
52014
52261
|
} catch {
|
|
52015
52262
|
}
|
|
@@ -52017,16 +52264,16 @@ function migrateLegacyStore() {
|
|
|
52017
52264
|
}
|
|
52018
52265
|
function readJson(path) {
|
|
52019
52266
|
try {
|
|
52020
|
-
return (0,
|
|
52267
|
+
return (0, import_node_fs6.existsSync)(path) ? JSON.parse((0, import_node_fs6.readFileSync)(path, "utf8")) : null;
|
|
52021
52268
|
} catch {
|
|
52022
52269
|
return null;
|
|
52023
52270
|
}
|
|
52024
52271
|
}
|
|
52025
52272
|
function writeJson(path, value) {
|
|
52026
|
-
(0,
|
|
52027
|
-
(0,
|
|
52273
|
+
(0, import_node_fs6.mkdirSync)(storeDir(), { recursive: true });
|
|
52274
|
+
(0, import_node_fs6.writeFileSync)(path, JSON.stringify(value, null, 2), "utf8");
|
|
52028
52275
|
try {
|
|
52029
|
-
(0,
|
|
52276
|
+
(0, import_node_fs6.chmodSync)(path, 384);
|
|
52030
52277
|
} catch {
|
|
52031
52278
|
}
|
|
52032
52279
|
}
|
|
@@ -52059,6 +52306,7 @@ async function resolveToken() {
|
|
|
52059
52306
|
const t = readTokens();
|
|
52060
52307
|
if (!t) return { token: null, reason: "signed-out" };
|
|
52061
52308
|
if (Date.now() < t.expiresAt - REFRESH_SKEW_MS) return { token: t.accessToken };
|
|
52309
|
+
if (!isTrustedFlolessHost(env().apiBase)) return { token: null, reason: "session-expired" };
|
|
52062
52310
|
let res;
|
|
52063
52311
|
try {
|
|
52064
52312
|
res = await fetch(`${env().apiBase}/auth/refresh`, {
|
|
@@ -52164,7 +52412,7 @@ async function ensureSeat(token) {
|
|
|
52164
52412
|
const res = await fetch(`${env().apiBase}/seats/claim`, {
|
|
52165
52413
|
method: "POST",
|
|
52166
52414
|
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
52167
|
-
body: JSON.stringify({ device_fingerprint: installId(), device_name: (0,
|
|
52415
|
+
body: JSON.stringify({ device_fingerprint: installId(), device_name: (0, import_node_os6.hostname)(), os_version: `${process.platform} ${process.arch}` })
|
|
52168
52416
|
});
|
|
52169
52417
|
if (!res.ok) return;
|
|
52170
52418
|
const b = await res.json();
|
|
@@ -52185,7 +52433,7 @@ async function seatHeartbeat() {
|
|
|
52185
52433
|
try {
|
|
52186
52434
|
const token = await ensureFreshToken().catch(() => null);
|
|
52187
52435
|
if (!token) return;
|
|
52188
|
-
const hmac = (0,
|
|
52436
|
+
const hmac = (0, import_node_crypto3.createHmac)("sha256", seat.hmacSecret).update(seat.nonce).digest("hex");
|
|
52189
52437
|
let res;
|
|
52190
52438
|
try {
|
|
52191
52439
|
res = await fetch(`${env().apiBase}/seats/heartbeat`, {
|
|
@@ -52255,7 +52503,7 @@ function logout() {
|
|
|
52255
52503
|
resetSeat();
|
|
52256
52504
|
for (const p of [tokenPath(), cachePath()]) {
|
|
52257
52505
|
try {
|
|
52258
|
-
(0,
|
|
52506
|
+
(0, import_node_fs6.rmSync)(p, { force: true });
|
|
52259
52507
|
} catch {
|
|
52260
52508
|
}
|
|
52261
52509
|
}
|
|
@@ -52279,7 +52527,7 @@ function openBrowser(url) {
|
|
|
52279
52527
|
(0, import_node_child_process2.spawn)(cmd, args, opts).unref();
|
|
52280
52528
|
}
|
|
52281
52529
|
async function startLogin() {
|
|
52282
|
-
const sessionId = (0,
|
|
52530
|
+
const sessionId = (0, import_node_crypto3.randomUUID)();
|
|
52283
52531
|
const loginUrl = `${env().webBase}/login?desktop=true&session=${sessionId}&app=floless`;
|
|
52284
52532
|
openBrowser(loginUrl);
|
|
52285
52533
|
void pollDesktopStatus(sessionId).catch(() => {
|
|
@@ -52312,20 +52560,20 @@ async function pollDesktopStatus(sessionId, timeoutMs = 18e4) {
|
|
|
52312
52560
|
return false;
|
|
52313
52561
|
}
|
|
52314
52562
|
function installId() {
|
|
52315
|
-
const p = (0,
|
|
52563
|
+
const p = (0, import_node_path5.join)(storeDir(), "floless-install-id");
|
|
52316
52564
|
const existing = readJson(p);
|
|
52317
52565
|
if (typeof existing === "string" && existing.length >= 80 && existing.length <= 100) {
|
|
52318
52566
|
return existing;
|
|
52319
52567
|
}
|
|
52320
|
-
const id = (0,
|
|
52568
|
+
const id = (0, import_node_crypto3.createHash)("sha512").update((0, import_node_crypto3.randomUUID)()).digest("base64");
|
|
52321
52569
|
writeJson(p, id);
|
|
52322
52570
|
return id;
|
|
52323
52571
|
}
|
|
52324
52572
|
|
|
52325
52573
|
// version.ts
|
|
52326
52574
|
var import_node_module3 = require("node:module");
|
|
52327
|
-
var
|
|
52328
|
-
var
|
|
52575
|
+
var import_node_path6 = require("node:path");
|
|
52576
|
+
var import_node_fs7 = require("node:fs");
|
|
52329
52577
|
function resolveVersion(s) {
|
|
52330
52578
|
if (s.isSea) {
|
|
52331
52579
|
const m = s.sqVersionXml?.match(/<version>([^<]+)<\/version>/);
|
|
@@ -52344,8 +52592,8 @@ function isSea2() {
|
|
|
52344
52592
|
}
|
|
52345
52593
|
function readSqVersionXml() {
|
|
52346
52594
|
try {
|
|
52347
|
-
const sq = (0,
|
|
52348
|
-
return (0,
|
|
52595
|
+
const sq = (0, import_node_path6.join)((0, import_node_path6.dirname)(process.execPath), "sq.version");
|
|
52596
|
+
return (0, import_node_fs7.existsSync)(sq) ? (0, import_node_fs7.readFileSync)(sq, "utf8") : null;
|
|
52349
52597
|
} catch {
|
|
52350
52598
|
return null;
|
|
52351
52599
|
}
|
|
@@ -52361,7 +52609,7 @@ function appVersion() {
|
|
|
52361
52609
|
return resolveVersion({
|
|
52362
52610
|
isSea: isSea2(),
|
|
52363
52611
|
sqVersionXml: readSqVersionXml(),
|
|
52364
|
-
define: true ? "0.
|
|
52612
|
+
define: true ? "0.12.0" : void 0,
|
|
52365
52613
|
pkgVersion: readPkgVersion()
|
|
52366
52614
|
});
|
|
52367
52615
|
}
|
|
@@ -52371,14 +52619,14 @@ function resolveChannel(s) {
|
|
|
52371
52619
|
return "dev";
|
|
52372
52620
|
}
|
|
52373
52621
|
function appChannel() {
|
|
52374
|
-
return resolveChannel({ isSea: isSea2(), define: true ? "0.
|
|
52622
|
+
return resolveChannel({ isSea: isSea2(), define: true ? "0.12.0" : void 0 });
|
|
52375
52623
|
}
|
|
52376
52624
|
|
|
52377
52625
|
// oauth-presets.ts
|
|
52378
|
-
var
|
|
52379
|
-
var
|
|
52626
|
+
var import_node_os7 = require("node:os");
|
|
52627
|
+
var import_node_path7 = require("node:path");
|
|
52380
52628
|
var import_node_net = __toESM(require("node:net"), 1);
|
|
52381
|
-
var
|
|
52629
|
+
var import_node_fs8 = require("node:fs");
|
|
52382
52630
|
var MANAGED_HEADER = "# managed by floless.app - do not edit";
|
|
52383
52631
|
var OAUTH_PRESETS = {
|
|
52384
52632
|
"trimble-connect": {
|
|
@@ -52408,7 +52656,7 @@ function managedProfileYaml(preset) {
|
|
|
52408
52656
|
].join("\n");
|
|
52409
52657
|
}
|
|
52410
52658
|
function oauthDir() {
|
|
52411
|
-
return process.env.AWARE_HOME ? (0,
|
|
52659
|
+
return process.env.AWARE_HOME ? (0, import_node_path7.join)(process.env.AWARE_HOME, "oauth") : (0, import_node_path7.join)((0, import_node_os7.homedir)(), ".aware", "oauth");
|
|
52412
52660
|
}
|
|
52413
52661
|
function isUpgradableLegacyProfile(existing, preset) {
|
|
52414
52662
|
if (existing.startsWith(MANAGED_HEADER)) return false;
|
|
@@ -52422,22 +52670,22 @@ function ensureManagedProfile(id) {
|
|
|
52422
52670
|
const preset = OAUTH_PRESETS[id];
|
|
52423
52671
|
if (!preset) return "not-managed";
|
|
52424
52672
|
const dir = oauthDir();
|
|
52425
|
-
const file = (0,
|
|
52426
|
-
const existing = (0,
|
|
52673
|
+
const file = (0, import_node_path7.join)(dir, `${id}.yaml`);
|
|
52674
|
+
const existing = (0, import_node_fs8.existsSync)(file) ? (0, import_node_fs8.readFileSync)(file, "utf8") : null;
|
|
52427
52675
|
if (existing !== null && !existing.startsWith(MANAGED_HEADER) && !isUpgradableLegacyProfile(existing, preset)) {
|
|
52428
52676
|
return "skipped";
|
|
52429
52677
|
}
|
|
52430
52678
|
const desired = managedProfileYaml(preset);
|
|
52431
52679
|
if (existing === desired) return "unchanged";
|
|
52432
|
-
(0,
|
|
52433
|
-
(0,
|
|
52680
|
+
(0, import_node_fs8.mkdirSync)(dir, { recursive: true });
|
|
52681
|
+
(0, import_node_fs8.writeFileSync)(file, desired, "utf8");
|
|
52434
52682
|
return "written";
|
|
52435
52683
|
}
|
|
52436
52684
|
function isPortBindable(port, host = "127.0.0.1") {
|
|
52437
|
-
return new Promise((
|
|
52685
|
+
return new Promise((resolve5) => {
|
|
52438
52686
|
const srv = import_node_net.default.createServer();
|
|
52439
|
-
srv.once("error", () =>
|
|
52440
|
-
srv.listen(port, host, () => srv.close(() =>
|
|
52687
|
+
srv.once("error", () => resolve5(false));
|
|
52688
|
+
srv.listen(port, host, () => srv.close(() => resolve5(true)));
|
|
52441
52689
|
});
|
|
52442
52690
|
}
|
|
52443
52691
|
|
|
@@ -52508,7 +52756,7 @@ function withBadge(report, opts) {
|
|
|
52508
52756
|
}
|
|
52509
52757
|
|
|
52510
52758
|
// index.ts
|
|
52511
|
-
var
|
|
52759
|
+
var import_node_crypto6 = require("node:crypto");
|
|
52512
52760
|
|
|
52513
52761
|
// graft.ts
|
|
52514
52762
|
var TEKLA_MARKER = "Recipe: Tekla model plug-in";
|
|
@@ -52552,16 +52800,16 @@ function buildPreview(m, sourceKind, sourceRef, stagedRef) {
|
|
|
52552
52800
|
}
|
|
52553
52801
|
|
|
52554
52802
|
// graft-manifest-reader.ts
|
|
52555
|
-
var
|
|
52556
|
-
var
|
|
52803
|
+
var import_node_fs9 = require("node:fs");
|
|
52804
|
+
var import_node_path8 = require("node:path");
|
|
52557
52805
|
var import_yaml3 = __toESM(require_dist6(), 1);
|
|
52558
52806
|
var asRecord2 = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
52559
52807
|
function readStagedManifest(agentDir) {
|
|
52560
|
-
const manifestPath = (0,
|
|
52561
|
-
if (!(0,
|
|
52808
|
+
const manifestPath = (0, import_node_path8.join)(agentDir, "manifest.yaml");
|
|
52809
|
+
if (!(0, import_node_fs9.existsSync)(manifestPath)) return null;
|
|
52562
52810
|
let doc;
|
|
52563
52811
|
try {
|
|
52564
|
-
doc = asRecord2((0, import_yaml3.parse)((0,
|
|
52812
|
+
doc = asRecord2((0, import_yaml3.parse)((0, import_node_fs9.readFileSync)(manifestPath, "utf8")));
|
|
52565
52813
|
} catch {
|
|
52566
52814
|
return null;
|
|
52567
52815
|
}
|
|
@@ -52591,10 +52839,10 @@ function readStagedManifest(agentDir) {
|
|
|
52591
52839
|
}
|
|
52592
52840
|
let skillCount = Array.isArray(doc.skills) ? doc.skills.length : 0;
|
|
52593
52841
|
if (!skillCount) {
|
|
52594
|
-
const skillsDir = (0,
|
|
52595
|
-
if ((0,
|
|
52842
|
+
const skillsDir = (0, import_node_path8.join)(agentDir, "skills");
|
|
52843
|
+
if ((0, import_node_fs9.existsSync)(skillsDir)) {
|
|
52596
52844
|
try {
|
|
52597
|
-
skillCount = (0,
|
|
52845
|
+
skillCount = (0, import_node_fs9.readdirSync)(skillsDir).filter((f) => f.endsWith(".md")).length;
|
|
52598
52846
|
} catch {
|
|
52599
52847
|
}
|
|
52600
52848
|
}
|
|
@@ -52608,7 +52856,7 @@ function readStagedManifest(agentDir) {
|
|
|
52608
52856
|
}
|
|
52609
52857
|
|
|
52610
52858
|
// graft-stage-registry.ts
|
|
52611
|
-
var
|
|
52859
|
+
var import_node_fs10 = require("node:fs");
|
|
52612
52860
|
var TTL_MS = 30 * 60 * 1e3;
|
|
52613
52861
|
var registry = /* @__PURE__ */ new Map();
|
|
52614
52862
|
function registerStage(token, tempDir, agentId) {
|
|
@@ -52630,7 +52878,7 @@ function evict(token) {
|
|
|
52630
52878
|
clearTimeout(e.timer);
|
|
52631
52879
|
registry.delete(token);
|
|
52632
52880
|
try {
|
|
52633
|
-
(0,
|
|
52881
|
+
(0, import_node_fs10.rmSync)(e.tempDir, { recursive: true, force: true });
|
|
52634
52882
|
} catch {
|
|
52635
52883
|
}
|
|
52636
52884
|
}
|
|
@@ -52639,8 +52887,8 @@ function clearAllStages() {
|
|
|
52639
52887
|
}
|
|
52640
52888
|
|
|
52641
52889
|
// graft-commit.ts
|
|
52642
|
-
var
|
|
52643
|
-
var
|
|
52890
|
+
var import_node_fs11 = require("node:fs");
|
|
52891
|
+
var import_node_path9 = require("node:path");
|
|
52644
52892
|
var GraftCommitError = class extends Error {
|
|
52645
52893
|
constructor(message, code) {
|
|
52646
52894
|
super(message);
|
|
@@ -52650,34 +52898,34 @@ var GraftCommitError = class extends Error {
|
|
|
52650
52898
|
code;
|
|
52651
52899
|
};
|
|
52652
52900
|
function commitStaged(tempDir, agentId, targetAgentsDir, force) {
|
|
52653
|
-
const staged = (0,
|
|
52654
|
-
const target = (0,
|
|
52655
|
-
if ((0,
|
|
52901
|
+
const staged = (0, import_node_path9.join)(tempDir, "agents", agentId);
|
|
52902
|
+
const target = (0, import_node_path9.join)(targetAgentsDir, agentId);
|
|
52903
|
+
if ((0, import_node_fs11.existsSync)(target)) {
|
|
52656
52904
|
if (!force) throw new GraftCommitError(`an agent named "${agentId}" is already installed`, "collision");
|
|
52657
|
-
(0,
|
|
52905
|
+
(0, import_node_fs11.rmSync)(target, { recursive: true, force: true });
|
|
52658
52906
|
}
|
|
52659
|
-
(0,
|
|
52907
|
+
(0, import_node_fs11.mkdirSync)(targetAgentsDir, { recursive: true });
|
|
52660
52908
|
try {
|
|
52661
|
-
(0,
|
|
52909
|
+
(0, import_node_fs11.renameSync)(staged, target);
|
|
52662
52910
|
} catch {
|
|
52663
|
-
(0,
|
|
52911
|
+
(0, import_node_fs11.cpSync)(staged, target, { recursive: true });
|
|
52664
52912
|
}
|
|
52665
|
-
(0,
|
|
52913
|
+
(0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
|
|
52666
52914
|
return { agentId };
|
|
52667
52915
|
}
|
|
52668
52916
|
function matchAssemblies(globOrDir) {
|
|
52669
52917
|
let dir;
|
|
52670
52918
|
let pattern;
|
|
52671
|
-
if ((0,
|
|
52919
|
+
if ((0, import_node_fs11.existsSync)(globOrDir) && (0, import_node_fs11.statSync)(globOrDir).isDirectory()) {
|
|
52672
52920
|
dir = globOrDir;
|
|
52673
52921
|
pattern = "*.dll";
|
|
52674
52922
|
} else {
|
|
52675
|
-
dir = (0,
|
|
52676
|
-
pattern = (0,
|
|
52923
|
+
dir = (0, import_node_path9.dirname)(globOrDir);
|
|
52924
|
+
pattern = (0, import_node_path9.basename)(globOrDir);
|
|
52677
52925
|
}
|
|
52678
|
-
if (!dir || !(0,
|
|
52926
|
+
if (!dir || !(0, import_node_fs11.existsSync)(dir) || !(0, import_node_fs11.statSync)(dir).isDirectory()) return [];
|
|
52679
52927
|
const re = globToRegExp(pattern);
|
|
52680
|
-
return (0,
|
|
52928
|
+
return (0, import_node_fs11.readdirSync)(dir).filter((f) => re.test(f)).sort();
|
|
52681
52929
|
}
|
|
52682
52930
|
function globToRegExp(p) {
|
|
52683
52931
|
const esc = p.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
@@ -52685,25 +52933,25 @@ function globToRegExp(p) {
|
|
|
52685
52933
|
}
|
|
52686
52934
|
|
|
52687
52935
|
// floless-store.ts
|
|
52688
|
-
var
|
|
52689
|
-
var
|
|
52690
|
-
var
|
|
52691
|
-
var
|
|
52692
|
-
var
|
|
52693
|
-
var TEMPLATES_FILE = (0,
|
|
52694
|
-
var REQUESTS_DIR = (0,
|
|
52936
|
+
var import_node_crypto4 = require("node:crypto");
|
|
52937
|
+
var import_node_fs12 = require("node:fs");
|
|
52938
|
+
var import_node_os8 = require("node:os");
|
|
52939
|
+
var import_node_path10 = require("node:path");
|
|
52940
|
+
var ROOT2 = process.env.FLOLESS_HOME ?? (0, import_node_path10.join)((0, import_node_os8.homedir)(), ".floless");
|
|
52941
|
+
var TEMPLATES_FILE = (0, import_node_path10.join)(ROOT2, "templates.json");
|
|
52942
|
+
var REQUESTS_DIR = (0, import_node_path10.join)(ROOT2, "requests");
|
|
52695
52943
|
function ensureRoot() {
|
|
52696
|
-
if (!(0,
|
|
52944
|
+
if (!(0, import_node_fs12.existsSync)(ROOT2)) (0, import_node_fs12.mkdirSync)(ROOT2, { recursive: true });
|
|
52697
52945
|
}
|
|
52698
52946
|
function withinRequestsDir(p) {
|
|
52699
|
-
const base = (0,
|
|
52700
|
-
const full = (0,
|
|
52701
|
-
return full === base || full.startsWith(base +
|
|
52947
|
+
const base = (0, import_node_path10.resolve)(REQUESTS_DIR);
|
|
52948
|
+
const full = (0, import_node_path10.resolve)(p);
|
|
52949
|
+
return full === base || full.startsWith(base + import_node_path10.sep);
|
|
52702
52950
|
}
|
|
52703
52951
|
function listTemplates() {
|
|
52704
|
-
if (!(0,
|
|
52952
|
+
if (!(0, import_node_fs12.existsSync)(TEMPLATES_FILE)) return [];
|
|
52705
52953
|
try {
|
|
52706
|
-
const parsed = JSON.parse((0,
|
|
52954
|
+
const parsed = JSON.parse((0, import_node_fs12.readFileSync)(TEMPLATES_FILE, "utf8"));
|
|
52707
52955
|
return Array.isArray(parsed) ? parsed : [];
|
|
52708
52956
|
} catch {
|
|
52709
52957
|
return [];
|
|
@@ -52712,12 +52960,12 @@ function listTemplates() {
|
|
|
52712
52960
|
function writeTemplates(list) {
|
|
52713
52961
|
ensureRoot();
|
|
52714
52962
|
const tmp = `${TEMPLATES_FILE}.${process.pid}.tmp`;
|
|
52715
|
-
(0,
|
|
52716
|
-
(0,
|
|
52963
|
+
(0, import_node_fs12.writeFileSync)(tmp, JSON.stringify(list, null, 2));
|
|
52964
|
+
(0, import_node_fs12.renameSync)(tmp, TEMPLATES_FILE);
|
|
52717
52965
|
}
|
|
52718
52966
|
function addTemplate(input) {
|
|
52719
52967
|
const tpl = {
|
|
52720
|
-
id: (0,
|
|
52968
|
+
id: (0, import_node_crypto4.randomUUID)(),
|
|
52721
52969
|
name: input.name.trim(),
|
|
52722
52970
|
category: (input.category || "Uncategorized").trim(),
|
|
52723
52971
|
node: input.node,
|
|
@@ -52741,13 +52989,13 @@ function getTemplate(id) {
|
|
|
52741
52989
|
}
|
|
52742
52990
|
function addRequest(req, decoded = []) {
|
|
52743
52991
|
ensureRoot();
|
|
52744
|
-
if (!(0,
|
|
52745
|
-
const id = (0,
|
|
52992
|
+
if (!(0, import_node_fs12.existsSync)(REQUESTS_DIR)) (0, import_node_fs12.mkdirSync)(REQUESTS_DIR, { recursive: true });
|
|
52993
|
+
const id = (0, import_node_crypto4.randomUUID)();
|
|
52746
52994
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
52747
52995
|
const base = `${createdAt.replace(/[:.]/g, "-")}__${id}`;
|
|
52748
52996
|
const snapshots = decoded.map((d, i) => {
|
|
52749
|
-
const p = (0,
|
|
52750
|
-
(0,
|
|
52997
|
+
const p = (0, import_node_path10.join)(REQUESTS_DIR, `${base}__snap${i + 1}.${d.ext}`);
|
|
52998
|
+
(0, import_node_fs12.writeFileSync)(p, d.buf);
|
|
52751
52999
|
return p;
|
|
52752
53000
|
});
|
|
52753
53001
|
const full = {
|
|
@@ -52757,62 +53005,62 @@ function addRequest(req, decoded = []) {
|
|
|
52757
53005
|
...req,
|
|
52758
53006
|
...snapshots.length ? { snapshots } : {}
|
|
52759
53007
|
};
|
|
52760
|
-
(0,
|
|
53008
|
+
(0, import_node_fs12.writeFileSync)((0, import_node_path10.join)(REQUESTS_DIR, `${base}.json`), JSON.stringify(full, null, 2));
|
|
52761
53009
|
return full;
|
|
52762
53010
|
}
|
|
52763
53011
|
function listRequests() {
|
|
52764
|
-
if (!(0,
|
|
52765
|
-
return (0,
|
|
53012
|
+
if (!(0, import_node_fs12.existsSync)(REQUESTS_DIR)) return [];
|
|
53013
|
+
return (0, import_node_fs12.readdirSync)(REQUESTS_DIR).filter((f) => f.endsWith(".json")).sort().map((f) => {
|
|
52766
53014
|
try {
|
|
52767
|
-
return JSON.parse((0,
|
|
53015
|
+
return JSON.parse((0, import_node_fs12.readFileSync)((0, import_node_path10.join)(REQUESTS_DIR, f), "utf8"));
|
|
52768
53016
|
} catch {
|
|
52769
53017
|
return null;
|
|
52770
53018
|
}
|
|
52771
53019
|
}).filter((r) => r !== null);
|
|
52772
53020
|
}
|
|
52773
53021
|
function deleteRequest(id) {
|
|
52774
|
-
if (!(0,
|
|
52775
|
-
const file = (0,
|
|
53022
|
+
if (!(0, import_node_fs12.existsSync)(REQUESTS_DIR)) return false;
|
|
53023
|
+
const file = (0, import_node_fs12.readdirSync)(REQUESTS_DIR).find((f) => f.endsWith(`__${id}.json`));
|
|
52776
53024
|
if (!file) return false;
|
|
52777
53025
|
try {
|
|
52778
|
-
const parsed = JSON.parse((0,
|
|
53026
|
+
const parsed = JSON.parse((0, import_node_fs12.readFileSync)((0, import_node_path10.join)(REQUESTS_DIR, file), "utf8"));
|
|
52779
53027
|
for (const p of parsed.snapshots ?? []) {
|
|
52780
53028
|
if (!withinRequestsDir(p)) continue;
|
|
52781
53029
|
try {
|
|
52782
|
-
(0,
|
|
53030
|
+
(0, import_node_fs12.rmSync)(p);
|
|
52783
53031
|
} catch {
|
|
52784
53032
|
}
|
|
52785
53033
|
}
|
|
52786
53034
|
} catch {
|
|
52787
53035
|
}
|
|
52788
|
-
(0,
|
|
53036
|
+
(0, import_node_fs12.rmSync)((0, import_node_path10.join)(REQUESTS_DIR, file));
|
|
52789
53037
|
return true;
|
|
52790
53038
|
}
|
|
52791
53039
|
function clearRequests() {
|
|
52792
|
-
if (!(0,
|
|
52793
|
-
const allFiles = (0,
|
|
53040
|
+
if (!(0, import_node_fs12.existsSync)(REQUESTS_DIR)) return 0;
|
|
53041
|
+
const allFiles = (0, import_node_fs12.readdirSync)(REQUESTS_DIR);
|
|
52794
53042
|
const jsonFiles = allFiles.filter((f) => f.endsWith(".json"));
|
|
52795
53043
|
for (const f of allFiles) {
|
|
52796
53044
|
try {
|
|
52797
|
-
(0,
|
|
53045
|
+
(0, import_node_fs12.rmSync)((0, import_node_path10.join)(REQUESTS_DIR, f));
|
|
52798
53046
|
} catch {
|
|
52799
53047
|
}
|
|
52800
53048
|
}
|
|
52801
53049
|
return jsonFiles.length;
|
|
52802
53050
|
}
|
|
52803
53051
|
function snapshotPathFor(id, n) {
|
|
52804
|
-
if (!(0,
|
|
52805
|
-
const file = (0,
|
|
53052
|
+
if (!(0, import_node_fs12.existsSync)(REQUESTS_DIR)) return null;
|
|
53053
|
+
const file = (0, import_node_fs12.readdirSync)(REQUESTS_DIR).find((f) => f.endsWith(`__${id}.json`));
|
|
52806
53054
|
if (!file) return null;
|
|
52807
53055
|
try {
|
|
52808
|
-
const parsed = JSON.parse((0,
|
|
53056
|
+
const parsed = JSON.parse((0, import_node_fs12.readFileSync)((0, import_node_path10.join)(REQUESTS_DIR, file), "utf8"));
|
|
52809
53057
|
const cand = parsed.snapshots?.[n] ?? null;
|
|
52810
53058
|
return cand && withinRequestsDir(cand) ? cand : null;
|
|
52811
53059
|
} catch {
|
|
52812
53060
|
return null;
|
|
52813
53061
|
}
|
|
52814
53062
|
}
|
|
52815
|
-
var flolessRoot =
|
|
53063
|
+
var flolessRoot = ROOT2;
|
|
52816
53064
|
var SnapshotError = class extends Error {
|
|
52817
53065
|
};
|
|
52818
53066
|
var MAX_SNAPSHOTS = 8;
|
|
@@ -52839,8 +53087,8 @@ function decodeSnapshots(inputs) {
|
|
|
52839
53087
|
}
|
|
52840
53088
|
|
|
52841
53089
|
// routines.ts
|
|
52842
|
-
var
|
|
52843
|
-
var
|
|
53090
|
+
var import_node_fs14 = require("node:fs");
|
|
53091
|
+
var import_node_path12 = require("node:path");
|
|
52844
53092
|
|
|
52845
53093
|
// sse.ts
|
|
52846
53094
|
var clients = /* @__PURE__ */ new Set();
|
|
@@ -52877,11 +53125,11 @@ function clientCount() {
|
|
|
52877
53125
|
}
|
|
52878
53126
|
|
|
52879
53127
|
// trigger-sessions.ts
|
|
52880
|
-
var
|
|
52881
|
-
var
|
|
52882
|
-
var
|
|
53128
|
+
var import_node_fs13 = require("node:fs");
|
|
53129
|
+
var import_node_os9 = require("node:os");
|
|
53130
|
+
var import_node_path11 = require("node:path");
|
|
52883
53131
|
var import_yaml4 = __toESM(require_dist6(), 1);
|
|
52884
|
-
var AGENTS_DIR2 = process.env.AWARE_HOME ? (0,
|
|
53132
|
+
var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path11.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path11.join)((0, import_node_os9.homedir)(), ".aware", "agents");
|
|
52885
53133
|
function summarizeFire(data) {
|
|
52886
53134
|
if (!data) return "event";
|
|
52887
53135
|
const type = typeof data.type === "string" ? data.type : "";
|
|
@@ -52898,10 +53146,10 @@ function mapTriggerState(phase) {
|
|
|
52898
53146
|
function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
52899
53147
|
const safe = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
52900
53148
|
if (!safe(agent)) return false;
|
|
52901
|
-
const manifestPath = (0,
|
|
52902
|
-
if (!(0,
|
|
53149
|
+
const manifestPath = (0, import_node_path11.join)(agentsDir, agent, "manifest.yaml");
|
|
53150
|
+
if (!(0, import_node_fs13.existsSync)(manifestPath)) return false;
|
|
52903
53151
|
try {
|
|
52904
|
-
const doc = (0, import_yaml4.parse)((0,
|
|
53152
|
+
const doc = (0, import_yaml4.parse)((0, import_node_fs13.readFileSync)(manifestPath, "utf8"));
|
|
52905
53153
|
const transport = doc?.transport;
|
|
52906
53154
|
return !!(transport && typeof transport === "object" && "cli" in transport);
|
|
52907
53155
|
} catch {
|
|
@@ -53160,7 +53408,7 @@ var RoutineError = class extends Error {
|
|
|
53160
53408
|
}
|
|
53161
53409
|
status;
|
|
53162
53410
|
};
|
|
53163
|
-
var ROUTINES_FILE = (0,
|
|
53411
|
+
var ROUTINES_FILE = (0, import_node_path12.join)(flolessRoot, "routines.json");
|
|
53164
53412
|
var routines = [];
|
|
53165
53413
|
var loaded = false;
|
|
53166
53414
|
function ensureLoaded() {
|
|
@@ -53196,10 +53444,10 @@ function sanitizeRoutine(raw) {
|
|
|
53196
53444
|
};
|
|
53197
53445
|
}
|
|
53198
53446
|
function loadFromDisk() {
|
|
53199
|
-
if (!(0,
|
|
53447
|
+
if (!(0, import_node_fs14.existsSync)(ROUTINES_FILE)) return [];
|
|
53200
53448
|
let text;
|
|
53201
53449
|
try {
|
|
53202
|
-
text = (0,
|
|
53450
|
+
text = (0, import_node_fs14.readFileSync)(ROUTINES_FILE, "utf8");
|
|
53203
53451
|
} catch {
|
|
53204
53452
|
return [];
|
|
53205
53453
|
}
|
|
@@ -53208,17 +53456,17 @@ function loadFromDisk() {
|
|
|
53208
53456
|
return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
|
|
53209
53457
|
} catch {
|
|
53210
53458
|
try {
|
|
53211
|
-
(0,
|
|
53459
|
+
(0, import_node_fs14.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
|
|
53212
53460
|
} catch {
|
|
53213
53461
|
}
|
|
53214
53462
|
return [];
|
|
53215
53463
|
}
|
|
53216
53464
|
}
|
|
53217
53465
|
function saveRoutines() {
|
|
53218
|
-
if (!(0,
|
|
53466
|
+
if (!(0, import_node_fs14.existsSync)(flolessRoot)) (0, import_node_fs14.mkdirSync)(flolessRoot, { recursive: true });
|
|
53219
53467
|
const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
|
|
53220
|
-
(0,
|
|
53221
|
-
(0,
|
|
53468
|
+
(0, import_node_fs14.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
|
|
53469
|
+
(0, import_node_fs14.renameSync)(tmp, ROUTINES_FILE);
|
|
53222
53470
|
}
|
|
53223
53471
|
function listRoutines() {
|
|
53224
53472
|
ensureLoaded();
|
|
@@ -53608,9 +53856,9 @@ function isGatedAwareRoute(url, method) {
|
|
|
53608
53856
|
|
|
53609
53857
|
// autostart.mjs
|
|
53610
53858
|
var import_node_child_process3 = require("node:child_process");
|
|
53611
|
-
var
|
|
53612
|
-
var
|
|
53613
|
-
var
|
|
53859
|
+
var import_node_fs15 = require("node:fs");
|
|
53860
|
+
var import_node_os10 = require("node:os");
|
|
53861
|
+
var import_node_path13 = require("node:path");
|
|
53614
53862
|
|
|
53615
53863
|
// teardown.mjs
|
|
53616
53864
|
var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
@@ -53722,8 +53970,8 @@ function removeLegacyRunKey() {
|
|
|
53722
53970
|
}
|
|
53723
53971
|
function logLine(msg) {
|
|
53724
53972
|
try {
|
|
53725
|
-
(0,
|
|
53726
|
-
(0,
|
|
53973
|
+
(0, import_node_fs15.mkdirSync)(logDir(), { recursive: true });
|
|
53974
|
+
(0, import_node_fs15.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
53727
53975
|
`);
|
|
53728
53976
|
} catch {
|
|
53729
53977
|
}
|
|
@@ -53731,8 +53979,8 @@ function logLine(msg) {
|
|
|
53731
53979
|
function registerAutostart(exePath) {
|
|
53732
53980
|
if (!isWin) return;
|
|
53733
53981
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
53734
|
-
const tmp = (0,
|
|
53735
|
-
(0,
|
|
53982
|
+
const tmp = (0, import_node_path13.join)((0, import_node_os10.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
53983
|
+
(0, import_node_fs15.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
53736
53984
|
try {
|
|
53737
53985
|
(0, import_node_child_process3.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
53738
53986
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -53743,7 +53991,7 @@ function registerAutostart(exePath) {
|
|
|
53743
53991
|
throw err;
|
|
53744
53992
|
} finally {
|
|
53745
53993
|
try {
|
|
53746
|
-
(0,
|
|
53994
|
+
(0, import_node_fs15.rmSync)(tmp, { force: true });
|
|
53747
53995
|
} catch {
|
|
53748
53996
|
}
|
|
53749
53997
|
}
|
|
@@ -53777,11 +54025,11 @@ function unregisterAutostart() {
|
|
|
53777
54025
|
|
|
53778
54026
|
// updater.ts
|
|
53779
54027
|
var import_node_child_process4 = require("node:child_process");
|
|
53780
|
-
var
|
|
53781
|
-
var
|
|
54028
|
+
var import_node_crypto5 = require("node:crypto");
|
|
54029
|
+
var import_node_fs16 = require("node:fs");
|
|
53782
54030
|
var import_node_stream = require("node:stream");
|
|
53783
54031
|
var import_promises = require("node:stream/promises");
|
|
53784
|
-
var
|
|
54032
|
+
var import_node_path14 = require("node:path");
|
|
53785
54033
|
var CHANNEL = "win";
|
|
53786
54034
|
var FEED_TIMEOUT_MS = 15e3;
|
|
53787
54035
|
var DOWNLOAD_TIMEOUT_MS = 3e5;
|
|
@@ -53790,30 +54038,18 @@ function currentVersion() {
|
|
|
53790
54038
|
return appVersion();
|
|
53791
54039
|
}
|
|
53792
54040
|
function installRoot() {
|
|
53793
|
-
return (0,
|
|
54041
|
+
return (0, import_node_path14.dirname)((0, import_node_path14.dirname)(process.execPath));
|
|
53794
54042
|
}
|
|
53795
54043
|
function updateExePath() {
|
|
53796
|
-
return (0,
|
|
54044
|
+
return (0, import_node_path14.join)(installRoot(), "Update.exe");
|
|
53797
54045
|
}
|
|
53798
54046
|
function packagesDir() {
|
|
53799
|
-
return (0,
|
|
54047
|
+
return (0, import_node_path14.join)(installRoot(), "packages");
|
|
53800
54048
|
}
|
|
53801
54049
|
function feedUrl() {
|
|
53802
54050
|
const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
|
|
53803
54051
|
return env2 || updateApiBase();
|
|
53804
54052
|
}
|
|
53805
|
-
function isLoopback(host) {
|
|
53806
|
-
return host === "127.0.0.1" || host === "localhost" || host === "::1" || host.endsWith(".localhost");
|
|
53807
|
-
}
|
|
53808
|
-
var TRUSTED_FEED_ORIGINS = /* @__PURE__ */ new Set(["https://api.floless.io", "https://api.stage.floless.io"]);
|
|
53809
|
-
function isTrustedFlolessHost(url) {
|
|
53810
|
-
try {
|
|
53811
|
-
const u = new URL(url);
|
|
53812
|
-
return isLoopback(u.hostname) || TRUSTED_FEED_ORIGINS.has(u.origin);
|
|
53813
|
-
} catch {
|
|
53814
|
-
return false;
|
|
53815
|
-
}
|
|
53816
|
-
}
|
|
53817
54053
|
async function authedFetch(url, init = {}) {
|
|
53818
54054
|
const headers = new Headers(init.headers);
|
|
53819
54055
|
if (isTrustedFlolessHost(url)) {
|
|
@@ -53900,23 +54136,23 @@ async function checkForUpdate() {
|
|
|
53900
54136
|
return { supported: true, currentVersion: cur, updateAvailable: true, targetVersion: latest.Version, asset: latest };
|
|
53901
54137
|
}
|
|
53902
54138
|
async function sha1OfFile(path) {
|
|
53903
|
-
const hash = (0,
|
|
53904
|
-
await (0, import_promises.pipeline)((0,
|
|
54139
|
+
const hash = (0, import_node_crypto5.createHash)("sha1");
|
|
54140
|
+
await (0, import_promises.pipeline)((0, import_node_fs16.createReadStream)(path), hash);
|
|
53905
54141
|
return hash.digest("hex").toUpperCase();
|
|
53906
54142
|
}
|
|
53907
54143
|
async function downloadPackage(asset) {
|
|
53908
54144
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
53909
54145
|
const want = asset.SHA1.toUpperCase();
|
|
53910
54146
|
const dir = packagesDir();
|
|
53911
|
-
(0,
|
|
53912
|
-
const dest = (0,
|
|
53913
|
-
if ((0,
|
|
54147
|
+
(0, import_node_fs16.mkdirSync)(dir, { recursive: true });
|
|
54148
|
+
const dest = (0, import_node_path14.join)(dir, asset.FileName);
|
|
54149
|
+
if ((0, import_node_fs16.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
53914
54150
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
53915
54151
|
redirect: "follow",
|
|
53916
54152
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
53917
54153
|
});
|
|
53918
54154
|
if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
|
|
53919
|
-
await (0, import_promises.pipeline)(import_node_stream.Readable.fromWeb(res.body), (0,
|
|
54155
|
+
await (0, import_promises.pipeline)(import_node_stream.Readable.fromWeb(res.body), (0, import_node_fs16.createWriteStream)(dest));
|
|
53920
54156
|
const got = await sha1OfFile(dest);
|
|
53921
54157
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
53922
54158
|
return dest;
|
|
@@ -53925,12 +54161,12 @@ async function applyUpdate(check, opts) {
|
|
|
53925
54161
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
53926
54162
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
53927
54163
|
const exe = updateExePath();
|
|
53928
|
-
if (!(0,
|
|
54164
|
+
if (!(0, import_node_fs16.existsSync)(exe)) {
|
|
53929
54165
|
return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
|
|
53930
54166
|
}
|
|
53931
54167
|
const pkg = await downloadPackage(check.asset);
|
|
53932
54168
|
if (opts?.onBeforeApply) await opts.onBeforeApply();
|
|
53933
|
-
await new Promise((
|
|
54169
|
+
await new Promise((resolve5, reject) => {
|
|
53934
54170
|
const child = (0, import_node_child_process4.spawn)(exe, ["apply", "--package", pkg, "--waitPid", String(process.pid)], {
|
|
53935
54171
|
cwd: installRoot(),
|
|
53936
54172
|
detached: true,
|
|
@@ -53940,7 +54176,7 @@ async function applyUpdate(check, opts) {
|
|
|
53940
54176
|
child.once("error", reject);
|
|
53941
54177
|
child.once("spawn", () => {
|
|
53942
54178
|
child.unref();
|
|
53943
|
-
|
|
54179
|
+
resolve5();
|
|
53944
54180
|
});
|
|
53945
54181
|
});
|
|
53946
54182
|
return { applied: true, message: `updating to v${check.targetVersion}\u2026 the app will relaunch` };
|
|
@@ -53980,6 +54216,43 @@ async function reportIssue(input) {
|
|
|
53980
54216
|
return { ok: true, ref };
|
|
53981
54217
|
}
|
|
53982
54218
|
|
|
54219
|
+
// report-share.ts
|
|
54220
|
+
var SHARE_TIMEOUT_MS = 3e4;
|
|
54221
|
+
async function shareReport(input) {
|
|
54222
|
+
let token;
|
|
54223
|
+
try {
|
|
54224
|
+
token = await accessToken();
|
|
54225
|
+
} catch {
|
|
54226
|
+
return { ok: false, error: "offline" };
|
|
54227
|
+
}
|
|
54228
|
+
if (!token) return { ok: false, error: "signed_out" };
|
|
54229
|
+
const url = `${apiBaseUrl()}/reports`;
|
|
54230
|
+
let res;
|
|
54231
|
+
try {
|
|
54232
|
+
res = await authedFetch(url, {
|
|
54233
|
+
method: "POST",
|
|
54234
|
+
headers: { "Content-Type": "application/json" },
|
|
54235
|
+
body: JSON.stringify(input),
|
|
54236
|
+
signal: AbortSignal.timeout(SHARE_TIMEOUT_MS)
|
|
54237
|
+
});
|
|
54238
|
+
} catch {
|
|
54239
|
+
return { ok: false, error: "offline" };
|
|
54240
|
+
}
|
|
54241
|
+
if (res.status === 401) return { ok: false, error: "signed_out" };
|
|
54242
|
+
if (res.status === 403) return { ok: false, error: "no_subscription" };
|
|
54243
|
+
if (res.status === 429) return { ok: false, error: "rate_limited" };
|
|
54244
|
+
if (res.status === 413) return { ok: false, error: "too_large" };
|
|
54245
|
+
if (!res.ok) return { ok: false, error: "offline" };
|
|
54246
|
+
try {
|
|
54247
|
+
const b = await res.json();
|
|
54248
|
+
if (typeof b.url === "string" && b.url && new URL(b.url).protocol === "https:") {
|
|
54249
|
+
return { ok: true, url: b.url };
|
|
54250
|
+
}
|
|
54251
|
+
} catch {
|
|
54252
|
+
}
|
|
54253
|
+
return { ok: false, error: "offline" };
|
|
54254
|
+
}
|
|
54255
|
+
|
|
53983
54256
|
// release-notes.ts
|
|
53984
54257
|
var FETCH_TIMEOUT_MS = 8e3;
|
|
53985
54258
|
var AWARE_REPO = "aware-aeco/aware";
|
|
@@ -54089,15 +54362,19 @@ function summarizeRun(events) {
|
|
|
54089
54362
|
}
|
|
54090
54363
|
return { status, errorNodeId, errorMessage };
|
|
54091
54364
|
}
|
|
54365
|
+
function isTraceCorrupt(events) {
|
|
54366
|
+
if (!events.length) return false;
|
|
54367
|
+
return events.every((e) => e.kind === "unparsed");
|
|
54368
|
+
}
|
|
54092
54369
|
|
|
54093
54370
|
// launch.mjs
|
|
54094
54371
|
var import_node_child_process5 = require("node:child_process");
|
|
54095
|
-
var
|
|
54372
|
+
var import_node_path15 = require("node:path");
|
|
54096
54373
|
var import_node_url = require("node:url");
|
|
54097
|
-
var
|
|
54374
|
+
var import_node_fs17 = require("node:fs");
|
|
54098
54375
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
54099
54376
|
var import_node_readline = require("node:readline");
|
|
54100
|
-
var __dirname2 = (0,
|
|
54377
|
+
var __dirname2 = (0, import_node_path15.dirname)((0, import_node_url.fileURLToPath)(__import_meta_url));
|
|
54101
54378
|
var PORT = Number(process.env.PORT ?? 4317);
|
|
54102
54379
|
var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
|
|
54103
54380
|
var BROWSER_URL = `http://floless.localhost:${PORT}`;
|
|
@@ -54110,20 +54387,20 @@ var log = (m) => {
|
|
|
54110
54387
|
}
|
|
54111
54388
|
};
|
|
54112
54389
|
function ping() {
|
|
54113
|
-
return new Promise((
|
|
54390
|
+
return new Promise((resolve5) => {
|
|
54114
54391
|
const req = import_node_http.default.get(HEALTH_URL, { timeout: 1500 }, (res) => {
|
|
54115
54392
|
res.resume();
|
|
54116
|
-
|
|
54393
|
+
resolve5(res.statusCode === 200);
|
|
54117
54394
|
});
|
|
54118
|
-
req.on("error", () =>
|
|
54395
|
+
req.on("error", () => resolve5(false));
|
|
54119
54396
|
req.on("timeout", () => {
|
|
54120
54397
|
req.destroy();
|
|
54121
|
-
|
|
54398
|
+
resolve5(false);
|
|
54122
54399
|
});
|
|
54123
54400
|
});
|
|
54124
54401
|
}
|
|
54125
54402
|
function probeVersion() {
|
|
54126
|
-
return new Promise((
|
|
54403
|
+
return new Promise((resolve5) => {
|
|
54127
54404
|
const req = import_node_http.default.get(HEALTH_URL, { timeout: 1500 }, (res) => {
|
|
54128
54405
|
let body = "";
|
|
54129
54406
|
res.on("data", (c) => {
|
|
@@ -54131,16 +54408,16 @@ function probeVersion() {
|
|
|
54131
54408
|
});
|
|
54132
54409
|
res.on("end", () => {
|
|
54133
54410
|
try {
|
|
54134
|
-
|
|
54411
|
+
resolve5(JSON.parse(body).appVersion || null);
|
|
54135
54412
|
} catch {
|
|
54136
|
-
|
|
54413
|
+
resolve5(null);
|
|
54137
54414
|
}
|
|
54138
54415
|
});
|
|
54139
54416
|
});
|
|
54140
|
-
req.on("error", () =>
|
|
54417
|
+
req.on("error", () => resolve5(null));
|
|
54141
54418
|
req.on("timeout", () => {
|
|
54142
54419
|
req.destroy();
|
|
54143
|
-
|
|
54420
|
+
resolve5(null);
|
|
54144
54421
|
});
|
|
54145
54422
|
});
|
|
54146
54423
|
}
|
|
@@ -54169,8 +54446,8 @@ async function waitHealthy(timeoutMs = 3e4) {
|
|
|
54169
54446
|
function resolveServerStart() {
|
|
54170
54447
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
54171
54448
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
54172
|
-
const bundle = (0,
|
|
54173
|
-
if ((0,
|
|
54449
|
+
const bundle = (0, import_node_path15.join)(__dirname2, "dist", "floless-server.cjs");
|
|
54450
|
+
if ((0, import_node_fs17.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
54174
54451
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
54175
54452
|
}
|
|
54176
54453
|
function startServerDetached() {
|
|
@@ -54318,8 +54595,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
|
|
|
54318
54595
|
}
|
|
54319
54596
|
function killSupervisor({ tree = true } = {}) {
|
|
54320
54597
|
if (!isWin2) return;
|
|
54321
|
-
const isNpmChannel = /^node(\.exe)?$/i.test((0,
|
|
54322
|
-
const scriptMatch = isNpmChannel ? (0,
|
|
54598
|
+
const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path15.basename)(process.execPath));
|
|
54599
|
+
const scriptMatch = isNpmChannel ? (0, import_node_path15.basename)((0, import_node_url.fileURLToPath)(__import_meta_url)) : void 0;
|
|
54323
54600
|
const realExe = resolveRealInstallExe(process.execPath);
|
|
54324
54601
|
const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
|
|
54325
54602
|
const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
|
|
@@ -54352,15 +54629,15 @@ async function cmdRestart() {
|
|
|
54352
54629
|
await cmdOpen();
|
|
54353
54630
|
}
|
|
54354
54631
|
function apiJson(path, method = "GET") {
|
|
54355
|
-
return new Promise((
|
|
54632
|
+
return new Promise((resolve5, reject) => {
|
|
54356
54633
|
const req = import_node_http.default.request(`http://127.0.0.1:${PORT}${path}`, { method, timeout: 5e3 }, (res) => {
|
|
54357
54634
|
let body = "";
|
|
54358
54635
|
res.on("data", (c) => body += c);
|
|
54359
54636
|
res.on("end", () => {
|
|
54360
54637
|
try {
|
|
54361
|
-
|
|
54638
|
+
resolve5(JSON.parse(body || "{}"));
|
|
54362
54639
|
} catch {
|
|
54363
|
-
|
|
54640
|
+
resolve5({});
|
|
54364
54641
|
}
|
|
54365
54642
|
});
|
|
54366
54643
|
});
|
|
@@ -54426,11 +54703,11 @@ function removeRegistryFootprint() {
|
|
|
54426
54703
|
}
|
|
54427
54704
|
}
|
|
54428
54705
|
function promptYesNo(question) {
|
|
54429
|
-
return new Promise((
|
|
54706
|
+
return new Promise((resolve5) => {
|
|
54430
54707
|
const rl = (0, import_node_readline.createInterface)({ input: process.stdin, output: process.stdout });
|
|
54431
54708
|
rl.question(`${question} `, (answer) => {
|
|
54432
54709
|
rl.close();
|
|
54433
|
-
|
|
54710
|
+
resolve5(/^y(es)?$/i.test((answer ?? "").trim()));
|
|
54434
54711
|
});
|
|
54435
54712
|
});
|
|
54436
54713
|
}
|
|
@@ -54484,7 +54761,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null) {
|
|
|
54484
54761
|
}
|
|
54485
54762
|
await action(parseTeardownFlags(flagArgv));
|
|
54486
54763
|
}
|
|
54487
|
-
var entry = (0,
|
|
54764
|
+
var entry = (0, import_node_path15.basename)(process.argv[1] ?? "").toLowerCase();
|
|
54488
54765
|
if (entry === "launch.mjs") {
|
|
54489
54766
|
runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
|
|
54490
54767
|
log(`error: ${e?.message ?? e}`);
|
|
@@ -54558,9 +54835,9 @@ function awareUpgradeBlockReason(s) {
|
|
|
54558
54835
|
}
|
|
54559
54836
|
|
|
54560
54837
|
// skill-sync.ts
|
|
54561
|
-
var
|
|
54562
|
-
var
|
|
54563
|
-
var
|
|
54838
|
+
var import_node_fs18 = require("node:fs");
|
|
54839
|
+
var import_node_os11 = require("node:os");
|
|
54840
|
+
var import_node_path16 = require("node:path");
|
|
54564
54841
|
var import_node_url2 = require("node:url");
|
|
54565
54842
|
var import_yaml5 = __toESM(require_dist6(), 1);
|
|
54566
54843
|
|
|
@@ -54574,6 +54851,8 @@ var PRODUCT_SKILLS = [
|
|
|
54574
54851
|
// file a diagnosed bug/idea/question to the private log via the floless.io relay
|
|
54575
54852
|
"floless-app-routines",
|
|
54576
54853
|
// author event-driven ("on trigger") routines
|
|
54854
|
+
"floless-app-ui",
|
|
54855
|
+
// compose Custom Panels (~/.floless/ui/extensions.json) for the Dashboard
|
|
54577
54856
|
"floless-app-workflows"
|
|
54578
54857
|
// author/run .flo workflows
|
|
54579
54858
|
];
|
|
@@ -54583,30 +54862,30 @@ function selectShippedSkillNames(names) {
|
|
|
54583
54862
|
}
|
|
54584
54863
|
|
|
54585
54864
|
// skill-sync.ts
|
|
54586
|
-
var __dirname3 = (0,
|
|
54865
|
+
var __dirname3 = (0, import_node_path16.dirname)((0, import_node_url2.fileURLToPath)(__import_meta_url));
|
|
54587
54866
|
function bundledSkillsRoot() {
|
|
54588
54867
|
const candidates = [
|
|
54589
|
-
(0,
|
|
54590
|
-
(0,
|
|
54591
|
-
(0,
|
|
54868
|
+
(0, import_node_path16.join)(__dirname3, "skills"),
|
|
54869
|
+
(0, import_node_path16.join)((0, import_node_path16.dirname)(process.execPath), "skills"),
|
|
54870
|
+
(0, import_node_path16.join)(__dirname3, "..", ".claude", "skills")
|
|
54592
54871
|
];
|
|
54593
|
-
return candidates.find((p) => (0,
|
|
54872
|
+
return candidates.find((p) => (0, import_node_fs18.existsSync)(p)) ?? null;
|
|
54594
54873
|
}
|
|
54595
54874
|
function targetConfigDirs() {
|
|
54596
54875
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
54597
54876
|
if (override) {
|
|
54598
54877
|
return override.split(";").map((d) => d.trim()).filter(Boolean).map((dir) => ({ runtime: "custom", dir }));
|
|
54599
54878
|
}
|
|
54600
|
-
const home = (0,
|
|
54879
|
+
const home = (0, import_node_os11.homedir)();
|
|
54601
54880
|
return [
|
|
54602
|
-
{ runtime: "claude", dir: (0,
|
|
54603
|
-
{ runtime: "codex", dir: (0,
|
|
54604
|
-
{ runtime: "opencode", dir: (0,
|
|
54881
|
+
{ runtime: "claude", dir: (0, import_node_path16.join)(home, ".claude") },
|
|
54882
|
+
{ runtime: "codex", dir: (0, import_node_path16.join)(home, ".codex") },
|
|
54883
|
+
{ runtime: "opencode", dir: (0, import_node_path16.join)(home, ".opencode") }
|
|
54605
54884
|
];
|
|
54606
54885
|
}
|
|
54607
54886
|
function skillVersion(skillMdPath) {
|
|
54608
54887
|
try {
|
|
54609
|
-
const text = (0,
|
|
54888
|
+
const text = (0, import_node_fs18.readFileSync)(skillMdPath, "utf8");
|
|
54610
54889
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
54611
54890
|
if (!m || m[1] === void 0) return null;
|
|
54612
54891
|
const fm = (0, import_yaml5.parse)(m[1]);
|
|
@@ -54646,21 +54925,21 @@ function decideAction(installed, bundled) {
|
|
|
54646
54925
|
function bundledSkills(root) {
|
|
54647
54926
|
let entries = [];
|
|
54648
54927
|
try {
|
|
54649
|
-
entries = selectShippedSkillNames((0,
|
|
54928
|
+
entries = selectShippedSkillNames((0, import_node_fs18.readdirSync)(root));
|
|
54650
54929
|
} catch {
|
|
54651
54930
|
return [];
|
|
54652
54931
|
}
|
|
54653
54932
|
const out = [];
|
|
54654
54933
|
for (const name of entries) {
|
|
54655
|
-
const dir = (0,
|
|
54934
|
+
const dir = (0, import_node_path16.join)(root, name);
|
|
54656
54935
|
let isDir = false;
|
|
54657
54936
|
try {
|
|
54658
|
-
isDir = (0,
|
|
54937
|
+
isDir = (0, import_node_fs18.statSync)(dir).isDirectory();
|
|
54659
54938
|
} catch {
|
|
54660
54939
|
isDir = false;
|
|
54661
54940
|
}
|
|
54662
54941
|
if (!isDir) continue;
|
|
54663
|
-
const v = skillVersion((0,
|
|
54942
|
+
const v = skillVersion((0, import_node_path16.join)(dir, "SKILL.md"));
|
|
54664
54943
|
if (!v) continue;
|
|
54665
54944
|
out.push({ name, dir, version: v });
|
|
54666
54945
|
}
|
|
@@ -54673,17 +54952,17 @@ function syncSkills() {
|
|
|
54673
54952
|
const skills = bundledSkills(root);
|
|
54674
54953
|
if (!skills.length) return results;
|
|
54675
54954
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
54676
|
-
if (!(0,
|
|
54677
|
-
const skillsDir = (0,
|
|
54955
|
+
if (!(0, import_node_fs18.existsSync)(cfg)) continue;
|
|
54956
|
+
const skillsDir = (0, import_node_path16.join)(cfg, "skills");
|
|
54678
54957
|
for (const s of skills) {
|
|
54679
|
-
const dest = (0,
|
|
54680
|
-
const installedMd = (0,
|
|
54681
|
-
const installed = (0,
|
|
54958
|
+
const dest = (0, import_node_path16.join)(skillsDir, s.name);
|
|
54959
|
+
const installedMd = (0, import_node_path16.join)(dest, "SKILL.md");
|
|
54960
|
+
const installed = (0, import_node_fs18.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
54682
54961
|
const action = decideAction(installed, s.version);
|
|
54683
54962
|
if (action === "installed" || action === "updated") {
|
|
54684
54963
|
try {
|
|
54685
|
-
if (action === "updated") (0,
|
|
54686
|
-
(0,
|
|
54964
|
+
if (action === "updated") (0, import_node_fs18.rmSync)(dest, { recursive: true, force: true });
|
|
54965
|
+
(0, import_node_fs18.cpSync)(s.dir, dest, { recursive: true });
|
|
54687
54966
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
54688
54967
|
} catch {
|
|
54689
54968
|
}
|
|
@@ -54696,9 +54975,9 @@ function syncSkills() {
|
|
|
54696
54975
|
}
|
|
54697
54976
|
|
|
54698
54977
|
// watch.ts
|
|
54699
|
-
var
|
|
54700
|
-
var
|
|
54701
|
-
var
|
|
54978
|
+
var import_node_os12 = require("node:os");
|
|
54979
|
+
var import_node_path18 = require("node:path");
|
|
54980
|
+
var import_node_fs19 = require("node:fs");
|
|
54702
54981
|
|
|
54703
54982
|
// node_modules/chokidar/esm/index.js
|
|
54704
54983
|
var import_fs2 = require("fs");
|
|
@@ -54709,7 +54988,7 @@ var sysPath2 = __toESM(require("path"), 1);
|
|
|
54709
54988
|
// node_modules/readdirp/esm/index.js
|
|
54710
54989
|
var import_promises2 = require("node:fs/promises");
|
|
54711
54990
|
var import_node_stream2 = require("node:stream");
|
|
54712
|
-
var
|
|
54991
|
+
var import_node_path17 = require("node:path");
|
|
54713
54992
|
var EntryTypes = {
|
|
54714
54993
|
FILE_TYPE: "files",
|
|
54715
54994
|
DIR_TYPE: "directories",
|
|
@@ -54784,7 +55063,7 @@ var ReaddirpStream = class extends import_node_stream2.Readable {
|
|
|
54784
55063
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
54785
55064
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
54786
55065
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
54787
|
-
this._root = (0,
|
|
55066
|
+
this._root = (0, import_node_path17.resolve)(root);
|
|
54788
55067
|
this._isDirent = !opts.alwaysStat;
|
|
54789
55068
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
54790
55069
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
@@ -54855,8 +55134,8 @@ var ReaddirpStream = class extends import_node_stream2.Readable {
|
|
|
54855
55134
|
let entry2;
|
|
54856
55135
|
const basename5 = this._isDirent ? dirent.name : dirent;
|
|
54857
55136
|
try {
|
|
54858
|
-
const fullPath = (0,
|
|
54859
|
-
entry2 = { path: (0,
|
|
55137
|
+
const fullPath = (0, import_node_path17.resolve)((0, import_node_path17.join)(path, basename5));
|
|
55138
|
+
entry2 = { path: (0, import_node_path17.relative)(this._root, fullPath), fullPath, basename: basename5 };
|
|
54860
55139
|
entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
54861
55140
|
} catch (err) {
|
|
54862
55141
|
this._onError(err);
|
|
@@ -54890,7 +55169,7 @@ var ReaddirpStream = class extends import_node_stream2.Readable {
|
|
|
54890
55169
|
}
|
|
54891
55170
|
if (entryRealPathStats.isDirectory()) {
|
|
54892
55171
|
const len = entryRealPath.length;
|
|
54893
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
55172
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path17.sep) {
|
|
54894
55173
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
54895
55174
|
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
54896
55175
|
return this._onError(recursiveError);
|
|
@@ -55554,7 +55833,7 @@ var NodeFsHandler = class {
|
|
|
55554
55833
|
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
55555
55834
|
}
|
|
55556
55835
|
}).on(EV.ERROR, this._boundHandleError);
|
|
55557
|
-
return new Promise((
|
|
55836
|
+
return new Promise((resolve5, reject) => {
|
|
55558
55837
|
if (!stream)
|
|
55559
55838
|
return reject();
|
|
55560
55839
|
stream.once(STR_END, () => {
|
|
@@ -55563,7 +55842,7 @@ var NodeFsHandler = class {
|
|
|
55563
55842
|
return;
|
|
55564
55843
|
}
|
|
55565
55844
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
55566
|
-
|
|
55845
|
+
resolve5(void 0);
|
|
55567
55846
|
previous.getChildren().filter((item) => {
|
|
55568
55847
|
return item !== directory && !current.has(item);
|
|
55569
55848
|
}).forEach((item) => {
|
|
@@ -56397,16 +56676,34 @@ function appIdFromLogPath(path) {
|
|
|
56397
56676
|
const i = parts.lastIndexOf("logs");
|
|
56398
56677
|
return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
|
|
56399
56678
|
}
|
|
56679
|
+
function samePath(a, b) {
|
|
56680
|
+
const ra = (0, import_node_path18.resolve)(a);
|
|
56681
|
+
const rb = (0, import_node_path18.resolve)(b);
|
|
56682
|
+
return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
|
|
56683
|
+
}
|
|
56684
|
+
function underDir(path, dir) {
|
|
56685
|
+
const rp = (0, import_node_path18.resolve)(path);
|
|
56686
|
+
const rd = (0, import_node_path18.resolve)(dir);
|
|
56687
|
+
const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
|
|
56688
|
+
return p === d || p.startsWith(d + import_node_path18.sep);
|
|
56689
|
+
}
|
|
56400
56690
|
function startWatcher() {
|
|
56401
|
-
const awareDir = process.env.AWARE_HOME ?? (0,
|
|
56402
|
-
const credentialsDir = (0,
|
|
56403
|
-
if (!(0,
|
|
56691
|
+
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path18.join)((0, import_node_os12.homedir)(), ".aware");
|
|
56692
|
+
const credentialsDir = (0, import_node_path18.join)(awareDir, "credentials");
|
|
56693
|
+
if (!(0, import_node_fs19.existsSync)(credentialsDir)) {
|
|
56404
56694
|
try {
|
|
56405
|
-
(0,
|
|
56695
|
+
(0, import_node_fs19.mkdirSync)(credentialsDir, { recursive: true });
|
|
56406
56696
|
} catch {
|
|
56407
56697
|
}
|
|
56408
56698
|
}
|
|
56409
|
-
|
|
56699
|
+
if (!(0, import_node_fs19.existsSync)(uiDir)) {
|
|
56700
|
+
try {
|
|
56701
|
+
(0, import_node_fs19.mkdirSync)(uiDir, { recursive: true });
|
|
56702
|
+
} catch {
|
|
56703
|
+
}
|
|
56704
|
+
}
|
|
56705
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path18.join)(awareDir, d)).filter((p) => (0, import_node_fs19.existsSync)(p));
|
|
56706
|
+
if ((0, import_node_fs19.existsSync)(uiDir)) targets.push(uiDir);
|
|
56410
56707
|
if (targets.length === 0) {
|
|
56411
56708
|
return null;
|
|
56412
56709
|
}
|
|
@@ -56414,15 +56711,33 @@ function startWatcher() {
|
|
|
56414
56711
|
ignoreInitial: true,
|
|
56415
56712
|
awaitWriteFinish: { stabilityThreshold: 150, pollInterval: 50 }
|
|
56416
56713
|
});
|
|
56714
|
+
let lastExtContent = readExtensionsText();
|
|
56715
|
+
const handleExtensionsChange = () => {
|
|
56716
|
+
const next = readExtensionsText();
|
|
56717
|
+
if (next === lastExtContent) return;
|
|
56718
|
+
if (lastExtContent !== null) {
|
|
56719
|
+
try {
|
|
56720
|
+
snapshotExtensions(lastExtContent);
|
|
56721
|
+
} catch (err) {
|
|
56722
|
+
console.warn("[floless] failed to snapshot the previous extensions.json before a change (undo for this step is lost):", err);
|
|
56723
|
+
}
|
|
56724
|
+
}
|
|
56725
|
+
lastExtContent = next;
|
|
56726
|
+
broadcast({ type: "extensions-changed" });
|
|
56727
|
+
};
|
|
56417
56728
|
watcher.on("all", (event, path) => {
|
|
56729
|
+
if (underDir(path, uiDir)) {
|
|
56730
|
+
if (samePath(path, extensionsFile)) handleExtensionsChange();
|
|
56731
|
+
return;
|
|
56732
|
+
}
|
|
56418
56733
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
56419
56734
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
56420
56735
|
broadcast({ type: "fs-change", kind, event, path });
|
|
56421
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
56736
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs19.existsSync)(path)) {
|
|
56422
56737
|
const id = appIdFromLogPath(path);
|
|
56423
56738
|
if (!id) return;
|
|
56424
56739
|
try {
|
|
56425
|
-
broadcast({ type: "trace-file", id, runId: path.split(
|
|
56740
|
+
broadcast({ type: "trace-file", id, runId: path.split(import_node_path18.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs19.readFileSync)(path, "utf8")) });
|
|
56426
56741
|
} catch {
|
|
56427
56742
|
}
|
|
56428
56743
|
}
|
|
@@ -56431,10 +56746,10 @@ function startWatcher() {
|
|
|
56431
56746
|
}
|
|
56432
56747
|
|
|
56433
56748
|
// index.ts
|
|
56434
|
-
var __dirname4 = (0,
|
|
56435
|
-
var WEB_ROOT = [(0,
|
|
56436
|
-
(p) => (0,
|
|
56437
|
-
) ?? (0,
|
|
56749
|
+
var __dirname4 = (0, import_node_path19.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
56750
|
+
var WEB_ROOT = [(0, import_node_path19.join)(__dirname4, "web"), (0, import_node_path19.join)((0, import_node_path19.dirname)(process.execPath), "web"), (0, import_node_path19.join)(__dirname4, "..", "web")].find(
|
|
56751
|
+
(p) => (0, import_node_fs20.existsSync)(p)
|
|
56752
|
+
) ?? (0, import_node_path19.join)(__dirname4, "..", "web");
|
|
56438
56753
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
56439
56754
|
var HOST = "127.0.0.1";
|
|
56440
56755
|
function extractReportHtml(events) {
|
|
@@ -56461,7 +56776,7 @@ function installCrashHandlers() {
|
|
|
56461
56776
|
${stack}
|
|
56462
56777
|
`;
|
|
56463
56778
|
try {
|
|
56464
|
-
(0,
|
|
56779
|
+
(0, import_node_fs20.appendFileSync)(logFilePath(), line);
|
|
56465
56780
|
} catch {
|
|
56466
56781
|
}
|
|
56467
56782
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -56504,7 +56819,7 @@ async function startServer() {
|
|
|
56504
56819
|
};
|
|
56505
56820
|
function installAwareGlobal(spec, onLine = () => {
|
|
56506
56821
|
}) {
|
|
56507
|
-
return new Promise((
|
|
56822
|
+
return new Promise((resolve5, reject) => {
|
|
56508
56823
|
const child = (0, import_node_child_process6.spawn)("npm", ["i", "-g", `@aware-aeco/cli@${spec}`], { shell: isWin3, windowsHide: true });
|
|
56509
56824
|
let stderrTail = "";
|
|
56510
56825
|
let combinedTail = "";
|
|
@@ -56521,7 +56836,7 @@ async function startServer() {
|
|
|
56521
56836
|
onLine(s.trimEnd());
|
|
56522
56837
|
});
|
|
56523
56838
|
child.on("error", (e) => reject(e));
|
|
56524
|
-
child.on("close", (code) => code === 0 ?
|
|
56839
|
+
child.on("close", (code) => code === 0 ? resolve5() : reject(new Error(`npm exited ${code}: ${stderrTail || combinedTail}`)));
|
|
56525
56840
|
});
|
|
56526
56841
|
}
|
|
56527
56842
|
const bootstrapDeps = {
|
|
@@ -56548,6 +56863,9 @@ async function startServer() {
|
|
|
56548
56863
|
app.log.warn({ detail: err.detail }, err.message);
|
|
56549
56864
|
return reply.status(502).send({ ok: false, error: err.message, detail: err.detail ?? null });
|
|
56550
56865
|
}
|
|
56866
|
+
if (err.statusCode === 413) {
|
|
56867
|
+
return reply.status(413).send({ ok: false, error: "too_large" });
|
|
56868
|
+
}
|
|
56551
56869
|
app.log.error(err);
|
|
56552
56870
|
return reply.status(500).send({ ok: false, error: err.message });
|
|
56553
56871
|
});
|
|
@@ -56628,6 +56946,20 @@ async function startServer() {
|
|
|
56628
56946
|
return reply.status(status).send({ ok: false, error: result.error });
|
|
56629
56947
|
}
|
|
56630
56948
|
);
|
|
56949
|
+
app.post(
|
|
56950
|
+
"/api/share-report",
|
|
56951
|
+
{ bodyLimit: 6 * 1024 * 1024 },
|
|
56952
|
+
async (req, reply) => {
|
|
56953
|
+
const b = req.body ?? {};
|
|
56954
|
+
const html = typeof b.html === "string" ? b.html : "";
|
|
56955
|
+
const title = typeof b.title === "string" ? b.title.trim().slice(0, 200) : "";
|
|
56956
|
+
if (!html) return reply.status(400).send({ ok: false, error: "html is required" });
|
|
56957
|
+
const result = await shareReport({ title: title || "FloLess report", html });
|
|
56958
|
+
if (result.ok) return { ok: true, url: result.url };
|
|
56959
|
+
const status = result.error === "signed_out" ? 401 : result.error === "no_subscription" ? 403 : result.error === "rate_limited" ? 429 : result.error === "too_large" ? 413 : 503;
|
|
56960
|
+
return reply.status(status).send({ ok: false, error: result.error });
|
|
56961
|
+
}
|
|
56962
|
+
);
|
|
56631
56963
|
app.get("/api/autostart", async () => {
|
|
56632
56964
|
const supported = autostartSupported();
|
|
56633
56965
|
return { ok: true, supported, enabled: supported ? autostartPresent() : false };
|
|
@@ -56789,13 +57121,13 @@ async function startServer() {
|
|
|
56789
57121
|
}
|
|
56790
57122
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
56791
57123
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
56792
|
-
const tmpRoot = (0,
|
|
56793
|
-
const backupDir = (0,
|
|
56794
|
-
const bakeDir = (0,
|
|
56795
|
-
(0,
|
|
56796
|
-
(0,
|
|
57124
|
+
const tmpRoot = (0, import_node_fs20.mkdtempSync)((0, import_node_path19.join)((0, import_node_os13.tmpdir)(), "floless-bake-"));
|
|
57125
|
+
const backupDir = (0, import_node_path19.join)(tmpRoot, `${id}-backup`);
|
|
57126
|
+
const bakeDir = (0, import_node_path19.join)(tmpRoot, id);
|
|
57127
|
+
(0, import_node_fs20.cpSync)(appDir(id), backupDir, { recursive: true });
|
|
57128
|
+
(0, import_node_fs20.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
56797
57129
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
56798
|
-
(0,
|
|
57130
|
+
(0, import_node_fs20.writeFileSync)((0, import_node_path19.join)(bakeDir, floName), baked);
|
|
56799
57131
|
let appInstalled = true;
|
|
56800
57132
|
try {
|
|
56801
57133
|
await aware.uninstall(id);
|
|
@@ -56817,17 +57149,17 @@ async function startServer() {
|
|
|
56817
57149
|
throw installErr;
|
|
56818
57150
|
}
|
|
56819
57151
|
try {
|
|
56820
|
-
await aware.compile((0,
|
|
57152
|
+
await aware.compile((0, import_node_path19.join)(appDir(id), floName));
|
|
56821
57153
|
} catch (compileErr) {
|
|
56822
57154
|
app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
|
|
56823
57155
|
}
|
|
56824
57156
|
broadcast({ type: "baked", id });
|
|
56825
57157
|
return { ok: true, id, agent: id, inputs };
|
|
56826
57158
|
} finally {
|
|
56827
|
-
if (appInstalled) (0,
|
|
57159
|
+
if (appInstalled) (0, import_node_fs20.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
56828
57160
|
}
|
|
56829
57161
|
});
|
|
56830
|
-
const graftAgentsDir = () => (0,
|
|
57162
|
+
const graftAgentsDir = () => (0, import_node_path19.join)((0, import_node_os13.homedir)(), ".aware", "agents");
|
|
56831
57163
|
app.post("/api/graft/match", async (req, reply) => {
|
|
56832
57164
|
const { glob } = req.body ?? {};
|
|
56833
57165
|
if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
|
|
@@ -56844,7 +57176,7 @@ async function startServer() {
|
|
|
56844
57176
|
if (!sourceKind || !sourceRef) {
|
|
56845
57177
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
56846
57178
|
}
|
|
56847
|
-
const tempHome = (0,
|
|
57179
|
+
const tempHome = (0, import_node_fs20.mkdtempSync)((0, import_node_path19.join)((0, import_node_os13.tmpdir)(), "floless-graft-"));
|
|
56848
57180
|
let result;
|
|
56849
57181
|
try {
|
|
56850
57182
|
result = await aware.build({
|
|
@@ -56857,19 +57189,19 @@ async function startServer() {
|
|
|
56857
57189
|
awareHome: tempHome
|
|
56858
57190
|
});
|
|
56859
57191
|
} catch (err) {
|
|
56860
|
-
(0,
|
|
57192
|
+
(0, import_node_fs20.rmSync)(tempHome, { recursive: true, force: true });
|
|
56861
57193
|
const msg = err instanceof AwareError ? err.message : String(err?.message ?? err);
|
|
56862
57194
|
return reply.status(422).send({ ok: false, error: msg });
|
|
56863
57195
|
}
|
|
56864
57196
|
const manifest = readStagedManifest(result.agentDir);
|
|
56865
57197
|
if (!manifest) {
|
|
56866
|
-
(0,
|
|
57198
|
+
(0, import_node_fs20.rmSync)(tempHome, { recursive: true, force: true });
|
|
56867
57199
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
56868
57200
|
}
|
|
56869
|
-
const token = (0,
|
|
57201
|
+
const token = (0, import_node_crypto6.randomUUID)();
|
|
56870
57202
|
registerStage(token, tempHome, result.agentId);
|
|
56871
57203
|
const preview = buildPreview(manifest, sourceKind, sourceRef, token);
|
|
56872
|
-
if ((0,
|
|
57204
|
+
if ((0, import_node_fs20.existsSync)((0, import_node_path19.join)(graftAgentsDir(), result.agentId))) {
|
|
56873
57205
|
preview.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
56874
57206
|
}
|
|
56875
57207
|
return { ok: true, preview };
|
|
@@ -56888,7 +57220,7 @@ async function startServer() {
|
|
|
56888
57220
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
56889
57221
|
return reply.status(409).send({ ok: false, error: err.message, agentId: stage.agentId, collision: true });
|
|
56890
57222
|
}
|
|
56891
|
-
(0,
|
|
57223
|
+
(0, import_node_fs20.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
56892
57224
|
throw err;
|
|
56893
57225
|
}
|
|
56894
57226
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -57062,11 +57394,11 @@ async function startServer() {
|
|
|
57062
57394
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
57063
57395
|
const n = Number.parseInt(req.params.n, 10);
|
|
57064
57396
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
57065
|
-
if (!p || !(0,
|
|
57397
|
+
if (!p || !(0, import_node_fs20.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
57066
57398
|
const ext = p.split(".").pop().toLowerCase();
|
|
57067
57399
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : "image/jpeg");
|
|
57068
57400
|
reply.header("Cache-Control", "no-store");
|
|
57069
|
-
return (0,
|
|
57401
|
+
return (0, import_node_fs20.readFileSync)(p);
|
|
57070
57402
|
});
|
|
57071
57403
|
app.post(
|
|
57072
57404
|
"/api/tweak",
|
|
@@ -57106,6 +57438,158 @@ async function startServer() {
|
|
|
57106
57438
|
broadcast({ type: "requests-changed" });
|
|
57107
57439
|
return { ok: true, cleared };
|
|
57108
57440
|
});
|
|
57441
|
+
const EXT_SOURCE_REF = /^[A-Za-z0-9._-]+$/;
|
|
57442
|
+
function pickRows(v) {
|
|
57443
|
+
const isRowArray = (x) => Array.isArray(x) && x.length > 0 && x.every((r) => !!r && typeof r === "object" && !Array.isArray(r));
|
|
57444
|
+
if (isRowArray(v)) return v;
|
|
57445
|
+
if (v && typeof v === "object") {
|
|
57446
|
+
for (const key of ["rows", "items", "data"]) {
|
|
57447
|
+
const inner = v[key];
|
|
57448
|
+
if (isRowArray(inner)) return inner;
|
|
57449
|
+
}
|
|
57450
|
+
}
|
|
57451
|
+
return null;
|
|
57452
|
+
}
|
|
57453
|
+
function extractRunRows(events) {
|
|
57454
|
+
let rows = null;
|
|
57455
|
+
for (const ev of events) {
|
|
57456
|
+
const data = ev.data;
|
|
57457
|
+
if (!data || typeof data !== "object") continue;
|
|
57458
|
+
const found = pickRows(data.result ?? data);
|
|
57459
|
+
if (found) rows = found;
|
|
57460
|
+
}
|
|
57461
|
+
return rows;
|
|
57462
|
+
}
|
|
57463
|
+
const EXT_TRACE_MAX_BYTES = 5 * 1024 * 1024;
|
|
57464
|
+
function resolveExtensionSource(source, warn = () => {
|
|
57465
|
+
}) {
|
|
57466
|
+
const sep3 = source.indexOf(":");
|
|
57467
|
+
if (sep3 <= 0) return void 0;
|
|
57468
|
+
const kind = source.slice(0, sep3);
|
|
57469
|
+
const ref = source.slice(sep3 + 1);
|
|
57470
|
+
if (!EXT_SOURCE_REF.test(ref)) return void 0;
|
|
57471
|
+
if (kind === "last-run-output") {
|
|
57472
|
+
const latest = readLatestTrace(ref, void 0, EXT_TRACE_MAX_BYTES);
|
|
57473
|
+
if (!latest) return void 0;
|
|
57474
|
+
const events = parseTrace(latest.text);
|
|
57475
|
+
if (!latest.truncated && isTraceCorrupt(events)) {
|
|
57476
|
+
warn(`last-run-output:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
57477
|
+
return { appId: ref, runId: latest.runId, status: "unknown", rows: null, html: null, traceUnreadable: true };
|
|
57478
|
+
}
|
|
57479
|
+
return {
|
|
57480
|
+
appId: ref,
|
|
57481
|
+
runId: latest.runId,
|
|
57482
|
+
status: summarizeRun(events).status,
|
|
57483
|
+
rows: extractRunRows(events),
|
|
57484
|
+
html: withBadge(extractReportHtml(events))?.html ?? null
|
|
57485
|
+
};
|
|
57486
|
+
}
|
|
57487
|
+
if (kind === "last-run-status") {
|
|
57488
|
+
const latest = readLatestTrace(ref, void 0, EXT_TRACE_MAX_BYTES);
|
|
57489
|
+
if (!latest) return { appId: ref, status: "none", finishedAt: null, runId: null };
|
|
57490
|
+
const events = parseTrace(latest.text);
|
|
57491
|
+
if (!latest.truncated && isTraceCorrupt(events)) {
|
|
57492
|
+
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
57493
|
+
let finishedAt2 = null;
|
|
57494
|
+
try {
|
|
57495
|
+
finishedAt2 = (0, import_node_fs20.statSync)(latest.path).mtime.toISOString();
|
|
57496
|
+
} catch {
|
|
57497
|
+
finishedAt2 = null;
|
|
57498
|
+
}
|
|
57499
|
+
return { appId: ref, status: "unknown", finishedAt: finishedAt2, runId: latest.runId, traceUnreadable: true };
|
|
57500
|
+
}
|
|
57501
|
+
const runEnd = [...events].reverse().find((e) => e.kind === "run-end");
|
|
57502
|
+
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
57503
|
+
if (!finishedAt) {
|
|
57504
|
+
try {
|
|
57505
|
+
finishedAt = (0, import_node_fs20.statSync)(latest.path).mtime.toISOString();
|
|
57506
|
+
} catch {
|
|
57507
|
+
finishedAt = null;
|
|
57508
|
+
}
|
|
57509
|
+
}
|
|
57510
|
+
return { appId: ref, status: summarizeRun(events).status, finishedAt, runId: latest.runId };
|
|
57511
|
+
}
|
|
57512
|
+
if (kind === "routine-status") {
|
|
57513
|
+
const routines2 = listRoutines();
|
|
57514
|
+
const r = routines2.find((x) => x.id === ref) ?? routines2.find((x) => x.workflow === ref);
|
|
57515
|
+
if (!r) return void 0;
|
|
57516
|
+
return {
|
|
57517
|
+
id: r.id,
|
|
57518
|
+
name: r.name,
|
|
57519
|
+
workflow: r.workflow,
|
|
57520
|
+
kind: r.kind,
|
|
57521
|
+
enabled: r.enabled,
|
|
57522
|
+
nextFireAt: r.nextFireAt,
|
|
57523
|
+
lastRun: r.lastRun,
|
|
57524
|
+
broken: r.broken ?? null
|
|
57525
|
+
};
|
|
57526
|
+
}
|
|
57527
|
+
return void 0;
|
|
57528
|
+
}
|
|
57529
|
+
let uiAgentInstallKicked = false;
|
|
57530
|
+
let validationCache = null;
|
|
57531
|
+
app.get("/api/extensions", async () => {
|
|
57532
|
+
const descriptor = readExtensions();
|
|
57533
|
+
let validation = null;
|
|
57534
|
+
if (descriptor !== null) {
|
|
57535
|
+
const cacheKey = JSON.stringify(descriptor);
|
|
57536
|
+
if (validationCache && validationCache.key === cacheKey) {
|
|
57537
|
+
return finishExtensions(descriptor, validationCache.result);
|
|
57538
|
+
}
|
|
57539
|
+
try {
|
|
57540
|
+
validation = await aware.agentInvoke("ui", "validate", { descriptor }) ?? null;
|
|
57541
|
+
if (validation) validationCache = { key: cacheKey, result: validation };
|
|
57542
|
+
} catch (err) {
|
|
57543
|
+
const mapped = classifyValidateError(err);
|
|
57544
|
+
if (mapped.installing && !uiAgentInstallKicked) {
|
|
57545
|
+
uiAgentInstallKicked = true;
|
|
57546
|
+
aware.ensureAgentInstalled("ui").then(() => broadcast({ type: "extensions-changed" })).catch((e) => app.log.warn({ err: String(e) }, "ui agent auto-install failed"));
|
|
57547
|
+
}
|
|
57548
|
+
if (mapped.unexpected) app.log.warn({ err: String(err) }, "ui validate failed unexpectedly");
|
|
57549
|
+
validation = mapped;
|
|
57550
|
+
if (!mapped.installing && !mapped.unexpected) validationCache = { key: cacheKey, result: validation };
|
|
57551
|
+
}
|
|
57552
|
+
}
|
|
57553
|
+
return finishExtensions(descriptor, validation);
|
|
57554
|
+
});
|
|
57555
|
+
function finishExtensions(descriptor, validation) {
|
|
57556
|
+
const data = {};
|
|
57557
|
+
for (const panel of descriptorPanels(descriptor)) {
|
|
57558
|
+
const blocks = Array.isArray(panel.blocks) ? panel.blocks : [];
|
|
57559
|
+
for (const block of blocks) {
|
|
57560
|
+
if (!block || typeof block !== "object") continue;
|
|
57561
|
+
const b = block;
|
|
57562
|
+
if (b.type !== "table" && b.type !== "report") continue;
|
|
57563
|
+
const src = b.source;
|
|
57564
|
+
if (typeof src !== "string" || src in data) continue;
|
|
57565
|
+
try {
|
|
57566
|
+
const payload = resolveExtensionSource(src, (msg) => app.log.warn(msg));
|
|
57567
|
+
if (payload !== void 0) data[src] = payload;
|
|
57568
|
+
} catch {
|
|
57569
|
+
}
|
|
57570
|
+
}
|
|
57571
|
+
}
|
|
57572
|
+
return { ok: true, descriptor, validation, data };
|
|
57573
|
+
}
|
|
57574
|
+
app.post("/api/extensions/customize", async (req, reply) => {
|
|
57575
|
+
const instruction = typeof req.body?.instruction === "string" ? req.body.instruction.trim() : "";
|
|
57576
|
+
if (!instruction) return reply.status(400).send({ ok: false, error: "instruction required" });
|
|
57577
|
+
const panelId = typeof req.body?.panelId === "string" && req.body.panelId.trim() ? req.body.panelId.trim() : void 0;
|
|
57578
|
+
const request = addRequest({ type: "ui-customize", instruction, ...panelId ? { panelId } : {} });
|
|
57579
|
+
broadcast({ type: "request-added", request });
|
|
57580
|
+
return { ok: true, request };
|
|
57581
|
+
});
|
|
57582
|
+
app.post("/api/extensions/undo", async (_req, reply) => {
|
|
57583
|
+
const result = undoExtensions();
|
|
57584
|
+
if (!result.restored) return reply.send({ ok: false, error: "nothing to undo" });
|
|
57585
|
+
return { ok: true, descriptor: result.descriptor };
|
|
57586
|
+
});
|
|
57587
|
+
app.post("/api/extensions/reset", async (_req, reply) => {
|
|
57588
|
+
const result = resetExtensions();
|
|
57589
|
+
if (!result.reset) return reply.send({ ok: false, error: "nothing to reset \u2014 the dashboard is already the default" });
|
|
57590
|
+
return { ok: true, descriptor: null };
|
|
57591
|
+
});
|
|
57592
|
+
app.get("/api/extensions/history", async () => ({ ok: true, history: listHistory() }));
|
|
57109
57593
|
app.get("/api/events", async (_req, reply) => {
|
|
57110
57594
|
reply.hijack();
|
|
57111
57595
|
reply.raw.writeHead(200, {
|
|
@@ -57171,11 +57655,11 @@ function unregisterProtocol() {
|
|
|
57171
57655
|
|
|
57172
57656
|
// main.ts
|
|
57173
57657
|
function promptYesNo2(question) {
|
|
57174
|
-
return new Promise((
|
|
57658
|
+
return new Promise((resolve5) => {
|
|
57175
57659
|
const rl = (0, import_node_readline2.createInterface)({ input: process.stdin, output: process.stdout });
|
|
57176
57660
|
rl.question(`${question} `, (answer) => {
|
|
57177
57661
|
rl.close();
|
|
57178
|
-
|
|
57662
|
+
resolve5(/^y(es)?$/i.test((answer ?? "").trim()));
|
|
57179
57663
|
});
|
|
57180
57664
|
});
|
|
57181
57665
|
}
|