@flowriki/agent 0.1.0-beta.40 → 0.1.0-beta.41
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.
|
@@ -6,7 +6,7 @@ import os from "os";
|
|
|
6
6
|
import path from "path";
|
|
7
7
|
import { createRequire } from "module";
|
|
8
8
|
import { spawnSync } from "child_process";
|
|
9
|
-
var AGENT_VERSION = "0.1.0-beta.
|
|
9
|
+
var AGENT_VERSION = "0.1.0-beta.41";
|
|
10
10
|
async function prepareBrowsers() {
|
|
11
11
|
if (browsersReady()) {
|
|
12
12
|
return { ok: true, already: true, message: "chromium is already installed" };
|
|
@@ -10451,6 +10451,7 @@ import path10 from "path";
|
|
|
10451
10451
|
import fs25 from "fs";
|
|
10452
10452
|
import path24 from "path";
|
|
10453
10453
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
10454
|
+
import { execFile } from "child_process";
|
|
10454
10455
|
import fs34 from "fs";
|
|
10455
10456
|
import path34 from "path";
|
|
10456
10457
|
import { spawn as nodeSpawn } from "child_process";
|
|
@@ -11199,6 +11200,30 @@ function setFolder(projectId, folder) {
|
|
|
11199
11200
|
writeAll(all);
|
|
11200
11201
|
return foldersFor(projectId);
|
|
11201
11202
|
}
|
|
11203
|
+
var PROMPT = "Choose the folder your project's code is in";
|
|
11204
|
+
var WAIT_MS = 4 * 60 * 1e3;
|
|
11205
|
+
var NoFolderWindow = class extends Error {
|
|
11206
|
+
};
|
|
11207
|
+
async function chooseFolder(run, platform = process.platform) {
|
|
11208
|
+
const attempts = platform === "darwin" ? [["osascript", ["-e", "activate", "-e", `POSIX path of (choose folder with prompt "${PROMPT}")`]]] : platform === "win32" ? [["powershell", [
|
|
11209
|
+
"-NoProfile",
|
|
11210
|
+
"-STA",
|
|
11211
|
+
"-Command",
|
|
11212
|
+
`Add-Type -AssemblyName System.Windows.Forms; $d = New-Object System.Windows.Forms.FolderBrowserDialog; $d.Description = "${PROMPT}"; if ($d.ShowDialog() -eq 'OK') { $d.SelectedPath }`
|
|
11213
|
+
]]] : [["zenity", ["--file-selection", "--directory", `--title=${PROMPT}`]], ["kdialog", ["--getexistingdirectory", ".", "--title", PROMPT]]];
|
|
11214
|
+
for (const [file2, args] of attempts) {
|
|
11215
|
+
let answer;
|
|
11216
|
+
try {
|
|
11217
|
+
answer = await run(file2, args, WAIT_MS);
|
|
11218
|
+
} catch {
|
|
11219
|
+
continue;
|
|
11220
|
+
}
|
|
11221
|
+
const picked = answer.stdout.trim();
|
|
11222
|
+
if (answer.code === 0 && picked) return picked.length > 1 ? picked.replace(/[\\/]+$/, "") : picked;
|
|
11223
|
+
return null;
|
|
11224
|
+
}
|
|
11225
|
+
throw new NoFolderWindow("this computer has no folder window to open \u2014 type the folder's path instead");
|
|
11226
|
+
}
|
|
11202
11227
|
var MAX_PROMPT = 4e3;
|
|
11203
11228
|
function assistantHandlers({ deps }) {
|
|
11204
11229
|
const assistant = deps.assistant;
|
|
@@ -11246,7 +11271,12 @@ function assistantHandlers({ deps }) {
|
|
|
11246
11271
|
* `folder` is answered too, for them: the first one. */
|
|
11247
11272
|
"assistant.folder": async (command, project) => {
|
|
11248
11273
|
try {
|
|
11249
|
-
const { add, remove, path: asked } = command.args;
|
|
11274
|
+
const { add, remove, path: asked, choose } = command.args;
|
|
11275
|
+
if (choose === true) {
|
|
11276
|
+
const picked = await chooseFolder(runFile);
|
|
11277
|
+
const folders2 = picked ? addFolder(project.id, picked) : foldersFor(project.id);
|
|
11278
|
+
return { ok: true, result: { folders: folders2, folder: folders2[0] ?? null, chosen: picked } };
|
|
11279
|
+
}
|
|
11250
11280
|
const folders = typeof add === "string" ? addFolder(project.id, add) : typeof remove === "string" ? removeFolder(project.id, remove) : asked !== void 0 ? setFolder(project.id, asked === null ? null : String(asked)) : foldersFor(project.id);
|
|
11251
11281
|
return { ok: true, result: { folders, folder: folders[0] ?? null } };
|
|
11252
11282
|
} catch (error) {
|
|
@@ -11259,6 +11289,13 @@ function assistantHandlers({ deps }) {
|
|
|
11259
11289
|
}
|
|
11260
11290
|
};
|
|
11261
11291
|
}
|
|
11292
|
+
var runFile = (file2, args, timeoutMs) => new Promise((resolve2, reject) => {
|
|
11293
|
+
execFile(file2, args, { timeout: timeoutMs, windowsHide: false }, (error, stdout, stderr) => {
|
|
11294
|
+
if (error && error.code === "ENOENT") return reject(error);
|
|
11295
|
+
const code = error ? typeof error.code === "number" ? error.code : 1 : 0;
|
|
11296
|
+
resolve2({ code, stdout: String(stdout), stderr: String(stderr) });
|
|
11297
|
+
});
|
|
11298
|
+
});
|
|
11262
11299
|
function buildHandlers(deps) {
|
|
11263
11300
|
const context = {
|
|
11264
11301
|
deps,
|
package/dist/cli.js
CHANGED
package/dist/engine.js
CHANGED
package/package.json
CHANGED