@qablehq/atto 0.0.12 → 0.0.14

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
@@ -55,6 +55,9 @@ const IPC_CHANNELS = {
55
55
  tesboLogout: "taa:tesbo:logout",
56
56
  tesboAgents: "taa:tesbo:agents",
57
57
  tesboRemoteConfig: "taa:tesbo:remoteConfig",
58
+ /** Main → renderer: start a Chat-queued desktop session (New session equivalent). */
59
+ tesboRemoteSession: "taa:tesbo:remoteSession",
60
+ tesboAckRemoteSession: "taa:tesbo:ackRemoteSession",
58
61
  // Contextual command handling
59
62
  submitCommand: "taa:sessions:submitCommand",
60
63
  getCommandQueue: "taa:sessions:getCommandQueue",
@@ -3307,6 +3310,66 @@ async function pullAndSavePendingScripts() {
3307
3310
  return { saved, errors };
3308
3311
  }
3309
3312
  let scriptPollTimer = null;
3313
+ const claimedSessionJobs = /* @__PURE__ */ new Set();
3314
+ let remoteSessionSink = null;
3315
+ function setRemoteSessionSink(sink) {
3316
+ remoteSessionSink = sink;
3317
+ }
3318
+ async function ackAttoRemoteSession(id, status, error) {
3319
+ const link = readLink();
3320
+ if (!link || !id) return;
3321
+ await tesboFetch(link, `/api/atto/sessions/${encodeURIComponent(id)}/ack`, {
3322
+ method: "POST",
3323
+ body: JSON.stringify({ status, error: error || void 0 })
3324
+ });
3325
+ }
3326
+ async function pullAndDispatchPendingSessions() {
3327
+ const link = readLink();
3328
+ if (!link) return { started: 0, errors: [] };
3329
+ const response = await tesboFetch(link, "/api/atto/sessions/pending");
3330
+ if (response.status === 401) {
3331
+ clearLink();
3332
+ return { started: 0, errors: ["Access code stopped."] };
3333
+ }
3334
+ if (!response.ok) throw new Error(await errorMessage(response));
3335
+ const body = await response.json();
3336
+ const sessions = Array.isArray(body.sessions) ? body.sessions : [];
3337
+ let started = 0;
3338
+ const errors = [];
3339
+ for (const item of sessions) {
3340
+ if (!item?.id || !item.goal || !item.folderPath) continue;
3341
+ if (claimedSessionJobs.has(item.id)) continue;
3342
+ claimedSessionJobs.add(item.id);
3343
+ try {
3344
+ const job = {
3345
+ id: String(item.id),
3346
+ projectId: String(item.projectId || ""),
3347
+ projectName: String(item.projectName || ""),
3348
+ goal: String(item.goal || "").trim(),
3349
+ targetUrl: String(item.targetUrl || "").trim(),
3350
+ folderPath: String(item.folderPath || "").trim(),
3351
+ browserMode: item.browserMode === "headless" ? "headless" : "headed",
3352
+ createdAt: String(item.createdAt || "")
3353
+ };
3354
+ await ackAttoRemoteSession(job.id, "running");
3355
+ if (remoteSessionSink) {
3356
+ remoteSessionSink(job);
3357
+ } else {
3358
+ errors.push("Atto window is not ready to start a remote session yet.");
3359
+ }
3360
+ started += 1;
3361
+ } catch (error) {
3362
+ claimedSessionJobs.delete(item.id);
3363
+ errors.push(error instanceof Error ? error.message : "Could not start a remote session.");
3364
+ }
3365
+ }
3366
+ if (claimedSessionJobs.size > 200) {
3367
+ const keep = [...claimedSessionJobs].slice(-100);
3368
+ claimedSessionJobs.clear();
3369
+ for (const id of keep) claimedSessionJobs.add(id);
3370
+ }
3371
+ return { started, errors };
3372
+ }
3310
3373
  async function fetchAttoRemoteConfig() {
3311
3374
  const link = readLink();
3312
3375
  if (!link) return null;
@@ -3339,6 +3402,7 @@ function startAttoScriptPoller(intervalMs = 5e3) {
3339
3402
  if (scriptPollTimer) return;
3340
3403
  const tick = () => {
3341
3404
  void pullAndSavePendingScripts().catch(() => void 0);
3405
+ void pullAndDispatchPendingSessions().catch(() => void 0);
3342
3406
  };
3343
3407
  tick();
3344
3408
  scriptPollTimer = setInterval(tick, intervalMs);
@@ -3350,6 +3414,17 @@ function registerTesboHandlers() {
3350
3414
  electron.ipcMain.handle(IPC_CHANNELS.tesboLogout, () => tesboLogout());
3351
3415
  electron.ipcMain.handle(IPC_CHANNELS.tesboAgents, (_event, projectId) => tesboAgents(projectId));
3352
3416
  electron.ipcMain.handle(IPC_CHANNELS.tesboRemoteConfig, () => fetchAttoRemoteConfig());
3417
+ electron.ipcMain.handle(
3418
+ IPC_CHANNELS.tesboAckRemoteSession,
3419
+ async (_event, cmd) => {
3420
+ await ackAttoRemoteSession(cmd.id, cmd.status, cmd.error);
3421
+ }
3422
+ );
3423
+ setRemoteSessionSink((job) => {
3424
+ for (const win of electron.BrowserWindow.getAllWindows()) {
3425
+ win.webContents.send(IPC_CHANNELS.tesboRemoteSession, job);
3426
+ }
3427
+ });
3353
3428
  startAttoScriptPoller();
3354
3429
  void pullAndSavePendingScripts().catch(() => void 0);
3355
3430
  }
@@ -44,6 +44,9 @@ const IPC_CHANNELS = {
44
44
  tesboLogout: "taa:tesbo:logout",
45
45
  tesboAgents: "taa:tesbo:agents",
46
46
  tesboRemoteConfig: "taa:tesbo:remoteConfig",
47
+ /** Main → renderer: start a Chat-queued desktop session (New session equivalent). */
48
+ tesboRemoteSession: "taa:tesbo:remoteSession",
49
+ tesboAckRemoteSession: "taa:tesbo:ackRemoteSession",
47
50
  // Contextual command handling
48
51
  submitCommand: "taa:sessions:submitCommand",
49
52
  getCommandQueue: "taa:sessions:getCommandQueue",
@@ -110,7 +113,13 @@ const api = {
110
113
  login: (cmd) => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboLogin, cmd),
111
114
  logout: () => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboLogout),
112
115
  agents: (projectId) => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboAgents, projectId),
113
- remoteConfig: () => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboRemoteConfig)
116
+ remoteConfig: () => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboRemoteConfig),
117
+ onRemoteSession: (cb) => {
118
+ const listener = (_event, payload) => cb(payload);
119
+ electron.ipcRenderer.on(IPC_CHANNELS.tesboRemoteSession, listener);
120
+ return () => electron.ipcRenderer.removeListener(IPC_CHANNELS.tesboRemoteSession, listener);
121
+ },
122
+ ackRemoteSession: (cmd) => electron.ipcRenderer.invoke(IPC_CHANNELS.tesboAckRemoteSession, cmd)
114
123
  }
