@qablehq/atto 0.0.36 → 0.0.39

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.
@@ -17733,6 +17733,89 @@ const DEFAULT_GATE_POLICY = {
17733
17733
  severityOverrides: {},
17734
17734
  custom: []
17735
17735
  };
17736
+ function emptyGateReport(attempt = 1) {
17737
+ return { outcomes: [], passed: 0, failed: 0, warned: 0, disabled: 0, notApplicable: 0, bypassed: 0, attempt };
17738
+ }
17739
+ function summariseGateReport(outcomes, attempt) {
17740
+ const count2 = (status) => outcomes.filter((outcome) => outcome.status === status).length;
17741
+ return {
17742
+ outcomes,
17743
+ passed: count2("passed"),
17744
+ failed: outcomes.filter((outcome) => outcome.status === "failed" && outcome.severity === "error").length,
17745
+ warned: outcomes.filter((outcome) => outcome.status === "failed" && outcome.severity === "warning").length,
17746
+ disabled: count2("disabled"),
17747
+ notApplicable: count2("not-applicable"),
17748
+ bypassed: count2("bypassed"),
17749
+ attempt
17750
+ };
17751
+ }
17752
+ function applyBypass(report, bypassedIds) {
17753
+ const ids = new Set(bypassedIds);
17754
+ return summariseGateReport(
17755
+ report.outcomes.map(
17756
+ (outcome) => outcome.status === "failed" && ids.has(outcome.id) ? { ...outcome, status: "bypassed" } : outcome
17757
+ ),
17758
+ report.attempt
17759
+ );
17760
+ }
17761
+ const LOCKED_GATE_IDS = [
17762
+ "test-required",
17763
+ "assertions-required",
17764
+ "pom-dangling-import",
17765
+ "import-tokens"
17766
+ ];
17767
+ function isLockedGate(id) {
17768
+ return LOCKED_GATE_IDS.includes(id);
17769
+ }
17770
+ function normalizeGatePolicy(raw2) {
17771
+ if (typeof raw2 !== "object" || raw2 === null) return DEFAULT_GATE_POLICY;
17772
+ const record = raw2;
17773
+ const disabled = Array.isArray(record.disabled) ? record.disabled.filter((id) => typeof id === "string" && !isLockedGate(id)) : [];
17774
+ const severityOverrides = {};
17775
+ if (typeof record.severityOverrides === "object" && record.severityOverrides !== null) {
17776
+ for (const [id, severity] of Object.entries(record.severityOverrides)) {
17777
+ if (severity === "error" || severity === "warning") severityOverrides[id] = severity;
17778
+ }
17779
+ }
17780
+ const custom = Array.isArray(record.custom) ? record.custom.map(normalizeCustomGate).filter((gate) => gate !== null) : [];
17781
+ return { version: 1, disabled, severityOverrides, custom };
17782
+ }
17783
+ function normalizeCustomGate(raw2) {
17784
+ if (typeof raw2 !== "object" || raw2 === null) return null;
17785
+ const record = raw2;
17786
+ const id = typeof record.id === "string" && record.id.trim() ? record.id : null;
17787
+ const name = typeof record.name === "string" && record.name.trim() ? record.name.trim() : null;
17788
+ if (!id || !name) return null;
17789
+ const severity = record.severity === "warning" ? "warning" : "error";
17790
+ const enabled = record.enabled !== false;
17791
+ if (record.kind === "ai") {
17792
+ const prompt = typeof record.prompt === "string" ? record.prompt.trim() : "";
17793
+ if (!prompt) return null;
17794
+ return { id, kind: "ai", name, prompt, severity, enabled };
17795
+ }
17796
+ const matcher = record.matcher;
17797
+ const value = typeof matcher?.value === "string" ? matcher.value : "";
17798
+ if (!value.trim()) return null;
17799
+ return {
17800
+ id,
17801
+ kind: "pattern",
17802
+ name,
17803
+ description: typeof record.description === "string" ? record.description : "",
17804
+ scope: isGateScope(record.scope) ? record.scope : "all",
17805
+ condition: record.condition === "must_contain" ? "must_contain" : "must_not_contain",
17806
+ matcher: {
17807
+ type: matcher?.type === "regex" ? "regex" : "literal",
17808
+ value,
17809
+ caseInsensitive: matcher?.caseInsensitive === true
17810
+ },
17811
+ severity,
17812
+ hint: typeof record.hint === "string" && record.hint.trim() ? record.hint.trim() : void 0,
17813
+ enabled
17814
+ };
17815
+ }
17816
+ function isGateScope(value) {
17817
+ return value === "spec" || value === "page-objects" || value === "fixtures" || value === "all";
17818
+ }
17736
17819
  function compileMatcher(gate) {
17737
17820
  const flags = gate.matcher.caseInsensitive ? "i" : "";
17738
17821
  try {
@@ -17742,6 +17825,19 @@ function compileMatcher(gate) {
17742
17825
  return null;
17743
17826
  }
17744
17827
  }
17828
+ const qualityGates = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
17829
+ __proto__: null,
17830
+ DEFAULT_GATE_POLICY,
17831
+ GATE_CATEGORY_LABELS,
17832
+ GATE_SCOPE_LABELS,
17833
+ LOCKED_GATE_IDS,
17834
+ applyBypass,
17835
+ compileMatcher,
17836
+ emptyGateReport,
17837
+ isLockedGate,
17838
+ normalizeGatePolicy,
17839
+ summariseGateReport
17840
+ }, Symbol.toStringTag, { value: "Module" }));
17745
17841
  const STATUS = {
17746
17842
  passed: { icon: CircleCheck, tone: "text-success", label: "Met" },
17747
17843
  failed: { icon: CircleX, tone: "text-destructive", label: "Not met" },
@@ -33062,7 +33158,7 @@ function isTransientReachError(message) {
33062
33158
  message
33063
33159
  );
33064
33160
  }
