@qablehq/atto 0.0.10 → 0.0.12

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/out/main/index.js CHANGED
@@ -54,6 +54,7 @@ const IPC_CHANNELS = {
54
54
  tesboLogin: "taa:tesbo:login",
55
55
  tesboLogout: "taa:tesbo:logout",
56
56
  tesboAgents: "taa:tesbo:agents",
57
+ tesboRemoteConfig: "taa:tesbo:remoteConfig",
57
58
  // Contextual command handling
58
59
  submitCommand: "taa:sessions:submitCommand",
59
60
  getCommandQueue: "taa:sessions:getCommandQueue",
@@ -3111,16 +3112,29 @@ async function errorMessage(response) {
3111
3112
  }
3112
3113
  return `Tesbo returned ${response.status}`;
3113
3114
  }
3115
+ function isTransientNetworkError(error) {
3116
+ const message = error instanceof Error ? error.message : String(error ?? "");
3117
+ return /fetch failed|failed to fetch|network|ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|socket/i.test(
3118
+ message
3119
+ );
3120
+ }
3114
3121
  async function tesboFetch(link, path, init) {
3115
- return fetch(`${link.baseUrl}${path}`, {
3122
+ const run = () => fetch(`${link.baseUrl}${path}`, {
3116
3123
  ...init,
3117
3124
  headers: {
3118
3125
  accept: "application/json",
3119
3126
  [ACCESS_HEADER]: link.code,
3120
- ...{},
3127
+ ...init?.body ? { "content-type": "application/json" } : {},
3121
3128
  ...init?.headers
3122
3129
  }
3123
3130
  });
3131
+ try {
3132
+ return await run();
3133
+ } catch (error) {
3134
+ if (!isTransientNetworkError(error) || init?.method && init.method !== "GET") throw error;
3135
+ await new Promise((resolve2) => setTimeout(resolve2, 400));
3136
+ return await run();
3137
+ }
3124
3138
  }
3125
3139
  function asProjects(value) {
3126
3140
  if (!Array.isArray(value)) return [];
@@ -3169,6 +3183,7 @@ async function tesboStatus() {
3169
3183
  try {
3170
3184
  return await loadAccount(link);
3171
3185
  } catch (error) {
3186
+ if (isTransientNetworkError(error)) return disconnected("Could not reach Tesbo.");
3172
3187
  return disconnected(error instanceof Error ? error.message : "Could not reach Tesbo.");
3173
3188
  }
3174
3189
  }
@@ -3176,11 +3191,19 @@ async function tesboLogin(cmd) {
3176
3191
  const code = cmd.code.trim();
3177
3192
  if (!code) throw new Error("Paste the access code from Tesbo.");
3178
3193
  const link = { baseUrl: DEFAULT_BASE_URL, code };
3179
- const response = await fetch(`${link.baseUrl}/api/atto/connect`, {
3194
+ const connectOnce = () => fetch(`${link.baseUrl}/api/atto/connect`, {
3180
3195
  method: "POST",
3181
3196
  headers: { accept: "application/json", "content-type": "application/json" },
3182
3197
  body: JSON.stringify({ code })
3183
3198
  });
3199
+ let response;
3200
+ try {
3201
+ response = await connectOnce();
3202
+ } catch (error) {
3203
+ if (!isTransientNetworkError(error)) throw error;
3204
+ await new Promise((resolve2) => setTimeout(resolve2, 400));
3205
+ response = await connectOnce();
3206
+ }
3184
3207
  if (!response.ok) throw new Error(await errorMessage(response));
3185
3208
  writeLink(link);
3186
3209
  const projects = asProjects(await response.json());
@@ -3244,11 +3267,91 @@ async function tesboAgents(projectId) {
3244
3267
  }
3245
3268
  return { projectId, agents: [...SERVER_AGENTS, ...COMING_SOON], notice: null };
3246
3269
  }
3270
+ function safeTargetPath(savePath, fileName) {
3271
+ const folder = node_path.resolve(node_path.normalize(savePath.trim()));
3272
+ if (!node_path.isAbsolute(folder)) throw new Error("Save location from Tesbo must be an absolute path.");
3273
+ const base = String(fileName || "script.spec.ts").replace(/[/\\]/g, "_").trim() || "script.spec.ts";
3274
+ const target = node_path.resolve(folder, base);
3275
+ const root = folder.endsWith(node_path.sep) ? folder : folder + node_path.sep;
3276
+ if (target !== folder && !target.startsWith(root)) {
3277
+ throw new Error("Refusing to write outside the configured save location.");
3278
+ }
3279
+ return target;
3280
+ }
3281
+ async function pullAndSavePendingScripts() {
3282
+ const link = readLink();
3283
+ if (!link) return { saved: 0, errors: [] };
3284
+ const response = await tesboFetch(link, "/api/atto/scripts/pending");
3285
+ if (response.status === 401) {
3286
+ clearLink();
3287
+ return { saved: 0, errors: ["Access code stopped."] };
3288
+ }
3289
+ if (!response.ok) throw new Error(await errorMessage(response));
3290
+ const body = await response.json();
3291
+ const scripts = Array.isArray(body.scripts) ? body.scripts : [];
3292
+ let saved = 0;
3293
+ const errors = [];
3294
+ for (const item of scripts) {
3295
+ if (!item?.id || !item.script || !item.savePath) continue;
3296
+ try {
3297
+ const target = safeTargetPath(item.savePath, item.fileName || `${item.externalId || "script"}.spec.ts`);
3298
+ node_fs.mkdirSync(node_path.resolve(node_path.normalize(item.savePath.trim())), { recursive: true });
3299
+ node_fs.writeFileSync(target, item.script, { encoding: "utf8" });
3300
+ const ack = await tesboFetch(link, `/api/atto/scripts/${encodeURIComponent(item.id)}/ack`, { method: "POST", body: "{}" });
3301
+ if (!ack.ok) throw new Error(await errorMessage(ack));
3302
+ saved += 1;
3303
+ } catch (error) {
3304
+ errors.push(error instanceof Error ? error.message : "Could not save a script.");
3305
+ }
3306
+ }
3307
+ return { saved, errors };
3308
+ }
3309
+ let scriptPollTimer = null;
3310
+ async function fetchAttoRemoteConfig() {
3311
+ const link = readLink();
3312
+ if (!link) return null;
3313
+ const response = await tesboFetch(link, "/api/atto/remote-config");
3314
+ if (response.status === 401) {
3315
+ clearLink();
3316
+ return null;
3317
+ }
3318
+ if (!response.ok) throw new Error(await errorMessage(response));
3319
+ const body = await response.json();
3320
+ return {
3321
+ userName: String(body.userName || ""),
3322
+ clientName: String(body.clientName || ""),
3323
+ projectId: String(body.projectId || ""),
3324
+ projectName: String(body.projectName || ""),
3325
+ scriptSavePath: String(body.scriptSavePath || "").trim(),
3326
+ browserMode: body.browserMode === "headless" ? "headless" : "headed",
3327
+ targetUrl: String(body.targetUrl || "").trim(),
3328
+ description: String(body.description || "").trim(),
3329
+ memories: Array.isArray(body.memories) ? body.memories : [],
3330
+ qualityGates: body.qualityGates && typeof body.qualityGates === "object" ? body.qualityGates : {},
3331
+ install: {
3332
+ package: String(body.install?.package || "npm install -g @qablehq/atto"),
3333
+ chromium: String(body.install?.chromium || "npx playwright install chromium"),
3334
+ note: String(body.install?.note || "")
3335
+ }
3336
+ };
3337
+ }
3338
+ function startAttoScriptPoller(intervalMs = 5e3) {
3339
+ if (scriptPollTimer) return;
3340
+ const tick = () => {
3341
+ void pullAndSavePendingScripts().catch(() => void 0);
3342
+ };
3343
+ tick();
3344
+ scriptPollTimer = setInterval(tick, intervalMs);
3345
+ scriptPollTimer.unref?.();
3346
+ }
3247
3347
  function registerTesboHandlers() {
3248
3348
  electron.ipcMain.handle(IPC_CHANNELS.tesboStatus, () => tesboStatus());
3249
3349
  electron.ipcMain.handle(IPC_CHANNELS.tesboLogin, (_event, cmd) => tesboLogin(cmd));
3250
3350
  electron.ipcMain.handle(IPC_CHANNELS.tesboLogout, () => tesboLogout());
3251
3351
  electron.ipcMain.handle(IPC_CHANNELS.tesboAgents, (_event, projectId) => tesboAgents(projectId));
3352
+ electron.ipcMain.handle(IPC_CHANNELS.tesboRemoteConfig, () => fetchAttoRemoteConfig());
3353
+ startAttoScriptPoller();
3354
+ void pullAndSavePendingScripts().catch(() => void 0);
3252
3355
  }
3253
3356
  const SCHEME = "taa-media";
3254
3357
  const sessionRoots = /* @__PURE__ */ new Map();
@@ -43,6 +43,7 @@ const IPC_CHANNELS = {
43
43
  tesboLogin: "taa:tesbo:login",
44
44
  tesboLogout: "taa:tesbo:logout",
45
45
  tesboAgents: "taa:tesbo:agents",
46
+ tesboRemoteConfig: "taa:tesbo:remoteConfig",
46
47
  // Contextual command handling
47
48
  submitCommand: "taa:sessions:submitCommand",
48
49
  getCommandQueue: "taa:sessions:getCommandQueue",
@@ -108,7 +109,8 @@ const api = {
108
109
  status: () => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboStatus),
109
110
  login: (cmd) => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboLogin, cmd),
110
111
  logout: () => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboLogout),
111
- agents: (projectId) => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboAgents, projectId)
112
+ agents: (projectId) => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboAgents, projectId),
113
+ remoteConfig: () => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboRemoteConfig)
112
114
  }