115
124
  };
116
125
  electron.contextBridge.exposeInMainWorld("taa", api);
@@ -33191,7 +33191,7 @@ function TesboPanel() {
33191
33191
  formError && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-3 text-sm text-destructive", children: formError })
33192
33192
  ] });
33193
33193
  }
33194
- function tesboProjectId(remote) {
33194
+ function tesboProjectId$1(remote) {
33195
33195
  return `tesbo-${remote.projectId}`;
33196
33196
  }
33197
33197
  function ProjectList() {
@@ -33213,7 +33213,7 @@ function ProjectList() {
33213
33213
  reactExports.useEffect(() => {
33214
33214
  let cancelled = false;
33215
33215
  const applyRemote = (remote) => {
33216
- const id = tesboProjectId(remote);
33216
+ const id = tesboProjectId$1(remote);
33217
33217
  ensureProject(id, {
33218
33218
  name: remote.projectName || remote.userName || "Tesbo project",
33219
33219
  targetUrl: remote.targetUrl || void 0,
@@ -34506,7 +34506,7 @@ function GateEditor({
34506
34506
  }
34507
34507
  );
34508
34508
  }
34509
- let started = false;
34509
+ let started$1 = false;
34510
34510
  function toEngineContext(project) {
34511
34511
  if (!project.folderPath || !project.aiBinding) return null;
34512
34512
  return {
@@ -34530,8 +34530,8 @@ async function syncAiBindings() {
34530
34530
  }
34531
34531
  }
34532
34532
  async function bootstrapEngineConnection() {
34533
- if (started) return;
34534
- started = true;
34533
+ if (started$1) return;
34534
+ started$1 = true;
34535
34535
  await waitForStoreHydration();
34536
34536
  const { ingestEvent, setActiveSession, setActiveProject, createProject: createProject2, linkSessionToProject: linkSessionToProject2 } = useAppStore.getState();
34537
34537
  await syncAiBindings();
@@ -34828,7 +34828,101 @@ function App() {
34828
34828
  useThemeEffect();
34829
34829
  return /* @__PURE__ */ jsxRuntimeExports.jsx(AppShell, {});
34830
34830
  }
34831
+ function tesboProjectId(projectId) {
34832
+ return `tesbo-${projectId}`;
34833
+ }
34834
+ async function startRemoteSession(job) {
34835
+ const {
34836
+ ensureProject,
34837
+ setProjectFolderPath: setProjectFolderPath2,
34838
+ setProjectBrowserMode: setProjectBrowserMode2,
34839
+ setProjectAiBinding: setProjectAiBinding2,
34840
+ setProjectAnalysis: setProjectAnalysis2,
34841
+ setProjectMemories: setProjectMemories2,
34842
+ setActiveProject,
34843
+ setView,
34844
+ linkSessionToProject: linkSessionToProject2,
34845
+ setActiveSession,
34846
+ setStreamingSession
34847
+ } = useAppStore.getState();
34848
+ const id = tesboProjectId(job.projectId || "project");
34849
+ ensureProject(id, {
34850
+ name: job.projectName || "Tesbo project",
34851
+ targetUrl: job.targetUrl || void 0
34852
+ });
34853
+ setProjectFolderPath2(id, job.folderPath);
34854
+ setProjectBrowserMode2(id, job.browserMode);
34855
+ if (job.targetUrl) {
34856
+ ensureProject(id, {
34857
+ name: useAppStore.getState().projectsById[id]?.name || job.projectName || "Tesbo project",
34858
+ targetUrl: job.targetUrl
34859
+ });
34860
+ }
34861
+ setActiveProject(id);
34862
+ setView("session");
34863
+ const bindings = await window.taa.ai.listBindings().catch(() => ({}));
34864
+ if (bindings[id]) setProjectAiBinding2(id, bindings[id]);
34865
+ let project = useAppStore.getState().projectsById[id];
34866
+ if (!project?.folderPath) {
34867
+ throw new Error("No folder path on this PC for the Atto user. Set save location under Agents → Atto.");
34868
+ }
34869
+ if (!project.aiBinding) {
34870
+ throw new Error("Connect an AI key in Atto project settings on this PC, then retry from Chat.");
34871
+ }
34872
+ if (project.analysis?.status !== "ready") {
34873
+ setProjectAnalysis2(id, { status: "analyzing" });
34874
+ try {
34875
+ const result = await window.taa.projects.analyzeFolder({
34876
+ projectId: id,
34877
+ folderPath: project.folderPath
34878
+ });
34879
+ setProjectMemories2(id, result.memories);
34880
+ setProjectAnalysis2(id, {
34881
+ status: "ready",
34882
+ lastRunAt: (/* @__PURE__ */ new Date()).toISOString(),
34883
+ usedAi: result.usedAi,
34884
+ error: result.warning
34885
+ });
34886
+ } catch {
34887
+ setProjectAnalysis2(id, { status: "ready", lastRunAt: (/* @__PURE__ */ new Date()).toISOString() });
34888
+ }
34889
+ project = useAppStore.getState().projectsById[id];
34890
+ }
34891
+ await registerProjectWithEngine(project);
34892
+ const sessionId = await window.taa.sessions.submitGoal({
34893
+ goal: job.goal,
34894
+ targetUrl: job.targetUrl || project.targetUrl,
34895
+ project: {
34896
+ projectId: project.id,
34897
+ name: project.name,
34898
+ folderPath: project.folderPath,
34899
+ targetUrl: job.targetUrl || project.targetUrl,
34900
+ memories: (project.memories || []).map((memory) => memory.content),
34901
+ browserMode: job.browserMode || project.browserMode
34902
+ }
34903
+ });
34904
+ linkSessionToProject2(id, sessionId);
34905
+ setActiveSession(sessionId);
34906
+ setStreamingSession(sessionId);
34907
+ }
34908
+ let started = false;
34909
+ function startRemoteSessionListener() {
34910
+ if (started) return;
34911
+ started = true;
34912
+ window.taa.tesbo.onRemoteSession((job) => {
34913
+ void (async () => {
34914
+ try {
34915
+ await startRemoteSession(job);
34916
+ await window.taa.tesbo.ackRemoteSession({ id: job.id, status: "done" });
34917
+ } catch (error) {
34918
+ const message = error instanceof Error ? error.message : "Could not start remote session.";
34919
+ await window.taa.tesbo.ackRemoteSession({ id: job.id, status: "failed", error: message }).catch(() => void 0);
34920
+ }
34921
+ })();
34922
+ });
34923
+ }
34831
34924
  void bootstrapEngineConnection();
34925
+ startRemoteSessionListener();
34832
34926
  ReactDOM.createRoot(document.getElementById("root")).render(
34833
34927
  /* @__PURE__ */ jsxRuntimeExports.jsx(React.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(App, {}) })
34834
34928
  );
@@ -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-BVgDk13U.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-B6r2KnCj.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="./assets/index-CKtSvvUQ.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.12",
3
+ "version": "0.0.14",
4
4
  "description": "Atto \u2014 AI-assisted desktop test automation",
5
5
  "homepage": "https://github.com/QAbleHQ/Atto",
6
6
  "author": {