@flowriki/agent 0.1.0-beta.15 → 0.1.0-beta.17

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.15";
9
+ var AGENT_VERSION = "0.1.0-beta.17";
10
10
  async function prepareBrowsers() {
11
11
  if (browsersReady()) {
12
12
  return { ok: true, already: true, message: "chromium is already installed" };
@@ -2985,7 +2985,7 @@ var RunActors = class {
2985
2985
  this.current = session;
2986
2986
  this.currentId = id;
2987
2987
  if (this.initialized.has(id)) return;
2988
- await session.page.goto(startUrl, { waitUntil: "domcontentloaded" });
2988
+ if (startUrl) await session.page.goto(startUrl, { waitUntil: "domcontentloaded" });
2989
2989
  if (actor?.startSignedIn) {
2990
2990
  if (kept?.state) {
2991
2991
  const confirmed = await confirmSignedIn(session.page, kept.auth, this.opts.reuseCheckMs ?? 3e3);
@@ -3027,7 +3027,7 @@ var RunActors = class {
3027
3027
  } catch {
3028
3028
  }
3029
3029
  }
3030
- await session.page.goto(startUrl, { waitUntil: "domcontentloaded" });
3030
+ if (startUrl) await session.page.goto(startUrl, { waitUntil: "domcontentloaded" });
3031
3031
  }
3032
3032
  this.initialized.add(id);
3033
3033
  }
@@ -3919,6 +3919,12 @@ var checkStep = (id, proposals) => ({
3919
3919
  legacySelector: "",
3920
3920
  proposals
3921
3921
  });
3922
+ function opensItsOwnEntry(steps, opts) {
3923
+ const first = steps.find((step) => !step.disabled);
3924
+ if (!first || first.type !== "signIn" || !first.auth) return false;
3925
+ if (first.auth.from === "here") return false;
3926
+ return opts.resolveAuth?.(first.auth)?.navigation.kind === "open";
3927
+ }
3922
3928
  function stepFailure(step, detail) {
3923
3929
  return {
3924
3930
  stepId: step.id,
@@ -3940,7 +3946,9 @@ async function runStepsIn(session, steps, opts) {
3940
3946
  let status2 = "passed";
3941
3947
  let error = null;
3942
3948
  try {
3943
- if (opts.startUrl) await page.goto(opts.startUrl, { waitUntil: "domcontentloaded" });
3949
+ if (opts.startUrl && !opensItsOwnEntry(steps, opts)) {
3950
+ await page.goto(opts.startUrl, { waitUntil: "domcontentloaded" });
3951
+ }
3944
3952
  for (const recorded of steps) {
3945
3953
  let step = recorded;
3946
3954
  if (!recorded.disabled) {
@@ -4158,8 +4166,9 @@ async function replayFlow(opts) {
4158
4166
  hydrated: hydrated ? { ...hydrated, id: opts.defaultActorId ?? "default" } : null
4159
4167
  });
4160
4168
  let prepared = null;
4169
+ const entry = opensItsOwnEntry(steps, opts) ? "" : void 0;
4161
4170
  try {
4162
- await actors.select(opts.defaultActorId ?? "default");
4171
+ await actors.select(opts.defaultActorId ?? "default", entry);
4163
4172
  } catch (e) {
4164
4173
  prepared = e.message;
4165
4174
  }
@@ -4785,10 +4794,8 @@ async function startRecordingSession(opts) {
4785
4794
  await page.goto(url, { waitUntil: "domcontentloaded" });
4786
4795
  }
4787
4796
  await executeStep(page, opts.authentication.step, { ...opts.authentication, baseUrl: url });
4788
- const resume = { id: "auth-return", type: "navigate", name: "Open recording start page", role: "", scope: "", value: new URL(url).pathname + new URL(url).search + new URL(url).hash, navigationBase: "application", secret: false, legacySelector: "", proposals: [] };
4789
- steps.push(opts.authentication.step, resume);
4797
+ steps.push(opts.authentication.step);
4790
4798
  onStep?.(opts.authentication.step);
4791
- onStep?.(resume);
4792
4799
  } catch (error) {
4793
4800
  const landed = await page.url().replace(/^https?:\/\/[^/]+/, "");
4794
4801
  const title = await page.title().catch(() => "");
@@ -4850,7 +4857,8 @@ async function startRecordingSession(opts) {
4850
4857
  });
4851
4858
  });
4852
4859
  try {
4853
- await page.goto(url, { waitUntil: "domcontentloaded", timeout: 45e3 });
4860
+ if (!opts.authentication) await page.goto(url, { waitUntil: "domcontentloaded", timeout: 45e3 });
4861
+ else await ensureInstalled(page);
4854
4862
  } catch (err) {
4855
4863
  stopped = true;
4856
4864
  await browser.close().catch(() => {
@@ -5183,7 +5191,11 @@ async function startDebugSession(opts) {
5183
5191
  publish();
5184
5192
  });
5185
5193
  await context2.exposeBinding("__flCmd", (_src, msg) => {
5186
- void handleCommand(msg);
5194
+ void handleCommand(msg).catch((error) => {
5195
+ failure = { stepId: cursor ?? steps[0]?.id ?? "", error: firstLine2(error) };
5196
+ status2 = "paused";
5197
+ void paint(snapshot());
5198
+ });
5187
5199
  });
5188
5200
  await context2.addInitScript({ content: `${accNameScript2()}
5189
5201
  ;(${installRecorder.toString()})();
@@ -6298,7 +6310,7 @@ function toSummary(row) {
6298
6310
  };
6299
6311
  }
6300
6312
 
6301
- // ../repository-store/dist/chunk-IXRMPDVC.js
6313
+ // ../repository-store/dist/chunk-QSTSWM2T.js
6302
6314
  var FLOWRIKI_DIR = ".flowriki";
6303
6315
  var FEATURES_DIR = `${FLOWRIKI_DIR}/features`;
6304
6316
  var CONFIG_PATH = `${FLOWRIKI_DIR}/config.json`;
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  resolveCheckouts,
9
9
  start,
10
10
  status
11
- } from "./chunk-KY7KDJTV.js";
11
+ } from "./chunk-NTARVVKX.js";
12
12
 
13
13
  // src/cli.ts
14
14
  import { parseArgs } from "util";
@@ -111,6 +111,11 @@ Run \`flowriki-agent --help\`.`);
111
111
  return 0;
112
112
  }
113
113
  case "start": {
114
+ process.on("unhandledRejection", (reason) => {
115
+ const said = reason instanceof Error ? reason.stack ?? reason.message : String(reason);
116
+ console.error(red(`! a command failed without being handled \u2014 the agent is still running`));
117
+ console.error(dim(said.split("\n").slice(0, 4).join("\n")));
118
+ });
114
119
  const started = await start({
115
120
  ...service ? { service } : {},
116
121
  ...projects.length ? { projects } : {},
package/dist/engine.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  resolveCheckouts,
10
10
  start,
11
11
  status
12
- } from "./chunk-KY7KDJTV.js";
12
+ } from "./chunk-NTARVVKX.js";
13
13
  export {
14
14
  AGENT_VERSION,
15
15
  browsersReady,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowriki/agent",
3
- "version": "0.1.0-beta.15",
3
+ "version": "0.1.0-beta.17",
4
4
  "description": "Run Flowriki UI tests on your own computer. Connects this machine to your Flowriki account.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",