113
115
  };
114
116
  electron.contextBridge.exposeInMainWorld("taa", api);
@@ -17045,6 +17045,12 @@ const useAppStore = create$1()(
17045
17045
  set((state) => createProject(state, id, input));
17046
17046
  return id;
17047
17047
  },
17048
+ ensureProject: (id, input) => {
17049
+ set(
17050
+ (state) => state.projectsById[id] ? updateProject(state, id, input) : createProject(state, id, input)
17051
+ );
17052
+ return id;
17053
+ },
17048
17054
  updateProject: (id, patch) => set((state) => updateProject(state, id, patch)),
17049
17055
  deleteProject: (id) => set((state) => {
17050
17056
  const wasActive = state.activeProjectId === id;
@@ -33030,6 +33036,12 @@ const STATUS_LABEL$1 = {
33030
33036
  inactive: "Inactive",
33031
33037
  "coming-soon": "Coming soon"
33032
33038
  };
33039
+ function isTransientReachError(message) {
33040
+ if (!message) return false;
33041
+ return /could not reach tesbo|fetch failed|failed to fetch|network|ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND/i.test(
33042
+ message
33043
+ );
33044
+ }
33033
33045
  function TesboPanel() {
33034
33046
  const [status, setStatus] = reactExports.useState(null);
33035
33047
  const [code, setCode] = reactExports.useState("");
@@ -33043,15 +33055,17 @@ function TesboPanel() {
33043
33055
  let cancelled = false;
33044
33056
  const apply = (next, stamp) => {
33045
33057
  if (cancelled || stamp !== refreshGeneration.current) return;
33046
- const offline = !next.connected && next.error === "Could not reach Tesbo.";
33047
- if (offline && statusRef.current?.connected) return;
33058
+ if (!next.connected && isTransientReachError(next.error) && statusRef.current?.connected) {
33059
+ return;
33060
+ }
33048
33061
  statusRef.current = next;
33049
33062
  setStatus(next);
33050
33063
  setProjectId(
33051
33064
  (current) => next.projects.some((project) => project.id === current) ? current : next.projects[0]?.id ?? ""
33052
33065
  );
33053
33066
  if (!next.connected) setAgents(null);
33054
- if (next.error) setFormError(next.error);
33067
+ if (next.error && !isTransientReachError(next.error)) setFormError(next.error);
33068
+ else if (next.connected || !next.error) setFormError(null);
33055
33069
  };
33056
33070
  const refresh = () => {
33057
33071
  const stamp = refreshGeneration.current;
@@ -33073,11 +33087,15 @@ function TesboPanel() {
33073
33087
  }
33074
33088
  let cancelled = false;
33075
33089
  void window.taa.tesbo.agents(projectId).then((next) => {
33076
- if (!cancelled) setAgents(next);
33090
+ if (cancelled) return;
33091
+ setAgents(next);
33092
+ setFormError(null);
33077
33093
  }).catch((error) => {
33078
33094
  if (cancelled) return;
33095
+ const message = error instanceof Error ? error.message : "Could not load agents.";
33096
+ if (isTransientReachError(message)) return;
33079
33097
  setAgents(null);
33080
- setFormError(error instanceof Error ? error.message : "Could not load agents.");
33098
+ setFormError(message);
33081
33099
  });
33082
33100
  return () => {
33083
33101
  cancelled = true;
@@ -33173,24 +33191,74 @@ function TesboPanel() {
33173
33191
  formError && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-3 text-sm text-destructive", children: formError })
33174
33192
  ] });
33175
33193
  }
33194
+ function tesboProjectId(remote) {
33195
+ return `tesbo-${remote.projectId}`;
33196
+ }
33176
33197
  function ProjectList() {
33177
33198
  const projectsById = useAppStore((s2) => s2.projectsById);
33178
33199
  const projectOrder = useAppStore((s2) => s2.projectOrder);
33179
33200
  const setActiveProject = useAppStore((s2) => s2.setActiveProject);
33180
33201
  const setView = useAppStore((s2) => s2.setView);
33202
+ const ensureProject = useAppStore((s2) => s2.ensureProject);
33203
+ const setFolderPath = useAppStore((s2) => s2.setProjectFolderPath);
33204
+ const setBrowserMode = useAppStore((s2) => s2.setProjectBrowserMode);
33205
+ const setMemories = useAppStore((s2) => s2.setProjectMemories);
33181
33206
  const [dialogOpen, setDialogOpen] = reactExports.useState(false);
33207
+ const [tesboConnected, setTesboConnected] = reactExports.useState(false);
33182
33208
  const projects = projectOrder.map((id) => projectsById[id]);
33183
33209
  const openProjectSettings = (id) => {
33184
33210
  setActiveProject(id);
33185
33211
  setView("project-settings");
33186
33212
  };
33213
+ reactExports.useEffect(() => {
33214
+ let cancelled = false;
33215
+ const applyRemote = (remote) => {
33216
+ const id = tesboProjectId(remote);
33217
+ ensureProject(id, {
33218
+ name: remote.projectName || remote.userName || "Tesbo project",
33219
+ targetUrl: remote.targetUrl || void 0,
33220
+ description: remote.description || void 0
33221
+ });
33222
+ if (remote.scriptSavePath) setFolderPath(id, remote.scriptSavePath);
33223
+ setBrowserMode(id, remote.browserMode);
33224
+ setMemories(
33225
+ id,
33226
+ (remote.memories || []).map((memory) => ({
33227
+ id: memory.id,
33228
+ kind: "note",
33229
+ content: memory.content,
33230
+ createdAt: memory.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
33231
+ source: "manual"
33232
+ }))
33233
+ );
33234
+ setActiveProject(id);
33235
+ };
33236
+ const refresh = async () => {
33237
+ try {
33238
+ const status = await window.taa.tesbo.status();
33239
+ if (cancelled) return;
33240
+ setTesboConnected(Boolean(status.connected));
33241
+ if (!status.connected) return;
33242
+ const remote = await window.taa.tesbo.remoteConfig();
33243
+ if (cancelled || !remote?.projectId) return;
33244
+ applyRemote(remote);
33245
+ } catch {
33246
+ }
33247
+ };
33248
+ void refresh();
33249
+ const timer = window.setInterval(() => void refresh(), 8e3);
33250
+ return () => {
33251
+ cancelled = true;
33252
+ window.clearInterval(timer);
33253
+ };
33254
+ }, [ensureProject, setFolderPath, setBrowserMode, setMemories, setActiveProject]);
33187
33255
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full w-full flex-1 flex-col overflow-hidden bg-background", children: [
33188
33256
  /* @__PURE__ */ jsxRuntimeExports.jsxs("header", { className: "flex items-center justify-between border-b border-border px-6 py-4", children: [
33189
33257
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
33190
33258
  /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-lg font-semibold", children: "Projects" }),
33191
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "Group your test cases by the app or flow they cover." })
33259
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: tesboConnected ? "Connected to Tesbo. Folder, browser mode, and memories come from Agents → Atto on the website." : "Group your test cases by the app or flow they cover." })
33192
33260
  ] }),
