@floless/app 0.6.2 → 0.7.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 +339 -206
- package/dist/web/aware.js +11 -2
- package/launch.mjs +5 -1
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -5489,7 +5489,7 @@ var require_thread_stream = __commonJS({
|
|
|
5489
5489
|
var { version } = require_package();
|
|
5490
5490
|
var { EventEmitter: EventEmitter2 } = require("events");
|
|
5491
5491
|
var { Worker } = require("worker_threads");
|
|
5492
|
-
var { join:
|
|
5492
|
+
var { join: join20 } = 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"] || join20(__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: existsSync18 } = require("node:fs");
|
|
6010
6010
|
var getCallers = require_caller();
|
|
6011
|
-
var { join:
|
|
6011
|
+
var { join: join20, 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) && !existsSync18(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"] || join20(__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"] || join20(__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 join20(__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 join20 = ",";
|
|
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
|
+
join20 = `,
|
|
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 += join20;
|
|
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 += `${join20}"... ${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
|
+
join20 = `,
|
|
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 = join20;
|
|
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 = join20;
|
|
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 join20 = ",";
|
|
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
|
+
join20 = `,
|
|
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 += join20;
|
|
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 += `${join20}"... ${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
|
+
join20 = `,
|
|
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 = join20;
|
|
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 join21 = `,
|
|
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 += join21;
|
|
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 += `${join21}"... ${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 join20 = `,
|
|
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, join20, maximumBreadth);
|
|
7438
7438
|
keys = keys.slice(value.length);
|
|
7439
7439
|
maximumPropertiesToStringify -= value.length;
|
|
7440
|
-
separator =
|
|
7440
|
+
separator = join20;
|
|
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 = join20;
|
|
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 = join20;
|
|
7458
7458
|
}
|
|
7459
7459
|
if (separator !== "") {
|
|
7460
7460
|
res = `
|
|
@@ -41991,7 +41991,7 @@ var require_send = __commonJS({
|
|
|
41991
41991
|
var { parseTokenList } = require_parseTokenList();
|
|
41992
41992
|
var { createHttpError } = require_createHttpError();
|
|
41993
41993
|
var extname2 = path.extname;
|
|
41994
|
-
var
|
|
41994
|
+
var join20 = path.join;
|
|
41995
41995
|
var normalize2 = path.normalize;
|
|
41996
41996
|
var resolve4 = path.resolve;
|
|
41997
41997
|
var sep3 = path.sep;
|
|
@@ -42078,7 +42078,7 @@ var require_send = __commonJS({
|
|
|
42078
42078
|
return { statusCode: 403 };
|
|
42079
42079
|
}
|
|
42080
42080
|
parts = path2.split(sep3);
|
|
42081
|
-
path2 = normalize2(
|
|
42081
|
+
path2 = normalize2(join20(root, path2));
|
|
42082
42082
|
} else {
|
|
42083
42083
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
42084
42084
|
debug('malicious path "%s"', path2);
|
|
@@ -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 = join20(path2, index);
|
|
42365
42365
|
const { error, stat: stat4 } = await tryStat(p);
|
|
42366
42366
|
if (error) {
|
|
42367
42367
|
err = error;
|
|
@@ -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_path18 = require("node:path");
|
|
50831
|
+
var import_node_os12 = require("node:os");
|
|
50832
|
+
var import_node_fs19 = require("node:fs");
|
|
50833
50833
|
var import_node_child_process6 = require("node:child_process");
|
|
50834
50834
|
|
|
50835
50835
|
// log.mjs
|
|
@@ -51127,6 +51127,24 @@ function listIntegrations() {
|
|
|
51127
51127
|
}
|
|
51128
51128
|
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
51129
51129
|
}
|
|
51130
|
+
function mergeConnectables(base, live, displayName) {
|
|
51131
|
+
const have = new Set(base.map((i) => i.id));
|
|
51132
|
+
const extra = [];
|
|
51133
|
+
for (const c of live) {
|
|
51134
|
+
if (have.has(c.integration)) continue;
|
|
51135
|
+
const status = c.status === "valid" ? "connected" : c.status === "expired" ? "expired" : "disconnected";
|
|
51136
|
+
extra.push({
|
|
51137
|
+
id: c.integration,
|
|
51138
|
+
name: displayName(c.integration),
|
|
51139
|
+
vendor: null,
|
|
51140
|
+
agent: "first-party",
|
|
51141
|
+
network: [],
|
|
51142
|
+
status,
|
|
51143
|
+
expiresAt: c.expires_in_secs != null ? new Date(Date.now() + c.expires_in_secs * 1e3).toISOString() : null
|
|
51144
|
+
});
|
|
51145
|
+
}
|
|
51146
|
+
return [...base, ...extra].sort((a, b) => a.name.localeCompare(b.name));
|
|
51147
|
+
}
|
|
51130
51148
|
function parseTrace(text) {
|
|
51131
51149
|
return text.split(/\r?\n/).filter((l) => l.trim()).map((l) => {
|
|
51132
51150
|
try {
|
|
@@ -51148,7 +51166,7 @@ function nodeExe() {
|
|
|
51148
51166
|
}
|
|
51149
51167
|
if (!isSea3) return _nodeExe = process.execPath;
|
|
51150
51168
|
try {
|
|
51151
|
-
const out = (0, import_node_child_process.execFileSync)(process.platform === "win32" ? "where" : "which", ["node"], { encoding: "utf8" });
|
|
51169
|
+
const out = (0, import_node_child_process.execFileSync)(process.platform === "win32" ? "where" : "which", ["node"], { encoding: "utf8", windowsHide: true, timeout: 5e3 });
|
|
51152
51170
|
_nodeExe = out.split(/\r?\n/).map((s) => s.trim()).find(Boolean) ?? "node";
|
|
51153
51171
|
} catch {
|
|
51154
51172
|
_nodeExe = "node";
|
|
@@ -51171,7 +51189,7 @@ function resolveInvoker() {
|
|
|
51171
51189
|
return { head: [nodeExe(), (0, import_node_path3.join)(envDir, "scripts/bin/aware.js")], shell: false, pkgDir: envDir };
|
|
51172
51190
|
}
|
|
51173
51191
|
try {
|
|
51174
|
-
const root = (0, import_node_child_process.execFileSync)("npm", ["root", "-g"], { encoding: "utf8", shell: process.platform === "win32" }).trim();
|
|
51192
|
+
const root = (0, import_node_child_process.execFileSync)("npm", ["root", "-g"], { encoding: "utf8", shell: process.platform === "win32", windowsHide: true, timeout: 1e4 }).trim();
|
|
51175
51193
|
const pkgDir = (0, import_node_path3.join)(root, "@aware-aeco", "cli");
|
|
51176
51194
|
const bin = (0, import_node_path3.join)(pkgDir, "scripts/bin/aware.js");
|
|
51177
51195
|
if ((0, import_node_fs4.existsSync)(bin)) return { head: [nodeExe(), bin], shell: false, pkgDir };
|
|
@@ -51345,7 +51363,7 @@ var runChain = Promise.resolve();
|
|
|
51345
51363
|
function killTree(child) {
|
|
51346
51364
|
if (process.platform === "win32" && child.pid) {
|
|
51347
51365
|
try {
|
|
51348
|
-
(0, import_node_child_process.execFileSync)("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore" });
|
|
51366
|
+
(0, import_node_child_process.execFileSync)("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
|
|
51349
51367
|
return;
|
|
51350
51368
|
} catch {
|
|
51351
51369
|
}
|
|
@@ -51540,6 +51558,16 @@ function parseBuildOutput(stdout) {
|
|
|
51540
51558
|
rawOutput: stdout.trim()
|
|
51541
51559
|
};
|
|
51542
51560
|
}
|
|
51561
|
+
function agentInstallArgv(id) {
|
|
51562
|
+
return ["agent", "install", assertId(id)];
|
|
51563
|
+
}
|
|
51564
|
+
function parseAgentInstallOutput(stdout) {
|
|
51565
|
+
const m = stdout.match(/✓\s+installed\s+(\S+)/);
|
|
51566
|
+
return { installed: m?.[1] ?? null };
|
|
51567
|
+
}
|
|
51568
|
+
function isAgentInstalled(agents, id) {
|
|
51569
|
+
return agents.some((a) => a.id === id);
|
|
51570
|
+
}
|
|
51543
51571
|
var inFlightConnects = /* @__PURE__ */ new Map();
|
|
51544
51572
|
function cancelAllConnects() {
|
|
51545
51573
|
for (const cancel of inFlightConnects.values()) cancel();
|
|
@@ -51717,6 +51745,28 @@ var aware = {
|
|
|
51717
51745
|
if (code !== 0) throw new AwareError(`aware app uninstall failed (exit ${code})`, { stdout, stderr });
|
|
51718
51746
|
return { output: stdout.trim() };
|
|
51719
51747
|
},
|
|
51748
|
+
/**
|
|
51749
|
+
* Install a first-party agent by registry id (`aware agent install <id>`). The
|
|
51750
|
+
* registry install pulls a large tarball (~200s observed) — far over runRaw's 60s
|
|
51751
|
+
* default — so use a generous timeout. NOT idempotent: it errors `conflict:
|
|
51752
|
+
* already installed` (exit 8) when the agent is present, so callers should prefer
|
|
51753
|
+
* `ensureAgentInstalled`. The token is NOT involved — only the agent manifest is fetched.
|
|
51754
|
+
*/
|
|
51755
|
+
async agentInstall(id) {
|
|
51756
|
+
const { code, stdout, stderr } = await runRawWithEnv(agentInstallArgv(id), void 0, 6e5);
|
|
51757
|
+
if (code !== 0) throw new AwareError(`aware agent install ${id} failed (exit ${code})`, { stdout, stderr });
|
|
51758
|
+
return { ...parseAgentInstallOutput(stdout), output: stdout.trim() };
|
|
51759
|
+
},
|
|
51760
|
+
/**
|
|
51761
|
+
* Ensure agent <id> is installed, idempotently. Checks the installed list first
|
|
51762
|
+
* (cheap — an `agent list`) and only installs when absent, so it avoids both the
|
|
51763
|
+
* `conflict: already installed` error and the slow tarball pull on the common path.
|
|
51764
|
+
*/
|
|
51765
|
+
async ensureAgentInstalled(id) {
|
|
51766
|
+
const agents = await this.agentList();
|
|
51767
|
+
if (isAgentInstalled(agents, id)) return { installed: id, output: "already installed" };
|
|
51768
|
+
return this.agentInstall(id);
|
|
51769
|
+
},
|
|
51720
51770
|
/**
|
|
51721
51771
|
* POST /api/run — installed ID. `run` ignores --json and prints
|
|
51722
51772
|
* "✓ run complete; trace at <path>"; we parse the path and read the JSONL.
|
|
@@ -52161,8 +52211,12 @@ function browserCommand(url, platform = process.platform) {
|
|
|
52161
52211
|
if (platform === "win32") {
|
|
52162
52212
|
return {
|
|
52163
52213
|
cmd: "cmd",
|
|
52214
|
+
// NO `detached`: Node #21825 makes it defeat `windowsHide` for cmd.exe (a CUI child),
|
|
52215
|
+
// flashing a console window on sign-in. windowsHide alone hides it; `start` still hands
|
|
52216
|
+
// the URL to the browser via ShellExecute, which outlives this process. windowsVerbatimArguments
|
|
52217
|
+
// keeps `&` literal inside the quoted url (the desktop-session footgun documented above).
|
|
52164
52218
|
args: ["/c", "start", '""', `"${url}"`],
|
|
52165
|
-
opts: { windowsHide: true,
|
|
52219
|
+
opts: { windowsHide: true, windowsVerbatimArguments: true }
|
|
52166
52220
|
};
|
|
52167
52221
|
}
|
|
52168
52222
|
return { cmd: platform === "darwin" ? "open" : "xdg-open", args: [url], opts: { detached: true } };
|
|
@@ -52254,7 +52308,7 @@ function appVersion() {
|
|
|
52254
52308
|
return resolveVersion({
|
|
52255
52309
|
isSea: isSea2(),
|
|
52256
52310
|
sqVersionXml: readSqVersionXml(),
|
|
52257
|
-
define: true ? "0.
|
|
52311
|
+
define: true ? "0.7.0" : void 0,
|
|
52258
52312
|
pkgVersion: readPkgVersion()
|
|
52259
52313
|
});
|
|
52260
52314
|
}
|
|
@@ -52264,7 +52318,64 @@ function resolveChannel(s) {
|
|
|
52264
52318
|
return "dev";
|
|
52265
52319
|
}
|
|
52266
52320
|
function appChannel() {
|
|
52267
|
-
return resolveChannel({ isSea: isSea2(), define: true ? "0.
|
|
52321
|
+
return resolveChannel({ isSea: isSea2(), define: true ? "0.7.0" : void 0 });
|
|
52322
|
+
}
|
|
52323
|
+
|
|
52324
|
+
// oauth-presets.ts
|
|
52325
|
+
var import_node_os6 = require("node:os");
|
|
52326
|
+
var import_node_path6 = require("node:path");
|
|
52327
|
+
var import_node_net = __toESM(require("node:net"), 1);
|
|
52328
|
+
var import_node_fs7 = require("node:fs");
|
|
52329
|
+
var MANAGED_HEADER = "# managed by floless.app - do not edit";
|
|
52330
|
+
var OAUTH_PRESETS = {
|
|
52331
|
+
"trimble-connect": {
|
|
52332
|
+
id: "trimble-connect",
|
|
52333
|
+
displayName: "Trimble Connect",
|
|
52334
|
+
clientId: process.env.FLOLESS_TRIMBLE_CLIENT_ID ?? "0a2444e4-f531-4a67-ab43-edc93ccff680",
|
|
52335
|
+
redirectUri: "http://localhost",
|
|
52336
|
+
callbackPort: 80
|
|
52337
|
+
}
|
|
52338
|
+
};
|
|
52339
|
+
function friendlyIntegrationName(id) {
|
|
52340
|
+
const preset = OAUTH_PRESETS[id];
|
|
52341
|
+
if (preset) return preset.displayName;
|
|
52342
|
+
const known = {
|
|
52343
|
+
"microsoft-365": "Microsoft 365",
|
|
52344
|
+
"google-workspace": "Google Workspace"
|
|
52345
|
+
};
|
|
52346
|
+
return known[id] ?? id.replace(/[-_]+/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
52347
|
+
}
|
|
52348
|
+
function managedProfileYaml(preset) {
|
|
52349
|
+
return [
|
|
52350
|
+
MANAGED_HEADER,
|
|
52351
|
+
`client_id: ${preset.clientId}`,
|
|
52352
|
+
`redirect_uri: ${preset.redirectUri}`,
|
|
52353
|
+
`callback_port: ${preset.callbackPort}`,
|
|
52354
|
+
""
|
|
52355
|
+
].join("\n");
|
|
52356
|
+
}
|
|
52357
|
+
function oauthDir() {
|
|
52358
|
+
return process.env.AWARE_HOME ? (0, import_node_path6.join)(process.env.AWARE_HOME, "oauth") : (0, import_node_path6.join)((0, import_node_os6.homedir)(), ".aware", "oauth");
|
|
52359
|
+
}
|
|
52360
|
+
function ensureManagedProfile(id) {
|
|
52361
|
+
const preset = OAUTH_PRESETS[id];
|
|
52362
|
+
if (!preset) return "not-managed";
|
|
52363
|
+
const dir = oauthDir();
|
|
52364
|
+
const file = (0, import_node_path6.join)(dir, `${id}.yaml`);
|
|
52365
|
+
const existing = (0, import_node_fs7.existsSync)(file) ? (0, import_node_fs7.readFileSync)(file, "utf8") : null;
|
|
52366
|
+
if (existing !== null && !existing.startsWith(MANAGED_HEADER)) return "skipped";
|
|
52367
|
+
const desired = managedProfileYaml(preset);
|
|
52368
|
+
if (existing === desired) return "unchanged";
|
|
52369
|
+
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
52370
|
+
(0, import_node_fs7.writeFileSync)(file, desired, "utf8");
|
|
52371
|
+
return "written";
|
|
52372
|
+
}
|
|
52373
|
+
function isPortBindable(port, host = "127.0.0.1") {
|
|
52374
|
+
return new Promise((resolve4) => {
|
|
52375
|
+
const srv = import_node_net.default.createServer();
|
|
52376
|
+
srv.once("error", () => resolve4(false));
|
|
52377
|
+
srv.listen(port, host, () => srv.close(() => resolve4(true)));
|
|
52378
|
+
});
|
|
52268
52379
|
}
|
|
52269
52380
|
|
|
52270
52381
|
// bake.ts
|
|
@@ -52339,16 +52450,16 @@ function buildPreview(m, sourceKind, sourceRef, stagedRef) {
|
|
|
52339
52450
|
}
|
|
52340
52451
|
|
|
52341
52452
|
// graft-manifest-reader.ts
|
|
52342
|
-
var
|
|
52343
|
-
var
|
|
52453
|
+
var import_node_fs8 = require("node:fs");
|
|
52454
|
+
var import_node_path7 = require("node:path");
|
|
52344
52455
|
var import_yaml3 = __toESM(require_dist6(), 1);
|
|
52345
52456
|
var asRecord2 = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
52346
52457
|
function readStagedManifest(agentDir) {
|
|
52347
|
-
const manifestPath = (0,
|
|
52348
|
-
if (!(0,
|
|
52458
|
+
const manifestPath = (0, import_node_path7.join)(agentDir, "manifest.yaml");
|
|
52459
|
+
if (!(0, import_node_fs8.existsSync)(manifestPath)) return null;
|
|
52349
52460
|
let doc;
|
|
52350
52461
|
try {
|
|
52351
|
-
doc = asRecord2((0, import_yaml3.parse)((0,
|
|
52462
|
+
doc = asRecord2((0, import_yaml3.parse)((0, import_node_fs8.readFileSync)(manifestPath, "utf8")));
|
|
52352
52463
|
} catch {
|
|
52353
52464
|
return null;
|
|
52354
52465
|
}
|
|
@@ -52378,10 +52489,10 @@ function readStagedManifest(agentDir) {
|
|
|
52378
52489
|
}
|
|
52379
52490
|
let skillCount = Array.isArray(doc.skills) ? doc.skills.length : 0;
|
|
52380
52491
|
if (!skillCount) {
|
|
52381
|
-
const skillsDir = (0,
|
|
52382
|
-
if ((0,
|
|
52492
|
+
const skillsDir = (0, import_node_path7.join)(agentDir, "skills");
|
|
52493
|
+
if ((0, import_node_fs8.existsSync)(skillsDir)) {
|
|
52383
52494
|
try {
|
|
52384
|
-
skillCount = (0,
|
|
52495
|
+
skillCount = (0, import_node_fs8.readdirSync)(skillsDir).filter((f) => f.endsWith(".md")).length;
|
|
52385
52496
|
} catch {
|
|
52386
52497
|
}
|
|
52387
52498
|
}
|
|
@@ -52395,7 +52506,7 @@ function readStagedManifest(agentDir) {
|
|
|
52395
52506
|
}
|
|
52396
52507
|
|
|
52397
52508
|
// graft-stage-registry.ts
|
|
52398
|
-
var
|
|
52509
|
+
var import_node_fs9 = require("node:fs");
|
|
52399
52510
|
var TTL_MS = 30 * 60 * 1e3;
|
|
52400
52511
|
var registry = /* @__PURE__ */ new Map();
|
|
52401
52512
|
function registerStage(token, tempDir, agentId) {
|
|
@@ -52417,7 +52528,7 @@ function evict(token) {
|
|
|
52417
52528
|
clearTimeout(e.timer);
|
|
52418
52529
|
registry.delete(token);
|
|
52419
52530
|
try {
|
|
52420
|
-
(0,
|
|
52531
|
+
(0, import_node_fs9.rmSync)(e.tempDir, { recursive: true, force: true });
|
|
52421
52532
|
} catch {
|
|
52422
52533
|
}
|
|
52423
52534
|
}
|
|
@@ -52426,8 +52537,8 @@ function clearAllStages() {
|
|
|
52426
52537
|
}
|
|
52427
52538
|
|
|
52428
52539
|
// graft-commit.ts
|
|
52429
|
-
var
|
|
52430
|
-
var
|
|
52540
|
+
var import_node_fs10 = require("node:fs");
|
|
52541
|
+
var import_node_path8 = require("node:path");
|
|
52431
52542
|
var GraftCommitError = class extends Error {
|
|
52432
52543
|
constructor(message, code) {
|
|
52433
52544
|
super(message);
|
|
@@ -52437,34 +52548,34 @@ var GraftCommitError = class extends Error {
|
|
|
52437
52548
|
code;
|
|
52438
52549
|
};
|
|
52439
52550
|
function commitStaged(tempDir, agentId, targetAgentsDir, force) {
|
|
52440
|
-
const staged = (0,
|
|
52441
|
-
const target = (0,
|
|
52442
|
-
if ((0,
|
|
52551
|
+
const staged = (0, import_node_path8.join)(tempDir, "agents", agentId);
|
|
52552
|
+
const target = (0, import_node_path8.join)(targetAgentsDir, agentId);
|
|
52553
|
+
if ((0, import_node_fs10.existsSync)(target)) {
|
|
52443
52554
|
if (!force) throw new GraftCommitError(`an agent named "${agentId}" is already installed`, "collision");
|
|
52444
|
-
(0,
|
|
52555
|
+
(0, import_node_fs10.rmSync)(target, { recursive: true, force: true });
|
|
52445
52556
|
}
|
|
52446
|
-
(0,
|
|
52557
|
+
(0, import_node_fs10.mkdirSync)(targetAgentsDir, { recursive: true });
|
|
52447
52558
|
try {
|
|
52448
|
-
(0,
|
|
52559
|
+
(0, import_node_fs10.renameSync)(staged, target);
|
|
52449
52560
|
} catch {
|
|
52450
|
-
(0,
|
|
52561
|
+
(0, import_node_fs10.cpSync)(staged, target, { recursive: true });
|
|
52451
52562
|
}
|
|
52452
|
-
(0,
|
|
52563
|
+
(0, import_node_fs10.rmSync)(tempDir, { recursive: true, force: true });
|
|
52453
52564
|
return { agentId };
|
|
52454
52565
|
}
|
|
52455
52566
|
function matchAssemblies(globOrDir) {
|
|
52456
52567
|
let dir;
|
|
52457
52568
|
let pattern;
|
|
52458
|
-
if ((0,
|
|
52569
|
+
if ((0, import_node_fs10.existsSync)(globOrDir) && (0, import_node_fs10.statSync)(globOrDir).isDirectory()) {
|
|
52459
52570
|
dir = globOrDir;
|
|
52460
52571
|
pattern = "*.dll";
|
|
52461
52572
|
} else {
|
|
52462
|
-
dir = (0,
|
|
52463
|
-
pattern = (0,
|
|
52573
|
+
dir = (0, import_node_path8.dirname)(globOrDir);
|
|
52574
|
+
pattern = (0, import_node_path8.basename)(globOrDir);
|
|
52464
52575
|
}
|
|
52465
|
-
if (!dir || !(0,
|
|
52576
|
+
if (!dir || !(0, import_node_fs10.existsSync)(dir) || !(0, import_node_fs10.statSync)(dir).isDirectory()) return [];
|
|
52466
52577
|
const re = globToRegExp(pattern);
|
|
52467
|
-
return (0,
|
|
52578
|
+
return (0, import_node_fs10.readdirSync)(dir).filter((f) => re.test(f)).sort();
|
|
52468
52579
|
}
|
|
52469
52580
|
function globToRegExp(p) {
|
|
52470
52581
|
const esc = p.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
@@ -52473,24 +52584,24 @@ function globToRegExp(p) {
|
|
|
52473
52584
|
|
|
52474
52585
|
// floless-store.ts
|
|
52475
52586
|
var import_node_crypto3 = require("node:crypto");
|
|
52476
|
-
var
|
|
52477
|
-
var
|
|
52478
|
-
var
|
|
52479
|
-
var ROOT = process.env.FLOLESS_HOME ?? (0,
|
|
52480
|
-
var TEMPLATES_FILE = (0,
|
|
52481
|
-
var REQUESTS_DIR = (0,
|
|
52587
|
+
var import_node_fs11 = require("node:fs");
|
|
52588
|
+
var import_node_os7 = require("node:os");
|
|
52589
|
+
var import_node_path9 = require("node:path");
|
|
52590
|
+
var ROOT = process.env.FLOLESS_HOME ?? (0, import_node_path9.join)((0, import_node_os7.homedir)(), ".floless");
|
|
52591
|
+
var TEMPLATES_FILE = (0, import_node_path9.join)(ROOT, "templates.json");
|
|
52592
|
+
var REQUESTS_DIR = (0, import_node_path9.join)(ROOT, "requests");
|
|
52482
52593
|
function ensureRoot() {
|
|
52483
|
-
if (!(0,
|
|
52594
|
+
if (!(0, import_node_fs11.existsSync)(ROOT)) (0, import_node_fs11.mkdirSync)(ROOT, { recursive: true });
|
|
52484
52595
|
}
|
|
52485
52596
|
function withinRequestsDir(p) {
|
|
52486
|
-
const base = (0,
|
|
52487
|
-
const full = (0,
|
|
52488
|
-
return full === base || full.startsWith(base +
|
|
52597
|
+
const base = (0, import_node_path9.resolve)(REQUESTS_DIR);
|
|
52598
|
+
const full = (0, import_node_path9.resolve)(p);
|
|
52599
|
+
return full === base || full.startsWith(base + import_node_path9.sep);
|
|
52489
52600
|
}
|
|
52490
52601
|
function listTemplates() {
|
|
52491
|
-
if (!(0,
|
|
52602
|
+
if (!(0, import_node_fs11.existsSync)(TEMPLATES_FILE)) return [];
|
|
52492
52603
|
try {
|
|
52493
|
-
const parsed = JSON.parse((0,
|
|
52604
|
+
const parsed = JSON.parse((0, import_node_fs11.readFileSync)(TEMPLATES_FILE, "utf8"));
|
|
52494
52605
|
return Array.isArray(parsed) ? parsed : [];
|
|
52495
52606
|
} catch {
|
|
52496
52607
|
return [];
|
|
@@ -52499,8 +52610,8 @@ function listTemplates() {
|
|
|
52499
52610
|
function writeTemplates(list) {
|
|
52500
52611
|
ensureRoot();
|
|
52501
52612
|
const tmp = `${TEMPLATES_FILE}.${process.pid}.tmp`;
|
|
52502
|
-
(0,
|
|
52503
|
-
(0,
|
|
52613
|
+
(0, import_node_fs11.writeFileSync)(tmp, JSON.stringify(list, null, 2));
|
|
52614
|
+
(0, import_node_fs11.renameSync)(tmp, TEMPLATES_FILE);
|
|
52504
52615
|
}
|
|
52505
52616
|
function addTemplate(input) {
|
|
52506
52617
|
const tpl = {
|
|
@@ -52528,13 +52639,13 @@ function getTemplate(id) {
|
|
|
52528
52639
|
}
|
|
52529
52640
|
function addRequest(req, decoded = []) {
|
|
52530
52641
|
ensureRoot();
|
|
52531
|
-
if (!(0,
|
|
52642
|
+
if (!(0, import_node_fs11.existsSync)(REQUESTS_DIR)) (0, import_node_fs11.mkdirSync)(REQUESTS_DIR, { recursive: true });
|
|
52532
52643
|
const id = (0, import_node_crypto3.randomUUID)();
|
|
52533
52644
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
52534
52645
|
const base = `${createdAt.replace(/[:.]/g, "-")}__${id}`;
|
|
52535
52646
|
const snapshots = decoded.map((d, i) => {
|
|
52536
|
-
const p = (0,
|
|
52537
|
-
(0,
|
|
52647
|
+
const p = (0, import_node_path9.join)(REQUESTS_DIR, `${base}__snap${i + 1}.${d.ext}`);
|
|
52648
|
+
(0, import_node_fs11.writeFileSync)(p, d.buf);
|
|
52538
52649
|
return p;
|
|
52539
52650
|
});
|
|
52540
52651
|
const full = {
|
|
@@ -52544,55 +52655,55 @@ function addRequest(req, decoded = []) {
|
|
|
52544
52655
|
...req,
|
|
52545
52656
|
...snapshots.length ? { snapshots } : {}
|
|
52546
52657
|
};
|
|
52547
|
-
(0,
|
|
52658
|
+
(0, import_node_fs11.writeFileSync)((0, import_node_path9.join)(REQUESTS_DIR, `${base}.json`), JSON.stringify(full, null, 2));
|
|
52548
52659
|
return full;
|
|
52549
52660
|
}
|
|
52550
52661
|
function listRequests() {
|
|
52551
|
-
if (!(0,
|
|
52552
|
-
return (0,
|
|
52662
|
+
if (!(0, import_node_fs11.existsSync)(REQUESTS_DIR)) return [];
|
|
52663
|
+
return (0, import_node_fs11.readdirSync)(REQUESTS_DIR).filter((f) => f.endsWith(".json")).sort().map((f) => {
|
|
52553
52664
|
try {
|
|
52554
|
-
return JSON.parse((0,
|
|
52665
|
+
return JSON.parse((0, import_node_fs11.readFileSync)((0, import_node_path9.join)(REQUESTS_DIR, f), "utf8"));
|
|
52555
52666
|
} catch {
|
|
52556
52667
|
return null;
|
|
52557
52668
|
}
|
|
52558
52669
|
}).filter((r) => r !== null);
|
|
52559
52670
|
}
|
|
52560
52671
|
function deleteRequest(id) {
|
|
52561
|
-
if (!(0,
|
|
52562
|
-
const file = (0,
|
|
52672
|
+
if (!(0, import_node_fs11.existsSync)(REQUESTS_DIR)) return false;
|
|
52673
|
+
const file = (0, import_node_fs11.readdirSync)(REQUESTS_DIR).find((f) => f.endsWith(`__${id}.json`));
|
|
52563
52674
|
if (!file) return false;
|
|
52564
52675
|
try {
|
|
52565
|
-
const parsed = JSON.parse((0,
|
|
52676
|
+
const parsed = JSON.parse((0, import_node_fs11.readFileSync)((0, import_node_path9.join)(REQUESTS_DIR, file), "utf8"));
|
|
52566
52677
|
for (const p of parsed.snapshots ?? []) {
|
|
52567
52678
|
if (!withinRequestsDir(p)) continue;
|
|
52568
52679
|
try {
|
|
52569
|
-
(0,
|
|
52680
|
+
(0, import_node_fs11.rmSync)(p);
|
|
52570
52681
|
} catch {
|
|
52571
52682
|
}
|
|
52572
52683
|
}
|
|
52573
52684
|
} catch {
|
|
52574
52685
|
}
|
|
52575
|
-
(0,
|
|
52686
|
+
(0, import_node_fs11.rmSync)((0, import_node_path9.join)(REQUESTS_DIR, file));
|
|
52576
52687
|
return true;
|
|
52577
52688
|
}
|
|
52578
52689
|
function clearRequests() {
|
|
52579
|
-
if (!(0,
|
|
52580
|
-
const allFiles = (0,
|
|
52690
|
+
if (!(0, import_node_fs11.existsSync)(REQUESTS_DIR)) return 0;
|
|
52691
|
+
const allFiles = (0, import_node_fs11.readdirSync)(REQUESTS_DIR);
|
|
52581
52692
|
const jsonFiles = allFiles.filter((f) => f.endsWith(".json"));
|
|
52582
52693
|
for (const f of allFiles) {
|
|
52583
52694
|
try {
|
|
52584
|
-
(0,
|
|
52695
|
+
(0, import_node_fs11.rmSync)((0, import_node_path9.join)(REQUESTS_DIR, f));
|
|
52585
52696
|
} catch {
|
|
52586
52697
|
}
|
|
52587
52698
|
}
|
|
52588
52699
|
return jsonFiles.length;
|
|
52589
52700
|
}
|
|
52590
52701
|
function snapshotPathFor(id, n) {
|
|
52591
|
-
if (!(0,
|
|
52592
|
-
const file = (0,
|
|
52702
|
+
if (!(0, import_node_fs11.existsSync)(REQUESTS_DIR)) return null;
|
|
52703
|
+
const file = (0, import_node_fs11.readdirSync)(REQUESTS_DIR).find((f) => f.endsWith(`__${id}.json`));
|
|
52593
52704
|
if (!file) return null;
|
|
52594
52705
|
try {
|
|
52595
|
-
const parsed = JSON.parse((0,
|
|
52706
|
+
const parsed = JSON.parse((0, import_node_fs11.readFileSync)((0, import_node_path9.join)(REQUESTS_DIR, file), "utf8"));
|
|
52596
52707
|
const cand = parsed.snapshots?.[n] ?? null;
|
|
52597
52708
|
return cand && withinRequestsDir(cand) ? cand : null;
|
|
52598
52709
|
} catch {
|
|
@@ -52626,8 +52737,8 @@ function decodeSnapshots(inputs) {
|
|
|
52626
52737
|
}
|
|
52627
52738
|
|
|
52628
52739
|
// routines.ts
|
|
52629
|
-
var
|
|
52630
|
-
var
|
|
52740
|
+
var import_node_fs13 = require("node:fs");
|
|
52741
|
+
var import_node_path11 = require("node:path");
|
|
52631
52742
|
|
|
52632
52743
|
// sse.ts
|
|
52633
52744
|
var clients = /* @__PURE__ */ new Set();
|
|
@@ -52664,11 +52775,11 @@ function clientCount() {
|
|
|
52664
52775
|
}
|
|
52665
52776
|
|
|
52666
52777
|
// trigger-sessions.ts
|
|
52667
|
-
var
|
|
52668
|
-
var
|
|
52669
|
-
var
|
|
52778
|
+
var import_node_fs12 = require("node:fs");
|
|
52779
|
+
var import_node_os8 = require("node:os");
|
|
52780
|
+
var import_node_path10 = require("node:path");
|
|
52670
52781
|
var import_yaml4 = __toESM(require_dist6(), 1);
|
|
52671
|
-
var AGENTS_DIR2 = process.env.AWARE_HOME ? (0,
|
|
52782
|
+
var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path10.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path10.join)((0, import_node_os8.homedir)(), ".aware", "agents");
|
|
52672
52783
|
function summarizeFire(data) {
|
|
52673
52784
|
if (!data) return "event";
|
|
52674
52785
|
const type = typeof data.type === "string" ? data.type : "";
|
|
@@ -52685,10 +52796,10 @@ function mapTriggerState(phase) {
|
|
|
52685
52796
|
function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
52686
52797
|
const safe = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
52687
52798
|
if (!safe(agent)) return false;
|
|
52688
|
-
const manifestPath = (0,
|
|
52689
|
-
if (!(0,
|
|
52799
|
+
const manifestPath = (0, import_node_path10.join)(agentsDir, agent, "manifest.yaml");
|
|
52800
|
+
if (!(0, import_node_fs12.existsSync)(manifestPath)) return false;
|
|
52690
52801
|
try {
|
|
52691
|
-
const doc = (0, import_yaml4.parse)((0,
|
|
52802
|
+
const doc = (0, import_yaml4.parse)((0, import_node_fs12.readFileSync)(manifestPath, "utf8"));
|
|
52692
52803
|
const transport = doc?.transport;
|
|
52693
52804
|
return !!(transport && typeof transport === "object" && "cli" in transport);
|
|
52694
52805
|
} catch {
|
|
@@ -52947,7 +53058,7 @@ var RoutineError = class extends Error {
|
|
|
52947
53058
|
}
|
|
52948
53059
|
status;
|
|
52949
53060
|
};
|
|
52950
|
-
var ROUTINES_FILE = (0,
|
|
53061
|
+
var ROUTINES_FILE = (0, import_node_path11.join)(flolessRoot, "routines.json");
|
|
52951
53062
|
var routines = [];
|
|
52952
53063
|
var loaded = false;
|
|
52953
53064
|
function ensureLoaded() {
|
|
@@ -52983,10 +53094,10 @@ function sanitizeRoutine(raw) {
|
|
|
52983
53094
|
};
|
|
52984
53095
|
}
|
|
52985
53096
|
function loadFromDisk() {
|
|
52986
|
-
if (!(0,
|
|
53097
|
+
if (!(0, import_node_fs13.existsSync)(ROUTINES_FILE)) return [];
|
|
52987
53098
|
let text;
|
|
52988
53099
|
try {
|
|
52989
|
-
text = (0,
|
|
53100
|
+
text = (0, import_node_fs13.readFileSync)(ROUTINES_FILE, "utf8");
|
|
52990
53101
|
} catch {
|
|
52991
53102
|
return [];
|
|
52992
53103
|
}
|
|
@@ -52995,17 +53106,17 @@ function loadFromDisk() {
|
|
|
52995
53106
|
return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
|
|
52996
53107
|
} catch {
|
|
52997
53108
|
try {
|
|
52998
|
-
(0,
|
|
53109
|
+
(0, import_node_fs13.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
|
|
52999
53110
|
} catch {
|
|
53000
53111
|
}
|
|
53001
53112
|
return [];
|
|
53002
53113
|
}
|
|
53003
53114
|
}
|
|
53004
53115
|
function saveRoutines() {
|
|
53005
|
-
if (!(0,
|
|
53116
|
+
if (!(0, import_node_fs13.existsSync)(flolessRoot)) (0, import_node_fs13.mkdirSync)(flolessRoot, { recursive: true });
|
|
53006
53117
|
const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
|
|
53007
|
-
(0,
|
|
53008
|
-
(0,
|
|
53118
|
+
(0, import_node_fs13.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
|
|
53119
|
+
(0, import_node_fs13.renameSync)(tmp, ROUTINES_FILE);
|
|
53009
53120
|
}
|
|
53010
53121
|
function listRoutines() {
|
|
53011
53122
|
ensureLoaded();
|
|
@@ -53395,9 +53506,9 @@ function isGatedAwareRoute(url, method) {
|
|
|
53395
53506
|
|
|
53396
53507
|
// autostart.mjs
|
|
53397
53508
|
var import_node_child_process3 = require("node:child_process");
|
|
53398
|
-
var
|
|
53399
|
-
var
|
|
53400
|
-
var
|
|
53509
|
+
var import_node_fs14 = require("node:fs");
|
|
53510
|
+
var import_node_os9 = require("node:os");
|
|
53511
|
+
var import_node_path12 = require("node:path");
|
|
53401
53512
|
|
|
53402
53513
|
// teardown.mjs
|
|
53403
53514
|
var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
@@ -53509,8 +53620,8 @@ function removeLegacyRunKey() {
|
|
|
53509
53620
|
}
|
|
53510
53621
|
function logLine(msg) {
|
|
53511
53622
|
try {
|
|
53512
|
-
(0,
|
|
53513
|
-
(0,
|
|
53623
|
+
(0, import_node_fs14.mkdirSync)(logDir(), { recursive: true });
|
|
53624
|
+
(0, import_node_fs14.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
53514
53625
|
`);
|
|
53515
53626
|
} catch {
|
|
53516
53627
|
}
|
|
@@ -53518,8 +53629,8 @@ function logLine(msg) {
|
|
|
53518
53629
|
function registerAutostart(exePath) {
|
|
53519
53630
|
if (!isWin) return;
|
|
53520
53631
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
53521
|
-
const tmp = (0,
|
|
53522
|
-
(0,
|
|
53632
|
+
const tmp = (0, import_node_path12.join)((0, import_node_os9.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
53633
|
+
(0, import_node_fs14.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
53523
53634
|
try {
|
|
53524
53635
|
(0, import_node_child_process3.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
53525
53636
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -53530,7 +53641,7 @@ function registerAutostart(exePath) {
|
|
|
53530
53641
|
throw err;
|
|
53531
53642
|
} finally {
|
|
53532
53643
|
try {
|
|
53533
|
-
(0,
|
|
53644
|
+
(0, import_node_fs14.rmSync)(tmp, { force: true });
|
|
53534
53645
|
} catch {
|
|
53535
53646
|
}
|
|
53536
53647
|
}
|
|
@@ -53565,10 +53676,10 @@ function unregisterAutostart() {
|
|
|
53565
53676
|
// updater.ts
|
|
53566
53677
|
var import_node_child_process4 = require("node:child_process");
|
|
53567
53678
|
var import_node_crypto4 = require("node:crypto");
|
|
53568
|
-
var
|
|
53679
|
+
var import_node_fs15 = require("node:fs");
|
|
53569
53680
|
var import_node_stream = require("node:stream");
|
|
53570
53681
|
var import_promises = require("node:stream/promises");
|
|
53571
|
-
var
|
|
53682
|
+
var import_node_path13 = require("node:path");
|
|
53572
53683
|
var CHANNEL = "win";
|
|
53573
53684
|
var FEED_TIMEOUT_MS = 15e3;
|
|
53574
53685
|
var DOWNLOAD_TIMEOUT_MS = 3e5;
|
|
@@ -53577,13 +53688,13 @@ function currentVersion() {
|
|
|
53577
53688
|
return appVersion();
|
|
53578
53689
|
}
|
|
53579
53690
|
function installRoot() {
|
|
53580
|
-
return (0,
|
|
53691
|
+
return (0, import_node_path13.dirname)((0, import_node_path13.dirname)(process.execPath));
|
|
53581
53692
|
}
|
|
53582
53693
|
function updateExePath() {
|
|
53583
|
-
return (0,
|
|
53694
|
+
return (0, import_node_path13.join)(installRoot(), "Update.exe");
|
|
53584
53695
|
}
|
|
53585
53696
|
function packagesDir() {
|
|
53586
|
-
return (0,
|
|
53697
|
+
return (0, import_node_path13.join)(installRoot(), "packages");
|
|
53587
53698
|
}
|
|
53588
53699
|
function feedUrl() {
|
|
53589
53700
|
const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
|
|
@@ -53688,22 +53799,22 @@ async function checkForUpdate() {
|
|
|
53688
53799
|
}
|
|
53689
53800
|
async function sha1OfFile(path) {
|
|
53690
53801
|
const hash = (0, import_node_crypto4.createHash)("sha1");
|
|
53691
|
-
await (0, import_promises.pipeline)((0,
|
|
53802
|
+
await (0, import_promises.pipeline)((0, import_node_fs15.createReadStream)(path), hash);
|
|
53692
53803
|
return hash.digest("hex").toUpperCase();
|
|
53693
53804
|
}
|
|
53694
53805
|
async function downloadPackage(asset) {
|
|
53695
53806
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
53696
53807
|
const want = asset.SHA1.toUpperCase();
|
|
53697
53808
|
const dir = packagesDir();
|
|
53698
|
-
(0,
|
|
53699
|
-
const dest = (0,
|
|
53700
|
-
if ((0,
|
|
53809
|
+
(0, import_node_fs15.mkdirSync)(dir, { recursive: true });
|
|
53810
|
+
const dest = (0, import_node_path13.join)(dir, asset.FileName);
|
|
53811
|
+
if ((0, import_node_fs15.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
53701
53812
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
53702
53813
|
redirect: "follow",
|
|
53703
53814
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
53704
53815
|
});
|
|
53705
53816
|
if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
|
|
53706
|
-
await (0, import_promises.pipeline)(import_node_stream.Readable.fromWeb(res.body), (0,
|
|
53817
|
+
await (0, import_promises.pipeline)(import_node_stream.Readable.fromWeb(res.body), (0, import_node_fs15.createWriteStream)(dest));
|
|
53707
53818
|
const got = await sha1OfFile(dest);
|
|
53708
53819
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
53709
53820
|
return dest;
|
|
@@ -53712,7 +53823,7 @@ async function applyUpdate(check, opts) {
|
|
|
53712
53823
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
53713
53824
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
53714
53825
|
const exe = updateExePath();
|
|
53715
|
-
if (!(0,
|
|
53826
|
+
if (!(0, import_node_fs15.existsSync)(exe)) {
|
|
53716
53827
|
return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
|
|
53717
53828
|
}
|
|
53718
53829
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -53735,12 +53846,12 @@ async function applyUpdate(check, opts) {
|
|
|
53735
53846
|
|
|
53736
53847
|
// launch.mjs
|
|
53737
53848
|
var import_node_child_process5 = require("node:child_process");
|
|
53738
|
-
var
|
|
53849
|
+
var import_node_path14 = require("node:path");
|
|
53739
53850
|
var import_node_url = require("node:url");
|
|
53740
|
-
var
|
|
53851
|
+
var import_node_fs16 = require("node:fs");
|
|
53741
53852
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
53742
53853
|
var import_node_readline = require("node:readline");
|
|
53743
|
-
var __dirname2 = (0,
|
|
53854
|
+
var __dirname2 = (0, import_node_path14.dirname)((0, import_node_url.fileURLToPath)(__import_meta_url));
|
|
53744
53855
|
var PORT = Number(process.env.PORT ?? 4317);
|
|
53745
53856
|
var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
|
|
53746
53857
|
var BROWSER_URL = `http://floless.localhost:${PORT}`;
|
|
@@ -53812,8 +53923,8 @@ async function waitHealthy(timeoutMs = 3e4) {
|
|
|
53812
53923
|
function resolveServerStart() {
|
|
53813
53924
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
53814
53925
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
53815
|
-
const bundle = (0,
|
|
53816
|
-
if ((0,
|
|
53926
|
+
const bundle = (0, import_node_path14.join)(__dirname2, "dist", "floless-server.cjs");
|
|
53927
|
+
if ((0, import_node_fs16.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
53817
53928
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
53818
53929
|
}
|
|
53819
53930
|
function startServerDetached() {
|
|
@@ -53830,7 +53941,7 @@ function startServerDetached() {
|
|
|
53830
53941
|
child.unref();
|
|
53831
53942
|
}
|
|
53832
53943
|
function openBrowser2(url) {
|
|
53833
|
-
if (isWin2) (0, import_node_child_process5.spawn)("cmd", ["/c", "start", "", url], { windowsHide: true
|
|
53944
|
+
if (isWin2) (0, import_node_child_process5.spawn)("cmd", ["/c", "start", "", url], { windowsHide: true }).unref();
|
|
53834
53945
|
else (0, import_node_child_process5.spawn)(process.platform === "darwin" ? "open" : "xdg-open", [url], { detached: true }).unref();
|
|
53835
53946
|
}
|
|
53836
53947
|
function stopServer() {
|
|
@@ -53961,8 +54072,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
|
|
|
53961
54072
|
}
|
|
53962
54073
|
function killSupervisor({ tree = true } = {}) {
|
|
53963
54074
|
if (!isWin2) return;
|
|
53964
|
-
const isNpmChannel = /^node(\.exe)?$/i.test((0,
|
|
53965
|
-
const scriptMatch = isNpmChannel ? (0,
|
|
54075
|
+
const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path14.basename)(process.execPath));
|
|
54076
|
+
const scriptMatch = isNpmChannel ? (0, import_node_path14.basename)((0, import_node_url.fileURLToPath)(__import_meta_url)) : void 0;
|
|
53966
54077
|
const realExe = resolveRealInstallExe(process.execPath);
|
|
53967
54078
|
const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
|
|
53968
54079
|
const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
|
|
@@ -54127,7 +54238,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null) {
|
|
|
54127
54238
|
}
|
|
54128
54239
|
await action(parseTeardownFlags(flagArgv));
|
|
54129
54240
|
}
|
|
54130
|
-
var entry = (0,
|
|
54241
|
+
var entry = (0, import_node_path14.basename)(process.argv[1] ?? "").toLowerCase();
|
|
54131
54242
|
if (entry === "launch.mjs") {
|
|
54132
54243
|
runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
|
|
54133
54244
|
log(`error: ${e?.message ?? e}`);
|
|
@@ -54201,9 +54312,9 @@ function awareUpgradeBlockReason(s) {
|
|
|
54201
54312
|
}
|
|
54202
54313
|
|
|
54203
54314
|
// skill-sync.ts
|
|
54204
|
-
var
|
|
54205
|
-
var
|
|
54206
|
-
var
|
|
54315
|
+
var import_node_fs17 = require("node:fs");
|
|
54316
|
+
var import_node_os10 = require("node:os");
|
|
54317
|
+
var import_node_path15 = require("node:path");
|
|
54207
54318
|
var import_node_url2 = require("node:url");
|
|
54208
54319
|
var import_yaml5 = __toESM(require_dist6(), 1);
|
|
54209
54320
|
|
|
@@ -54224,30 +54335,30 @@ function selectShippedSkillNames(names) {
|
|
|
54224
54335
|
}
|
|
54225
54336
|
|
|
54226
54337
|
// skill-sync.ts
|
|
54227
|
-
var __dirname3 = (0,
|
|
54338
|
+
var __dirname3 = (0, import_node_path15.dirname)((0, import_node_url2.fileURLToPath)(__import_meta_url));
|
|
54228
54339
|
function bundledSkillsRoot() {
|
|
54229
54340
|
const candidates = [
|
|
54230
|
-
(0,
|
|
54231
|
-
(0,
|
|
54232
|
-
(0,
|
|
54341
|
+
(0, import_node_path15.join)(__dirname3, "skills"),
|
|
54342
|
+
(0, import_node_path15.join)((0, import_node_path15.dirname)(process.execPath), "skills"),
|
|
54343
|
+
(0, import_node_path15.join)(__dirname3, "..", ".claude", "skills")
|
|
54233
54344
|
];
|
|
54234
|
-
return candidates.find((p) => (0,
|
|
54345
|
+
return candidates.find((p) => (0, import_node_fs17.existsSync)(p)) ?? null;
|
|
54235
54346
|
}
|
|
54236
54347
|
function targetConfigDirs() {
|
|
54237
54348
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
54238
54349
|
if (override) {
|
|
54239
54350
|
return override.split(";").map((d) => d.trim()).filter(Boolean).map((dir) => ({ runtime: "custom", dir }));
|
|
54240
54351
|
}
|
|
54241
|
-
const home = (0,
|
|
54352
|
+
const home = (0, import_node_os10.homedir)();
|
|
54242
54353
|
return [
|
|
54243
|
-
{ runtime: "claude", dir: (0,
|
|
54244
|
-
{ runtime: "codex", dir: (0,
|
|
54245
|
-
{ runtime: "opencode", dir: (0,
|
|
54354
|
+
{ runtime: "claude", dir: (0, import_node_path15.join)(home, ".claude") },
|
|
54355
|
+
{ runtime: "codex", dir: (0, import_node_path15.join)(home, ".codex") },
|
|
54356
|
+
{ runtime: "opencode", dir: (0, import_node_path15.join)(home, ".opencode") }
|
|
54246
54357
|
];
|
|
54247
54358
|
}
|
|
54248
54359
|
function skillVersion(skillMdPath) {
|
|
54249
54360
|
try {
|
|
54250
|
-
const text = (0,
|
|
54361
|
+
const text = (0, import_node_fs17.readFileSync)(skillMdPath, "utf8");
|
|
54251
54362
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
54252
54363
|
if (!m || m[1] === void 0) return null;
|
|
54253
54364
|
const fm = (0, import_yaml5.parse)(m[1]);
|
|
@@ -54287,21 +54398,21 @@ function decideAction(installed, bundled) {
|
|
|
54287
54398
|
function bundledSkills(root) {
|
|
54288
54399
|
let entries = [];
|
|
54289
54400
|
try {
|
|
54290
|
-
entries = selectShippedSkillNames((0,
|
|
54401
|
+
entries = selectShippedSkillNames((0, import_node_fs17.readdirSync)(root));
|
|
54291
54402
|
} catch {
|
|
54292
54403
|
return [];
|
|
54293
54404
|
}
|
|
54294
54405
|
const out = [];
|
|
54295
54406
|
for (const name of entries) {
|
|
54296
|
-
const dir = (0,
|
|
54407
|
+
const dir = (0, import_node_path15.join)(root, name);
|
|
54297
54408
|
let isDir = false;
|
|
54298
54409
|
try {
|
|
54299
|
-
isDir = (0,
|
|
54410
|
+
isDir = (0, import_node_fs17.statSync)(dir).isDirectory();
|
|
54300
54411
|
} catch {
|
|
54301
54412
|
isDir = false;
|
|
54302
54413
|
}
|
|
54303
54414
|
if (!isDir) continue;
|
|
54304
|
-
const v = skillVersion((0,
|
|
54415
|
+
const v = skillVersion((0, import_node_path15.join)(dir, "SKILL.md"));
|
|
54305
54416
|
if (!v) continue;
|
|
54306
54417
|
out.push({ name, dir, version: v });
|
|
54307
54418
|
}
|
|
@@ -54314,17 +54425,17 @@ function syncSkills() {
|
|
|
54314
54425
|
const skills = bundledSkills(root);
|
|
54315
54426
|
if (!skills.length) return results;
|
|
54316
54427
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
54317
|
-
if (!(0,
|
|
54318
|
-
const skillsDir = (0,
|
|
54428
|
+
if (!(0, import_node_fs17.existsSync)(cfg)) continue;
|
|
54429
|
+
const skillsDir = (0, import_node_path15.join)(cfg, "skills");
|
|
54319
54430
|
for (const s of skills) {
|
|
54320
|
-
const dest = (0,
|
|
54321
|
-
const installedMd = (0,
|
|
54322
|
-
const installed = (0,
|
|
54431
|
+
const dest = (0, import_node_path15.join)(skillsDir, s.name);
|
|
54432
|
+
const installedMd = (0, import_node_path15.join)(dest, "SKILL.md");
|
|
54433
|
+
const installed = (0, import_node_fs17.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
54323
54434
|
const action = decideAction(installed, s.version);
|
|
54324
54435
|
if (action === "installed" || action === "updated") {
|
|
54325
54436
|
try {
|
|
54326
|
-
if (action === "updated") (0,
|
|
54327
|
-
(0,
|
|
54437
|
+
if (action === "updated") (0, import_node_fs17.rmSync)(dest, { recursive: true, force: true });
|
|
54438
|
+
(0, import_node_fs17.cpSync)(s.dir, dest, { recursive: true });
|
|
54328
54439
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
54329
54440
|
} catch {
|
|
54330
54441
|
}
|
|
@@ -54337,9 +54448,9 @@ function syncSkills() {
|
|
|
54337
54448
|
}
|
|
54338
54449
|
|
|
54339
54450
|
// watch.ts
|
|
54340
|
-
var
|
|
54341
|
-
var
|
|
54342
|
-
var
|
|
54451
|
+
var import_node_os11 = require("node:os");
|
|
54452
|
+
var import_node_path17 = require("node:path");
|
|
54453
|
+
var import_node_fs18 = require("node:fs");
|
|
54343
54454
|
|
|
54344
54455
|
// node_modules/chokidar/esm/index.js
|
|
54345
54456
|
var import_fs2 = require("fs");
|
|
@@ -54350,7 +54461,7 @@ var sysPath2 = __toESM(require("path"), 1);
|
|
|
54350
54461
|
// node_modules/readdirp/esm/index.js
|
|
54351
54462
|
var import_promises2 = require("node:fs/promises");
|
|
54352
54463
|
var import_node_stream2 = require("node:stream");
|
|
54353
|
-
var
|
|
54464
|
+
var import_node_path16 = require("node:path");
|
|
54354
54465
|
var EntryTypes = {
|
|
54355
54466
|
FILE_TYPE: "files",
|
|
54356
54467
|
DIR_TYPE: "directories",
|
|
@@ -54425,7 +54536,7 @@ var ReaddirpStream = class extends import_node_stream2.Readable {
|
|
|
54425
54536
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
54426
54537
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
54427
54538
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
54428
|
-
this._root = (0,
|
|
54539
|
+
this._root = (0, import_node_path16.resolve)(root);
|
|
54429
54540
|
this._isDirent = !opts.alwaysStat;
|
|
54430
54541
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
54431
54542
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
@@ -54496,8 +54607,8 @@ var ReaddirpStream = class extends import_node_stream2.Readable {
|
|
|
54496
54607
|
let entry2;
|
|
54497
54608
|
const basename5 = this._isDirent ? dirent.name : dirent;
|
|
54498
54609
|
try {
|
|
54499
|
-
const fullPath = (0,
|
|
54500
|
-
entry2 = { path: (0,
|
|
54610
|
+
const fullPath = (0, import_node_path16.resolve)((0, import_node_path16.join)(path, basename5));
|
|
54611
|
+
entry2 = { path: (0, import_node_path16.relative)(this._root, fullPath), fullPath, basename: basename5 };
|
|
54501
54612
|
entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
54502
54613
|
} catch (err) {
|
|
54503
54614
|
this._onError(err);
|
|
@@ -54531,7 +54642,7 @@ var ReaddirpStream = class extends import_node_stream2.Readable {
|
|
|
54531
54642
|
}
|
|
54532
54643
|
if (entryRealPathStats.isDirectory()) {
|
|
54533
54644
|
const len = entryRealPath.length;
|
|
54534
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
54645
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path16.sep) {
|
|
54535
54646
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
54536
54647
|
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
54537
54648
|
return this._onError(recursiveError);
|
|
@@ -56039,15 +56150,15 @@ function appIdFromLogPath(path) {
|
|
|
56039
56150
|
return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
|
|
56040
56151
|
}
|
|
56041
56152
|
function startWatcher() {
|
|
56042
|
-
const awareDir = process.env.AWARE_HOME ?? (0,
|
|
56043
|
-
const credentialsDir = (0,
|
|
56044
|
-
if (!(0,
|
|
56153
|
+
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path17.join)((0, import_node_os11.homedir)(), ".aware");
|
|
56154
|
+
const credentialsDir = (0, import_node_path17.join)(awareDir, "credentials");
|
|
56155
|
+
if (!(0, import_node_fs18.existsSync)(credentialsDir)) {
|
|
56045
56156
|
try {
|
|
56046
|
-
(0,
|
|
56157
|
+
(0, import_node_fs18.mkdirSync)(credentialsDir, { recursive: true });
|
|
56047
56158
|
} catch {
|
|
56048
56159
|
}
|
|
56049
56160
|
}
|
|
56050
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0,
|
|
56161
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path17.join)(awareDir, d)).filter((p) => (0, import_node_fs18.existsSync)(p));
|
|
56051
56162
|
if (targets.length === 0) {
|
|
56052
56163
|
return null;
|
|
56053
56164
|
}
|
|
@@ -56059,11 +56170,11 @@ function startWatcher() {
|
|
|
56059
56170
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
56060
56171
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
56061
56172
|
broadcast({ type: "fs-change", kind, event, path });
|
|
56062
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
56173
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs18.existsSync)(path)) {
|
|
56063
56174
|
const id = appIdFromLogPath(path);
|
|
56064
56175
|
if (!id) return;
|
|
56065
56176
|
try {
|
|
56066
|
-
broadcast({ type: "trace-file", id, runId: path.split(
|
|
56177
|
+
broadcast({ type: "trace-file", id, runId: path.split(import_node_path17.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs18.readFileSync)(path, "utf8")) });
|
|
56067
56178
|
} catch {
|
|
56068
56179
|
}
|
|
56069
56180
|
}
|
|
@@ -56072,10 +56183,10 @@ function startWatcher() {
|
|
|
56072
56183
|
}
|
|
56073
56184
|
|
|
56074
56185
|
// index.ts
|
|
56075
|
-
var __dirname4 = (0,
|
|
56076
|
-
var WEB_ROOT = [(0,
|
|
56077
|
-
(p) => (0,
|
|
56078
|
-
) ?? (0,
|
|
56186
|
+
var __dirname4 = (0, import_node_path18.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
56187
|
+
var WEB_ROOT = [(0, import_node_path18.join)(__dirname4, "web"), (0, import_node_path18.join)((0, import_node_path18.dirname)(process.execPath), "web"), (0, import_node_path18.join)(__dirname4, "..", "web")].find(
|
|
56188
|
+
(p) => (0, import_node_fs19.existsSync)(p)
|
|
56189
|
+
) ?? (0, import_node_path18.join)(__dirname4, "..", "web");
|
|
56079
56190
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
56080
56191
|
var HOST = "127.0.0.1";
|
|
56081
56192
|
function extractReportHtml(events) {
|
|
@@ -56102,7 +56213,7 @@ function installCrashHandlers() {
|
|
|
56102
56213
|
${stack}
|
|
56103
56214
|
`;
|
|
56104
56215
|
try {
|
|
56105
|
-
(0,
|
|
56216
|
+
(0, import_node_fs19.appendFileSync)(logFilePath(), line);
|
|
56106
56217
|
} catch {
|
|
56107
56218
|
}
|
|
56108
56219
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -56137,7 +56248,7 @@ async function startServer() {
|
|
|
56137
56248
|
const isWin3 = process.platform === "win32";
|
|
56138
56249
|
const has = (cmd) => {
|
|
56139
56250
|
try {
|
|
56140
|
-
(0, import_node_child_process6.execFileSync)(isWin3 ? "where" : "which", [cmd], { stdio: "ignore" });
|
|
56251
|
+
(0, import_node_child_process6.execFileSync)(isWin3 ? "where" : "which", [cmd], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
|
|
56141
56252
|
return true;
|
|
56142
56253
|
} catch {
|
|
56143
56254
|
return false;
|
|
@@ -56318,7 +56429,7 @@ async function startServer() {
|
|
|
56318
56429
|
return { ok: true, agent };
|
|
56319
56430
|
});
|
|
56320
56431
|
app.get("/api/integrations", async () => {
|
|
56321
|
-
|
|
56432
|
+
let integrations = listIntegrations();
|
|
56322
56433
|
try {
|
|
56323
56434
|
const live = await aware.connectList();
|
|
56324
56435
|
const byId = new Map(live.map((c) => [c.integration, c]));
|
|
@@ -56328,6 +56439,7 @@ async function startServer() {
|
|
|
56328
56439
|
it.status = c.status === "valid" ? "connected" : c.status === "expired" ? "expired" : "disconnected";
|
|
56329
56440
|
it.expiresAt = c.expires_in_secs != null ? new Date(Date.now() + c.expires_in_secs * 1e3).toISOString() : it.expiresAt;
|
|
56330
56441
|
}
|
|
56442
|
+
integrations = mergeConnectables(integrations, live, friendlyIntegrationName);
|
|
56331
56443
|
} catch (err) {
|
|
56332
56444
|
app.log.warn({ err: String(err) }, "aware connect --list unavailable; using file-based status");
|
|
56333
56445
|
}
|
|
@@ -56336,6 +56448,11 @@ async function startServer() {
|
|
|
56336
56448
|
const DEFAULT_CONNECT_FLOW = {};
|
|
56337
56449
|
app.post("/api/connect/:id", async (req) => {
|
|
56338
56450
|
const id = req.params.id;
|
|
56451
|
+
try {
|
|
56452
|
+
ensureManagedProfile(id);
|
|
56453
|
+
} catch (err) {
|
|
56454
|
+
app.log.warn({ id, err: String(err) }, "ensureManagedProfile failed");
|
|
56455
|
+
}
|
|
56339
56456
|
const requested = req.body?.flow;
|
|
56340
56457
|
const flow = requested === "device-code" || requested === "oauth" ? requested : DEFAULT_CONNECT_FLOW[id] ?? "oauth";
|
|
56341
56458
|
if (flow === "device-code") {
|
|
@@ -56346,13 +56463,29 @@ async function startServer() {
|
|
|
56346
56463
|
});
|
|
56347
56464
|
return { ok: true, id, flow, prompt };
|
|
56348
56465
|
}
|
|
56466
|
+
const preset = OAUTH_PRESETS[id];
|
|
56467
|
+
if (preset && !await isPortBindable(preset.callbackPort)) {
|
|
56468
|
+
broadcast({
|
|
56469
|
+
type: "connect-result",
|
|
56470
|
+
id,
|
|
56471
|
+
status: "failed",
|
|
56472
|
+
error: `local port ${preset.callbackPort} is in use \u2014 close the program using it, then click Connect again`
|
|
56473
|
+
});
|
|
56474
|
+
return { ok: true, id, flow, started: false };
|
|
56475
|
+
}
|
|
56349
56476
|
aware.connectOAuth(id, (result) => {
|
|
56477
|
+
const ok = result.status === "connected";
|
|
56350
56478
|
broadcast({
|
|
56351
56479
|
type: "connect-result",
|
|
56352
56480
|
id,
|
|
56353
|
-
status:
|
|
56354
|
-
error:
|
|
56481
|
+
status: ok ? "connected" : "failed",
|
|
56482
|
+
error: ok ? null : "sign-in failed or was cancelled"
|
|
56355
56483
|
});
|
|
56484
|
+
if (ok && id === "trimble-connect") {
|
|
56485
|
+
aware.ensureAgentInstalled(id).catch(
|
|
56486
|
+
(err) => app.log.warn({ id, err: String(err) }, "ensureAgentInstalled after connect failed (non-fatal)")
|
|
56487
|
+
);
|
|
56488
|
+
}
|
|
56356
56489
|
});
|
|
56357
56490
|
return { ok: true, id, flow, started: true };
|
|
56358
56491
|
});
|
|
@@ -56376,13 +56509,13 @@ async function startServer() {
|
|
|
56376
56509
|
}
|
|
56377
56510
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
56378
56511
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
56379
|
-
const tmpRoot = (0,
|
|
56380
|
-
const backupDir = (0,
|
|
56381
|
-
const bakeDir = (0,
|
|
56382
|
-
(0,
|
|
56383
|
-
(0,
|
|
56512
|
+
const tmpRoot = (0, import_node_fs19.mkdtempSync)((0, import_node_path18.join)((0, import_node_os12.tmpdir)(), "floless-bake-"));
|
|
56513
|
+
const backupDir = (0, import_node_path18.join)(tmpRoot, `${id}-backup`);
|
|
56514
|
+
const bakeDir = (0, import_node_path18.join)(tmpRoot, id);
|
|
56515
|
+
(0, import_node_fs19.cpSync)(appDir(id), backupDir, { recursive: true });
|
|
56516
|
+
(0, import_node_fs19.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
56384
56517
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
56385
|
-
(0,
|
|
56518
|
+
(0, import_node_fs19.writeFileSync)((0, import_node_path18.join)(bakeDir, floName), baked);
|
|
56386
56519
|
let appInstalled = true;
|
|
56387
56520
|
try {
|
|
56388
56521
|
await aware.uninstall(id);
|
|
@@ -56404,17 +56537,17 @@ async function startServer() {
|
|
|
56404
56537
|
throw installErr;
|
|
56405
56538
|
}
|
|
56406
56539
|
try {
|
|
56407
|
-
await aware.compile((0,
|
|
56540
|
+
await aware.compile((0, import_node_path18.join)(appDir(id), floName));
|
|
56408
56541
|
} catch (compileErr) {
|
|
56409
56542
|
app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
|
|
56410
56543
|
}
|
|
56411
56544
|
broadcast({ type: "baked", id });
|
|
56412
56545
|
return { ok: true, id, agent: id, inputs };
|
|
56413
56546
|
} finally {
|
|
56414
|
-
if (appInstalled) (0,
|
|
56547
|
+
if (appInstalled) (0, import_node_fs19.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
56415
56548
|
}
|
|
56416
56549
|
});
|
|
56417
|
-
const graftAgentsDir = () => (0,
|
|
56550
|
+
const graftAgentsDir = () => (0, import_node_path18.join)((0, import_node_os12.homedir)(), ".aware", "agents");
|
|
56418
56551
|
app.post("/api/graft/match", async (req, reply) => {
|
|
56419
56552
|
const { glob } = req.body ?? {};
|
|
56420
56553
|
if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
|
|
@@ -56431,7 +56564,7 @@ async function startServer() {
|
|
|
56431
56564
|
if (!sourceKind || !sourceRef) {
|
|
56432
56565
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
56433
56566
|
}
|
|
56434
|
-
const tempHome = (0,
|
|
56567
|
+
const tempHome = (0, import_node_fs19.mkdtempSync)((0, import_node_path18.join)((0, import_node_os12.tmpdir)(), "floless-graft-"));
|
|
56435
56568
|
let result;
|
|
56436
56569
|
try {
|
|
56437
56570
|
result = await aware.build({
|
|
@@ -56444,19 +56577,19 @@ async function startServer() {
|
|
|
56444
56577
|
awareHome: tempHome
|
|
56445
56578
|
});
|
|
56446
56579
|
} catch (err) {
|
|
56447
|
-
(0,
|
|
56580
|
+
(0, import_node_fs19.rmSync)(tempHome, { recursive: true, force: true });
|
|
56448
56581
|
const msg = err instanceof AwareError ? err.message : String(err?.message ?? err);
|
|
56449
56582
|
return reply.status(422).send({ ok: false, error: msg });
|
|
56450
56583
|
}
|
|
56451
56584
|
const manifest = readStagedManifest(result.agentDir);
|
|
56452
56585
|
if (!manifest) {
|
|
56453
|
-
(0,
|
|
56586
|
+
(0, import_node_fs19.rmSync)(tempHome, { recursive: true, force: true });
|
|
56454
56587
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
56455
56588
|
}
|
|
56456
56589
|
const token = (0, import_node_crypto5.randomUUID)();
|
|
56457
56590
|
registerStage(token, tempHome, result.agentId);
|
|
56458
56591
|
const preview = buildPreview(manifest, sourceKind, sourceRef, token);
|
|
56459
|
-
if ((0,
|
|
56592
|
+
if ((0, import_node_fs19.existsSync)((0, import_node_path18.join)(graftAgentsDir(), result.agentId))) {
|
|
56460
56593
|
preview.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
56461
56594
|
}
|
|
56462
56595
|
return { ok: true, preview };
|
|
@@ -56475,7 +56608,7 @@ async function startServer() {
|
|
|
56475
56608
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
56476
56609
|
return reply.status(409).send({ ok: false, error: err.message, agentId: stage.agentId, collision: true });
|
|
56477
56610
|
}
|
|
56478
|
-
(0,
|
|
56611
|
+
(0, import_node_fs19.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
56479
56612
|
throw err;
|
|
56480
56613
|
}
|
|
56481
56614
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -56610,11 +56743,11 @@ async function startServer() {
|
|
|
56610
56743
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
56611
56744
|
const n = Number.parseInt(req.params.n, 10);
|
|
56612
56745
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
56613
|
-
if (!p || !(0,
|
|
56746
|
+
if (!p || !(0, import_node_fs19.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
56614
56747
|
const ext = p.split(".").pop().toLowerCase();
|
|
56615
56748
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : "image/jpeg");
|
|
56616
56749
|
reply.header("Cache-Control", "no-store");
|
|
56617
|
-
return (0,
|
|
56750
|
+
return (0, import_node_fs19.readFileSync)(p);
|
|
56618
56751
|
});
|
|
56619
56752
|
app.post(
|
|
56620
56753
|
"/api/tweak",
|