33065
- function TesboPanel() {
33161
+ function TesboPanel({ onConnectionChange } = {}) {
33066
33162
  const [status, setStatus] = reactExports.useState(null);
33067
33163
  const [code, setCode] = reactExports.useState("");
33068
33164
  const [busy, setBusy] = reactExports.useState(false);
@@ -33071,6 +33167,8 @@ function TesboPanel() {
33071
33167
  const [agents, setAgents] = reactExports.useState(null);
33072
33168
  const statusRef = reactExports.useRef(null);
33073
33169
  const refreshGeneration = reactExports.useRef(0);
33170
+ const onConnectionChangeRef = reactExports.useRef(onConnectionChange);
33171
+ onConnectionChangeRef.current = onConnectionChange;
33074
33172
  reactExports.useEffect(() => {
33075
33173
  let cancelled = false;
33076
33174
  const apply = (next, stamp) => {
@@ -33078,6 +33176,7 @@ function TesboPanel() {
33078
33176
  if (!next.connected && isTransientReachError(next.error) && statusRef.current?.connected) {
33079
33177
  return;
33080
33178
  }
33179
+ const wasConnected = Boolean(statusRef.current?.connected);
33081
33180
  statusRef.current = next;
33082
33181
  setStatus(next);
33083
33182
  setProjectId(
@@ -33086,6 +33185,9 @@ function TesboPanel() {
33086
33185
  if (!next.connected) setAgents(null);
33087
33186
  if (next.error && !isTransientReachError(next.error)) setFormError(next.error);
33088
33187
  else if (next.connected || !next.error) setFormError(null);
33188
+ if (wasConnected !== Boolean(next.connected)) {
33189
+ onConnectionChangeRef.current?.(Boolean(next.connected));
33190
+ }
33089
33191
  };
33090
33192
  const refresh = () => {
33091
33193
  const stamp = refreshGeneration.current;
@@ -33132,6 +33234,7 @@ function TesboPanel() {
33132
33234
  setCode("");
33133
33235
  setProjectId(next.projects[0]?.id ?? "");
33134
33236
  if (next.error) setFormError(next.error);
33237
+ onConnectionChangeRef.current?.(Boolean(next.connected));
33135
33238
  } catch (error) {
33136
33239
  setFormError(error instanceof Error ? error.message : "Could not connect.");
33137
33240
  } finally {
@@ -33148,6 +33251,7 @@ function TesboPanel() {
33148
33251
  setStatus(next);
33149
33252
  setAgents(null);
33150
33253
  setProjectId("");
33254
+ onConnectionChangeRef.current?.(false);
33151
33255
  } finally {
33152
33256
  setBusy(false);
33153
33257
  }
@@ -33298,37 +33402,68 @@ function ProjectList() {
33298
33402
  let cancelled = false;
33299
33403
  const syncRemote = async (remote) => {
33300
33404
  const id = tesboProjectId$1(remote.projectId);
33405
+ const remoteUrl = String(remote.targetUrl || "").trim();
33406
+ const remoteFolder = String(remote.scriptSavePath || "").trim();
33407
+ const remoteName = String(remote.projectName || remote.userName || "Tesbo project").trim();
33408
+ const remoteDescription = String(remote.description || "").trim();
33301
33409
  ensureProject(id, {
33302
- name: remote.projectName || remote.userName || "Tesbo project",
33303
- targetUrl: remote.targetUrl || void 0,
33304
- description: remote.description || void 0
33410
+ name: remoteName || "Tesbo project",
33411
+ // Website Test Environments / Agents → Atto Target URL overwrite local placeholders.
33412
+ ...remoteUrl ? { targetUrl: remoteUrl } : {},
33413
+ ...remoteDescription ? { description: remoteDescription } : { description: void 0 }
33305
33414
  });
33306
- if (remote.scriptSavePath) setFolderPath(id, remote.scriptSavePath);
33307
- setBrowserMode(id, remote.browserMode);
33415
+ if (remoteFolder) setFolderPath(id, remoteFolder);
33416
+ setBrowserMode(id, remote.browserMode === "headless" ? "headless" : "headed");
33308
33417
  setMemories(
33309
33418
  id,
33310
33419
  (remote.memories || []).map((memory) => ({
33311
- id: memory.id,
33420
+ id: memory.id || `mem-${Math.random().toString(36).slice(2, 8)}`,
33312
33421
  kind: "note",
33313
33422
  content: memory.content,
33314
33423
  createdAt: memory.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
33315
33424
  source: "manual"
33316
33425
  }))
33317
33426
  );
33427
+ const folderForGates = remoteFolder || useAppStore.getState().projectsById[id]?.folderPath || "";
33428
+ if (folderForGates && remote.qualityGates && typeof remote.qualityGates === "object") {
33429
+ try {
33430
+ const { normalizeGatePolicy: normalizeGatePolicy2 } = await __vitePreload(async () => {
33431
+ const { normalizeGatePolicy: normalizeGatePolicy3 } = await Promise.resolve().then(() => qualityGates);
33432
+ return { normalizeGatePolicy: normalizeGatePolicy3 };
33433
+ }, true ? void 0 : void 0, import.meta.url);
33434
+ await window.taa.projects.setQualityGates({
33435
+ folderPath: folderForGates,
33436
+ policy: normalizeGatePolicy2(remote.qualityGates)
33437
+ });
33438
+ } catch {
33439
+ }
33440
+ }
33318
33441
  if (remote.aiSynced) {
33319
33442
  const bindings = await window.taa.ai.listBindings().catch(() => ({}));
33320
33443
  if (bindings[id]) setProjectAiBinding2(id, bindings[id]);
33321
33444
  }
33322
33445
  };
33446
+ const purgeTesboProjects = () => {
33447
+ const order2 = useAppStore.getState().projectOrder;
33448
+ for (const id of [...order2]) {
33449
+ if (id.startsWith("tesbo-")) deleteProject2(id);
33450
+ }
33451
+ setConnectedRemoteIds([]);
33452
+ setUnlockedRemoteIds([]);
33453
+ };
33323
33454
  const refresh = async () => {
33324
33455
  try {
33325
33456
  const status = await window.taa.tesbo.status();
33326
33457
  if (cancelled) return;
33327
- setTesboConnected(Boolean(status.connected));
33458
+ const connected = Boolean(status.connected);
33459
+ setTesboConnected(connected);
33328
33460
  setUnlockedRemoteIds(status.unlockedProjectIds || []);
33329
- const remoteIds = status.connected ? status.projects.map((project) => project.id) : [];
33461
+ const remoteIds = connected ? status.projects.map((project) => project.id) : [];
33330
33462
  setConnectedRemoteIds(remoteIds);
33331
- if (!status.connected) return;
33463
+ if (!connected) {
33464
+ purgeTesboProjects();
33465
+ return;
33466
+ }
33332
33467
  for (const project of status.projects) {
33333
33468
  ensureProject(tesboProjectId$1(project.id), {
33334
33469
  name: project.name || project.userName || "Tesbo project"
@@ -33364,7 +33499,22 @@ function ProjectList() {
33364
33499
  ] })
33365
33500
  ] }),
33366
33501
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 overflow-y-auto px-6 py-5", children: [
33367
- /* @__PURE__ */ jsxRuntimeExports.jsx(TesboPanel, {}),
33502
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
33503
+ TesboPanel,
33504
+ {
33505
+ onConnectionChange: (connected) => {
33506
+ setTesboConnected(connected);
33507
+ if (!connected) {
33508
+ const order2 = useAppStore.getState().projectOrder;
33509
+ for (const id of [...order2]) {
33510
+ if (id.startsWith("tesbo-")) deleteProject2(id);
33511
+ }
33512
+ setConnectedRemoteIds([]);
33513
+ setUnlockedRemoteIds([]);
33514
+ }
33515
+ }
33516
+ }
33517
+ ),
33368
33518
  !tesboConnected && projects.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 rounded-lg border border-dashed border-border px-4 py-8 text-center", children: [
33369
33519
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium", children: "Connect to see your project" }),
33370
33520
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Paste the project code from the website. Only that project appears here until you disconnect." })
@@ -35001,16 +35151,17 @@ async function startRemoteSession(job) {
35001
35151
  setStreamingSession
35002
35152
  } = useAppStore.getState();
35003
35153
  const id = tesboProjectId(job.projectId || "project");
35154
+ const jobUrl = String(job.targetUrl || "").trim();
35004
35155
  ensureProject(id, {
35005
35156
  name: job.projectName || "Tesbo project",
35006
- targetUrl: job.targetUrl || void 0
35157
+ ...jobUrl ? { targetUrl: jobUrl } : {}
35007
35158
  });
35008
35159
  setProjectFolderPath2(id, job.folderPath);
35009
35160
  setProjectBrowserMode2(id, job.browserMode);
35010
- if (job.targetUrl) {
35161
+ if (jobUrl) {
35011
35162
  ensureProject(id, {
35012
35163
  name: useAppStore.getState().projectsById[id]?.name || job.projectName || "Tesbo project",
35013
- targetUrl: job.targetUrl
35164
+ targetUrl: jobUrl
35014
35165
  });
35015
35166
  }
35016
35167
  setActiveProject(id, { force: true });
@@ -8,7 +8,7 @@
8
8
  />
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
10
  <title>Tesbo Automate</title>
11
- <script type="module" crossorigin src="./assets/index-DahmD4CZ.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-DevA0EpF.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="./assets/index-DyJdhPcb.css">
13
13
  </head>
14
14
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qablehq/atto",
3
- "version": "0.0.36",
3
+ "version": "0.0.39",
4
4
  "description": "Atto \u2014 AI-assisted desktop test automation",
5
5
  "homepage": "https://github.com/QAbleHQ/Atto",
6
6
  "author": {