33193
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { size: "sm", className: "gap-2", onClick: () => setDialogOpen(true), children: [
33261
+ !tesboConnected && /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { size: "sm", className: "gap-2", onClick: () => setDialogOpen(true), children: [
33194
33262
  /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-4" }),
33195
33263
  "New project"
33196
33264
  ] })
@@ -33200,10 +33268,10 @@ function ProjectList() {
33200
33268
  projects.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-center", children: [
33201
33269
  /* @__PURE__ */ jsxRuntimeExports.jsx(FolderKanban, { className: "size-8 text-muted-foreground" }),
33202
33270
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
33203
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium", children: "No projects yet" }),
33204
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "Create a project to start generating test cases." })
33271
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium", children: tesboConnected ? "Waiting for website settings" : "No projects yet" }),
33272
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: tesboConnected ? "On app-atto.tesbo.io open Agents → Atto, set the project folder path, then keep Atto connected." : "Create a project to start generating test cases." })
33205
33273
  ] }),
33206
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { size: "sm", className: "gap-2", onClick: () => setDialogOpen(true), children: [
33274
+ !tesboConnected && /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { size: "sm", className: "gap-2", onClick: () => setDialogOpen(true), children: [
33207
33275
  /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-4" }),
33208
33276
  "New project"
33209
33277
  ] })
@@ -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-CWoTAmL0.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-BVgDk13U.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="./assets/index-CKtSvvUQ.css">
13
13
  </head>
14
14
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qablehq/atto",
3
- "version": "0.0.10",
4
- "description": "Atto — AI-assisted desktop test automation",
3
+ "version": "0.0.12",
4
+ "description": "Atto \u2014 AI-assisted desktop test automation",
5
5
  "homepage": "https://github.com/QAbleHQ/Atto",
6
6
  "author": {
7
7
  "name": "QAble",