@qablehq/atto 0.0.18 → 0.0.19

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.
Files changed (179) hide show
  1. package/out/main/index.js +544 -192
  2. package/out/preload/index.js +15 -1
  3. package/out/renderer/assets/actionscript-3-XzMDKpbw.js +7 -0
  4. package/out/renderer/assets/{ada-BZS802Se.js → ada-BygE0u4b.js} +1 -1
  5. package/out/renderer/assets/ahk-BMkQhlCC.js +7 -0
  6. package/out/renderer/assets/ahk2-CcfgwDsZ.js +7 -0
  7. package/out/renderer/assets/{angular-html-BJCWRjqJ.js → angular-html-DuB66kSz.js} +1 -1
  8. package/out/renderer/assets/{angular-ts-DY2SSsMH.js → angular-ts-D5xc9lym.js} +4 -4
  9. package/out/renderer/assets/apex-qg9RQ075.js +7 -0
  10. package/out/renderer/assets/{apl-DaBQFEEA.js → apl-yOYUHP8d.js} +2 -2
  11. package/out/renderer/assets/asciidoc-C0WHk4w6.js +7 -0
  12. package/out/renderer/assets/{astro-y3sdhPpl.js → astro-2kT-iZU2.js} +1 -1
  13. package/out/renderer/assets/{bat-BzNgQIA7.js → bat-Dkbx_DMM.js} +1 -1
  14. package/out/renderer/assets/beancount-DsK3lj01.js +7 -0
  15. package/out/renderer/assets/bird2-iVuaRSDs.js +7 -0
  16. package/out/renderer/assets/{blade-DTIBeXBj.js → blade-H7By5jXu.js} +4 -4
  17. package/out/renderer/assets/bsl-BQH46PtH.js +9 -0
  18. package/out/renderer/assets/c3-_0-mb_f-.js +7 -0
  19. package/out/renderer/assets/catppuccin-frappe-CsW6iLIR.js +4 -0
  20. package/out/renderer/assets/catppuccin-latte-reHbSDAH.js +4 -0
  21. package/out/renderer/assets/catppuccin-macchiato-rSGd47q5.js +4 -0
  22. package/out/renderer/assets/catppuccin-mocha-C6c0_b-7.js +4 -0
  23. package/out/renderer/assets/chapel-wQk8d_On.js +9 -0
  24. package/out/renderer/assets/clarity-C5IjJ-qf.js +7 -0
  25. package/out/renderer/assets/{cobol-Cff68WIy.js → cobol-DauSNXId.js} +2 -2
  26. package/out/renderer/assets/coq-DPxrIdHD.js +7 -0
  27. package/out/renderer/assets/cpp-CjtLXoXm.js +19 -0
  28. package/out/renderer/assets/{crystal-CCwukLCR.js → crystal-DhDF6hP-.js} +3 -3
  29. package/out/renderer/assets/csharp-B9Sq4das.js +7 -0
  30. package/out/renderer/assets/css-RFTgTh3p.js +7 -0
  31. package/out/renderer/assets/dart-C9cA83Kz.js +7 -0
  32. package/out/renderer/assets/dotenv-D6mB0Q3S.js +7 -0
  33. package/out/renderer/assets/{edge-Bt6vbpjM.js → edge-DwlWfPqZ.js} +3 -3
  34. package/out/renderer/assets/{elixir-Cuo0djbX.js → elixir-B5T6YfxL.js} +2 -2
  35. package/out/renderer/assets/emacs-lisp-DA7QHB8Q.js +7 -0
  36. package/out/renderer/assets/{erb-V2Ws3SNY.js → erb-ClV2iBZ3.js} +6 -6
  37. package/out/renderer/assets/{gdresource-B5TLWiFO.js → gdresource-CRSgAcUB.js} +1 -1
  38. package/out/renderer/assets/gdscript-DO90EOCr.js +7 -0
  39. package/out/renderer/assets/{git-commit-PP9xCApN.js → git-commit-Dv4XKH0P.js} +2 -2
  40. package/out/renderer/assets/{git-rebase-D-XQSvDj.js → git-rebase-CBPs_8pF.js} +2 -2
  41. package/out/renderer/assets/{glimmer-js-DG20vYlC.js → glimmer-js-BoSiU7IK.js} +2 -2
  42. package/out/renderer/assets/{glimmer-ts-C6w_4QSb.js → glimmer-ts-D5t4bJm3.js} +2 -2
  43. package/out/renderer/assets/gn-hQC9pe50.js +7 -0
  44. package/out/renderer/assets/hack-BMCu-aN4.js +13 -0
  45. package/out/renderer/assets/{haml-DlpJLJBj.js → haml-aYVaJAFz.js} +1 -1
  46. package/out/renderer/assets/handlebars-DOx8io1-.js +15 -0
  47. package/out/renderer/assets/haxe-BRsgd3cI.js +7 -0
  48. package/out/renderer/assets/{html-DmbcFRC9.js → html-BJOXR_IN.js} +1 -1
  49. package/out/renderer/assets/{html-derivative-hBF5i0yR.js → html-derivative-DMkc3qiA.js} +2 -2
  50. package/out/renderer/assets/hxml-bhUxPckm.js +9 -0
  51. package/out/renderer/assets/{index-CKtSvvUQ.css → index-Cmmme7Q7.css} +4 -4
  52. package/out/renderer/assets/{index-CWoTAmL0.js → index-fqs2TZZI.js} +4301 -1702
  53. package/out/renderer/assets/{jinja-Co0rsagz.js → jinja-CYR28n3S.js} +2 -2
  54. package/out/renderer/assets/{julia-CF2trtnW.js → julia-DiYuCSV5.js} +4 -4
  55. package/out/renderer/assets/{just-DLfNrYXP.js → just-njno1COI.js} +8 -8
  56. package/out/renderer/assets/kanagawa-dragon-BzrndB3G.js +4 -0
  57. package/out/renderer/assets/kanagawa-lotus-BMbWLXSu.js +4 -0
  58. package/out/renderer/assets/kanagawa-wave-OC_VodQx.js +4 -0
  59. package/out/renderer/assets/latex-B9v8pMd0.js +10 -0
  60. package/out/renderer/assets/{liquid-CRPVOqng.js → liquid-er0ejDCL.js} +2 -2
  61. package/out/renderer/assets/{llvm-CTKcAHbb.js → llvm-vwd2ARYn.js} +1 -1
  62. package/out/renderer/assets/luau-_M-Xr-8y.js +7 -0
  63. package/out/renderer/assets/marko-DZ3fVwnp.js +15 -0
  64. package/out/renderer/assets/mdc-Dg7yoyIh.js +16 -0
  65. package/out/renderer/assets/mermaid-cpc8TKa6.js +7 -0
  66. package/out/renderer/assets/mojo-CCMjFYSY.js +7 -0
  67. package/out/renderer/assets/monokai-BL-7sM2b.js +4 -0
  68. package/out/renderer/assets/moonbit-NJknOnNj.js +7 -0
  69. package/out/renderer/assets/move-e8N3PYLu.js +7 -0
  70. package/out/renderer/assets/{nextflow-CZlu-KJ9.js → nextflow-duJcHzhS.js} +2 -2
  71. package/out/renderer/assets/{nextflow-groovy-BoHzzNJ-.js → nextflow-groovy-BVAMb5Nw.js} +1 -1
  72. package/out/renderer/assets/{nim-DH52b3O2.js → nim-CO9jlkx_.js} +2 -2
  73. package/out/renderer/assets/nsis-CgTxT63b.js +7 -0
  74. package/out/renderer/assets/nushell-DhZRrV4v.js +7 -0
  75. package/out/renderer/assets/{objective-c-BRoNQF42.js → objective-c-BSkeXF7b.js} +2 -2
  76. package/out/renderer/assets/one-dark-pro-DfmyFT_9.js +4 -0
  77. package/out/renderer/assets/org-CQ3J1455.js +106 -0
  78. package/out/renderer/assets/{perl-DNMq5TeG.js → perl-BFPqQ3p2.js} +3 -3
  79. package/out/renderer/assets/php-BWimq2sn.js +20 -0
  80. package/out/renderer/assets/{powershell-BcMVbGpk.js → powershell-BM-TNTx9.js} +1 -1
  81. package/out/renderer/assets/prisma-BGGfvhdm.js +7 -0
  82. package/out/renderer/assets/{pug-SkQ8WOMr.js → pug-BFbasRPI.js} +2 -2
  83. package/out/renderer/assets/r-AvJ-_IZz.js +7 -0
  84. package/out/renderer/assets/{razor-CAqfpVJf.js → razor-dJKRQxMy.js} +3 -3
  85. package/out/renderer/assets/rbs-CsVKzbYM.js +7 -0
  86. package/out/renderer/assets/red-BcXR4G_B.js +4 -0
  87. package/out/renderer/assets/rose-pine-DsUfEP3G.js +4 -0
  88. package/out/renderer/assets/rose-pine-dawn-BvRaiqBN.js +4 -0
  89. package/out/renderer/assets/rose-pine-moon-B51k6Eh0.js +4 -0
  90. package/out/renderer/assets/{rst-d2ON5Kil.js → rst-rpZ4ExZM.js} +7 -7
  91. package/out/renderer/assets/{ruby-D3ZRMd1J.js → ruby-DqVdtl8n.js} +6 -6
  92. package/out/renderer/assets/rust-66fbAM7D.js +7 -0
  93. package/out/renderer/assets/{sas-C8EJbWIQ.js → sas-BqoR79ug.js} +1 -1
  94. package/out/renderer/assets/{scala-B-_7vFVn.js → scala-X3YXDlFi.js} +1 -1
  95. package/out/renderer/assets/{scss-FZJI91Eq.js → scss-3k6UWg9O.js} +1 -1
  96. package/out/renderer/assets/smalltalk-CwntpOpi.js +7 -0
  97. package/out/renderer/assets/smithy-y2AkadvV.js +7 -0
  98. package/out/renderer/assets/solarized-dark-9CqJc6gu.js +4 -0
  99. package/out/renderer/assets/solarized-light-CahvOdlg.js +4 -0
  100. package/out/renderer/assets/solidity-7D_UgM9r.js +7 -0
  101. package/out/renderer/assets/{soy-DAT1Vt2Q.js → soy-COqPEtV1.js} +2 -2
  102. package/out/renderer/assets/sql-DRwHerI8.js +7 -0
  103. package/out/renderer/assets/{stata-BQJhX8pA.js → stata-Cq8N7nxi.js} +1 -1
  104. package/out/renderer/assets/surrealql-CU92wPzz.js +9 -0
  105. package/out/renderer/assets/{svelte-DYzzbzh8.js → svelte-Cv_F2nMH.js} +2 -2
  106. package/out/renderer/assets/swift-C0Fmtg1M.js +7 -0
  107. package/out/renderer/assets/system-verilog-yaG6IMEl.js +7 -0
  108. package/out/renderer/assets/{templ-BwefK4nX.js → templ-G5iBeRA1.js} +1 -1
  109. package/out/renderer/assets/{tex-CGVqF8nD.js → tex-DieQ98e7.js} +1 -1
  110. package/out/renderer/assets/{ts-tags-Bbg2DCJJ.js → ts-tags-dhWLpawA.js} +3 -3
  111. package/out/renderer/assets/twig-D9Wa-3Eg.js +36 -0
  112. package/out/renderer/assets/typespec-BxYMz8HZ.js +7 -0
  113. package/out/renderer/assets/typst-C8rHYIyJ.js +126 -0
  114. package/out/renderer/assets/{v-BSYXvR4g.js → v-Dq8gf8Kd.js} +1 -1
  115. package/out/renderer/assets/{vb-Bzg9rspf.js → vb-Csa1FuFR.js} +1 -1
  116. package/out/renderer/assets/verilog-D6UvsxG6.js +7 -0
  117. package/out/renderer/assets/{vue-BSHLbQPw.js → vue-DhJhQFen.js} +4 -4
  118. package/out/renderer/assets/{vue-vine-CBak_P96.js → vue-vine-Da6PFzL2.js} +2 -2
  119. package/out/renderer/index.html +2 -2
  120. package/package.json +1 -1
  121. package/out/renderer/assets/actionscript-3-DtnkuHN2.js +0 -7
  122. package/out/renderer/assets/apex-Df0W-oIK.js +0 -7
  123. package/out/renderer/assets/asciidoc-CT8_dLUs.js +0 -7
  124. package/out/renderer/assets/beancount-aZWrE5WV.js +0 -7
  125. package/out/renderer/assets/bird2-BQeaUJ-I.js +0 -7
  126. package/out/renderer/assets/bsl-DwPS0BId.js +0 -9
  127. package/out/renderer/assets/c3-D2B0LXIg.js +0 -7
  128. package/out/renderer/assets/catppuccin-frappe-C21OPQfC.js +0 -4
  129. package/out/renderer/assets/catppuccin-latte-0ZtXlsrX.js +0 -4
  130. package/out/renderer/assets/catppuccin-macchiato-BD_FR4sl.js +0 -4
  131. package/out/renderer/assets/catppuccin-mocha-C653csR5.js +0 -4
  132. package/out/renderer/assets/clarity-D2ViJC0i.js +0 -7
  133. package/out/renderer/assets/coq-l_JvzFJl.js +0 -7
  134. package/out/renderer/assets/cpp-B-e1Rzcy.js +0 -22
  135. package/out/renderer/assets/csharp-ChNHWsy7.js +0 -7
  136. package/out/renderer/assets/css-DfTYai-u.js +0 -7
  137. package/out/renderer/assets/dart-BNVTaiA9.js +0 -7
  138. package/out/renderer/assets/dotenv-Bb4iNxXK.js +0 -7
  139. package/out/renderer/assets/emacs-lisp-DbZW1X_J.js +0 -7
  140. package/out/renderer/assets/gdscript-CNW3Aj-d.js +0 -7
  141. package/out/renderer/assets/gn-OUMx7fqt.js +0 -7
  142. package/out/renderer/assets/hack-DjUcXazN.js +0 -13
  143. package/out/renderer/assets/handlebars-DCI1Liu6.js +0 -15
  144. package/out/renderer/assets/haxe-BpobLYM9.js +0 -7
  145. package/out/renderer/assets/hxml-Jle7oGdm.js +0 -9
  146. package/out/renderer/assets/kanagawa-dragon-DU8n2NNT.js +0 -4
  147. package/out/renderer/assets/kanagawa-lotus-Byd0CDet.js +0 -4
  148. package/out/renderer/assets/kanagawa-wave-DExoagcR.js +0 -4
  149. package/out/renderer/assets/latex-CXCNXL7j.js +0 -10
  150. package/out/renderer/assets/luau-CZXYDZ20.js +0 -7
  151. package/out/renderer/assets/marko-CIEVFCDi.js +0 -15
  152. package/out/renderer/assets/mdc-CgmrJS3R.js +0 -16
  153. package/out/renderer/assets/mermaid-z_1ejSlp.js +0 -7
  154. package/out/renderer/assets/mojo-ByCRDvCf.js +0 -7
  155. package/out/renderer/assets/monokai-DelygWXa.js +0 -4
  156. package/out/renderer/assets/moonbit-CqjK87KZ.js +0 -7
  157. package/out/renderer/assets/move-DhTNmxqC.js +0 -7
  158. package/out/renderer/assets/nushell-DB8ZUEbK.js +0 -7
  159. package/out/renderer/assets/one-dark-pro-CsMf0BoJ.js +0 -4
  160. package/out/renderer/assets/php-Dhtz88su.js +0 -20
  161. package/out/renderer/assets/prisma-bmxcSDxq.js +0 -7
  162. package/out/renderer/assets/r-Dpdc-Kyk.js +0 -7
  163. package/out/renderer/assets/red-DByOl5N0.js +0 -4
  164. package/out/renderer/assets/rose-pine-B-kZ4Z9q.js +0 -4
  165. package/out/renderer/assets/rose-pine-dawn-efeVGdSI.js +0 -4
  166. package/out/renderer/assets/rose-pine-moon-DmodZNzl.js +0 -4
  167. package/out/renderer/assets/rust-CMNYZh5a.js +0 -7
  168. package/out/renderer/assets/smalltalk-qxcGy4fT.js +0 -7
  169. package/out/renderer/assets/solarized-dark-BBl5y5sR.js +0 -4
  170. package/out/renderer/assets/solarized-light-DW9b_AY8.js +0 -4
  171. package/out/renderer/assets/solidity-CSTQ0FCC.js +0 -7
  172. package/out/renderer/assets/sql-D_4CBcMI.js +0 -7
  173. package/out/renderer/assets/surrealql-Bs3vUeKA.js +0 -9
  174. package/out/renderer/assets/swift-Cohr-WZC.js +0 -7
  175. package/out/renderer/assets/system-verilog-BcESSvRn.js +0 -7
  176. package/out/renderer/assets/twig-B5sqQI1E.js +0 -36
  177. package/out/renderer/assets/typespec-CmH6i407.js +0 -7
  178. package/out/renderer/assets/typst-XYLFxYau.js +0 -7
  179. package/out/renderer/assets/verilog-CCb_iTfF.js +0 -7
package/out/main/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  const electron = require("electron");
3
3
  const node_path = require("node:path");
4
- const Anthropic = require("@anthropic-ai/sdk");
5
4
  const node_fs = require("node:fs");
5
+ const node_url = require("node:url");
6
+ const Anthropic = require("@anthropic-ai/sdk");
6
7
  const node_crypto = require("node:crypto");
7
8
  const node_http = require("node:http");
8
- const node_url = require("node:url");
9
9
  const node_child_process = require("node:child_process");
10
10
  const playwright = require("playwright");
11
11
  const ts = require("typescript");
@@ -54,11 +54,531 @@ 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",
58
+ /** Main → renderer: start a Chat-queued desktop session (New session equivalent). */
59
+ tesboRemoteSession: "taa:tesbo:remoteSession",
60
+ tesboAckRemoteSession: "taa:tesbo:ackRemoteSession",
61
+ /** Renderer → main: bind a RealEngine session to a Chat job for live mirroring. */
62
+ tesboBindRemoteSession: "taa:tesbo:bindRemoteSession",
57
63
  // Contextual command handling
58
64
  submitCommand: "taa:sessions:submitCommand",
59
65
  getCommandQueue: "taa:sessions:getCommandQueue",
60
66
  clearCommandQueue: "taa:sessions:clearCommandQueue"
61
67
  };
68
+ const SCHEME = "taa-media";
69
+ const sessionRoots = /* @__PURE__ */ new Map();
70
+ const FIXTURES_ASSETS_DIR = node_path.join(electron.app.getAppPath(), "src/main/engine/mock/fixtures/assets");
71
+ function registerSessionMediaRoot(sessionId, absoluteDir) {
72
+ sessionRoots.set(sessionId, absoluteDir);
73
+ }
74
+ function resolveSessionMediaFile(sessionId, filename) {
75
+ const root = sessionRoots.get(sessionId);
76
+ if (!root) return null;
77
+ const safe = node_path.basename(filename);
78
+ if (!safe) return null;
79
+ return node_path.join(root, safe);
80
+ }
81
+ function registerMediaProtocolScheme() {
82
+ electron.protocol.registerSchemesAsPrivileged([
83
+ {
84
+ scheme: SCHEME,
85
+ privileges: { standard: true, secure: true, supportFetchAPI: true, corsEnabled: true, stream: true }
86
+ }
87
+ ]);
88
+ }
89
+ function registerMediaProtocol() {
90
+ electron.protocol.handle(SCHEME, (request) => {
91
+ const url = new URL(request.url);
92
+ const filename = node_path.basename(decodeURIComponent(url.pathname.replace(/^\/+/, "")));
93
+ const root = sessionRoots.get(url.hostname) ?? FIXTURES_ASSETS_DIR;
94
+ return electron.net.fetch(node_url.pathToFileURL(node_path.join(root, filename)).toString());
95
+ });
96
+ }
97
+ const DEFAULT_BASE_URL = "https://api-app-atto.tesbo.io";
98
+ const ACCESS_HEADER = "x-atto-access-code";
99
+ function sessionPath() {
100
+ return node_path.join(electron.app.getPath("userData"), "tesbo-link.json");
101
+ }
102
+ function readLink() {
103
+ try {
104
+ const parsed = JSON.parse(node_fs.readFileSync(sessionPath(), "utf8"));
105
+ if (typeof parsed.code !== "string" || !parsed.code.trim()) return null;
106
+ return { baseUrl: DEFAULT_BASE_URL, code: parsed.code.trim() };
107
+ } catch {
108
+ return null;
109
+ }
110
+ }
111
+ function writeLink(link) {
112
+ const path = sessionPath();
113
+ node_fs.mkdirSync(electron.app.getPath("userData"), { recursive: true });
114
+ node_fs.writeFileSync(path, JSON.stringify(link), { mode: 384 });
115
+ node_fs.chmodSync(path, 384);
116
+ }
117
+ function clearLink() {
118
+ node_fs.rmSync(sessionPath(), { force: true });
119
+ }
120
+ function disconnected(error = null) {
121
+ return { connected: false, baseUrl: DEFAULT_BASE_URL, user: null, workspaces: [], projects: [], error };
122
+ }
123
+ async function errorMessage(response) {
124
+ try {
125
+ const body = await response.json();
126
+ if (typeof body.error === "string" && body.error.trim()) return body.error;
127
+ if (typeof body.message === "string" && body.message.trim()) return body.message;
128
+ } catch {
129
+ }
130
+ return `Tesbo returned ${response.status}`;
131
+ }
132
+ function isTransientNetworkError(error) {
133
+ const message = error instanceof Error ? error.message : String(error ?? "");
134
+ return /fetch failed|failed to fetch|network|ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|socket/i.test(
135
+ message
136
+ );
137
+ }
138
+ async function tesboFetch(link, path, init) {
139
+ const run = () => fetch(`${link.baseUrl}${path}`, {
140
+ ...init,
141
+ headers: {
142
+ accept: "application/json",
143
+ [ACCESS_HEADER]: link.code,
144
+ ...init?.body ? { "content-type": "application/json" } : {},
145
+ ...init?.headers
146
+ }
147
+ });
148
+ try {
149
+ return await run();
150
+ } catch (error) {
151
+ if (!isTransientNetworkError(error) || init?.method && init.method !== "GET") throw error;
152
+ await new Promise((resolve2) => setTimeout(resolve2, 400));
153
+ return await run();
154
+ }
155
+ }
156
+ function asProjects(value) {
157
+ if (!Array.isArray(value)) return [];
158
+ const projects = [];
159
+ for (const item of value) {
160
+ if (!item || typeof item !== "object") continue;
161
+ const row = item;
162
+ if (typeof row.id !== "string" || typeof row.name !== "string") continue;
163
+ projects.push({
164
+ id: row.id,
165
+ key: typeof row.key === "string" ? row.key : "",
166
+ name: row.name,
167
+ role: typeof row.role === "string" ? row.role : "member",
168
+ clientName: typeof row.clientName === "string" ? row.clientName : void 0,
169
+ userName: typeof row.userName === "string" ? row.userName : void 0
170
+ });
171
+ }
172
+ return projects;
173
+ }
174
+ async function loadAccount(link) {
175
+ const response = await tesboFetch(link, "/api/atto/projects");
176
+ if (response.status === 401) {
177
+ clearLink();
178
+ return disconnected(await errorMessage(response));
179
+ }
180
+ if (!response.ok) throw new Error(await errorMessage(response));
181
+ const projects = asProjects(await response.json());
182
+ return {
183
+ connected: true,
184
+ baseUrl: link.baseUrl,
185
+ user: signedInUser(projects),
186
+ workspaces: [],
187
+ projects,
188
+ error: null
189
+ };
190
+ }
191
+ function signedInUser(projects) {
192
+ const project = projects.find((item) => item.userName || item.clientName);
193
+ if (!project) return null;
194
+ const name = [project.userName, project.clientName].filter(Boolean).join(" · ");
195
+ return { userId: project.userName || project.clientName || "", email: null, name: name || null };
196
+ }
197
+ async function tesboStatus() {
198
+ const link = readLink();
199
+ if (!link) return disconnected();
200
+ try {
201
+ return await loadAccount(link);
202
+ } catch (error) {
203
+ if (isTransientNetworkError(error)) return disconnected("Could not reach Tesbo.");
204
+ return disconnected(error instanceof Error ? error.message : "Could not reach Tesbo.");
205
+ }
206
+ }
207
+ async function tesboLogin(cmd) {
208
+ const code = cmd.code.trim();
209
+ if (!code) throw new Error("Paste the access code from Tesbo.");
210
+ const link = { baseUrl: DEFAULT_BASE_URL, code };
211
+ const connectOnce = () => fetch(`${link.baseUrl}/api/atto/connect`, {
212
+ method: "POST",
213
+ headers: { accept: "application/json", "content-type": "application/json" },
214
+ body: JSON.stringify({ code })
215
+ });
216
+ let response;
217
+ try {
218
+ response = await connectOnce();
219
+ } catch (error) {
220
+ if (!isTransientNetworkError(error)) throw error;
221
+ await new Promise((resolve2) => setTimeout(resolve2, 400));
222
+ response = await connectOnce();
223
+ }
224
+ if (!response.ok) throw new Error(await errorMessage(response));
225
+ writeLink(link);
226
+ const projects = asProjects(await response.json());
227
+ return {
228
+ connected: true,
229
+ baseUrl: link.baseUrl,
230
+ user: signedInUser(projects),
231
+ workspaces: [],
232
+ projects,
233
+ error: null
234
+ };
235
+ }
236
+ async function tesboLogout() {
237
+ clearLink();
238
+ return disconnected();
239
+ }
240
+ const SERVER_AGENTS = [
241
+ {
242
+ id: "zyra",
243
+ name: "Zyra the Test Generator",
244
+ role: "AI testcase generation agent",
245
+ summary: "Stays on Tesbo for the QAble team. This package does not open the website.",
246
+ status: "active",
247
+ detail: null
248
+ },
249
+ {
250
+ id: "nyra",
251
+ name: "NYRA",
252
+ role: "App exploration agent",
253
+ summary: "Stays on Tesbo for the QAble team. This package does not open the website.",
254
+ status: "active",
255
+ detail: null
256
+ }
257
+ ];
258
+ const COMING_SOON = [
259
+ {
260
+ id: "run-analyst",
261
+ name: "Run Analyst",
262
+ role: "Execution insight agent",
263
+ summary: "Planned for run failure clustering, flaky-test signals, and release risk notes.",
264
+ status: "coming-soon",
265
+ detail: null
266
+ },
267
+ {
268
+ id: "bug-triage",
269
+ name: "Bug Triage",
270
+ role: "Defect analysis agent",
271
+ summary: "Planned for duplicate bug checks, severity suggestions, and owner recommendations.",
272
+ status: "coming-soon",
273
+ detail: null
274
+ }
275
+ ];
276
+ async function tesboAgents(projectId) {
277
+ const link = readLink();
278
+ if (!link) throw new Error("Connect with an access code first.");
279
+ if (!projectId.trim()) throw new Error("Choose a project.");
280
+ const status = await loadAccount(link);
281
+ if (!status.connected) throw new Error(status.error || "This access code has been stopped.");
282
+ if (!status.projects.some((project) => project.id === projectId)) {
283
+ throw new Error("This project is not available for this access code.");
284
+ }
285
+ return { projectId, agents: [...SERVER_AGENTS, ...COMING_SOON], notice: null };
286
+ }
287
+ function safeTargetPath(savePath, fileName) {
288
+ const folder = node_path.resolve(node_path.normalize(savePath.trim()));
289
+ if (!node_path.isAbsolute(folder)) throw new Error("Save location from Tesbo must be an absolute path.");
290
+ const base = String(fileName || "script.spec.ts").replace(/[/\\]/g, "_").trim() || "script.spec.ts";
291
+ const target = node_path.resolve(folder, base);
292
+ const root = folder.endsWith(node_path.sep) ? folder : folder + node_path.sep;
293
+ if (target !== folder && !target.startsWith(root)) {
294
+ throw new Error("Refusing to write outside the configured save location.");
295
+ }
296
+ return target;
297
+ }
298
+ async function pullAndSavePendingScripts() {
299
+ const link = readLink();
300
+ if (!link) return { saved: 0, errors: [] };
301
+ const response = await tesboFetch(link, "/api/atto/scripts/pending");
302
+ if (response.status === 401) {
303
+ clearLink();
304
+ return { saved: 0, errors: ["Access code stopped."] };
305
+ }
306
+ if (!response.ok) throw new Error(await errorMessage(response));
307
+ const body = await response.json();
308
+ const scripts = Array.isArray(body.scripts) ? body.scripts : [];
309
+ let saved = 0;
310
+ const errors = [];
311
+ for (const item of scripts) {
312
+ if (!item?.id || !item.script || !item.savePath) continue;
313
+ try {
314
+ const target = safeTargetPath(item.savePath, item.fileName || `${item.externalId || "script"}.spec.ts`);
315
+ node_fs.mkdirSync(node_path.resolve(node_path.normalize(item.savePath.trim())), { recursive: true });
316
+ node_fs.writeFileSync(target, item.script, { encoding: "utf8" });
317
+ const ack = await tesboFetch(link, `/api/atto/scripts/${encodeURIComponent(item.id)}/ack`, { method: "POST", body: "{}" });
318
+ if (!ack.ok) throw new Error(await errorMessage(ack));
319
+ saved += 1;
320
+ } catch (error) {
321
+ errors.push(error instanceof Error ? error.message : "Could not save a script.");
322
+ }
323
+ }
324
+ return { saved, errors };
325
+ }
326
+ let scriptPollTimer = null;
327
+ const claimedSessionJobs = /* @__PURE__ */ new Set();
328
+ let remoteSessionSink = null;
329
+ function setRemoteSessionSink(sink) {
330
+ remoteSessionSink = sink;
331
+ }
332
+ async function ackAttoRemoteSession(id, status, error, desktopSessionId) {
333
+ const link = readLink();
334
+ if (!link || !id) return;
335
+ await tesboFetch(link, `/api/atto/sessions/${encodeURIComponent(id)}/ack`, {
336
+ method: "POST",
337
+ body: JSON.stringify({
338
+ status,
339
+ error: error || void 0,
340
+ desktopSessionId: desktopSessionId || void 0
341
+ })
342
+ });
343
+ }
344
+ const remoteJobByDesktopSession = /* @__PURE__ */ new Map();
345
+ const activeRemoteJobIds = /* @__PURE__ */ new Set();
346
+ let answerPollTimer = null;
347
+ let engineAdapterForAnswers = null;
348
+ function bindRemoteSessionJob(jobId, desktopSessionId) {
349
+ if (!jobId || !desktopSessionId) return;
350
+ remoteJobByDesktopSession.set(desktopSessionId, jobId);
351
+ activeRemoteJobIds.add(jobId);
352
+ void ackAttoRemoteSession(jobId, "running", void 0, desktopSessionId).catch(() => void 0);
353
+ }
354
+ function attachEngineForRemoteAnswers(adapter) {
355
+ engineAdapterForAnswers = adapter;
356
+ if (answerPollTimer) return;
357
+ answerPollTimer = setInterval(() => {
358
+ void pullRemoteSessionAnswers().catch(() => void 0);
359
+ }, 2500);
360
+ answerPollTimer.unref?.();
361
+ }
362
+ function mirrorEngineEventToChat(event) {
363
+ const jobId = remoteJobByDesktopSession.get(event.sessionId);
364
+ if (!jobId) return;
365
+ if (event.type !== "narration_step" && event.type !== "assertion_result" && event.type !== "stuck_question" && event.type !== "session_status_changed" && event.type !== "agent_log" && event.type !== "code_generated") {
366
+ return;
367
+ }
368
+ if (event.type === "narration_step" && event.status === "in_progress") return;
369
+ if (event.type === "narration_step" && Array.isArray(event.attachments)) {
370
+ const shot = event.attachments.find((item) => item.kind === "screenshot" && item.url);
371
+ if (shot?.url?.startsWith("taa-media://")) {
372
+ void uploadLiveFrame(jobId, event.sessionId, shot.url).catch(() => void 0);
373
+ }
374
+ }
375
+ const payload = event.type === "code_generated" ? {
376
+ type: "code_generated",
377
+ sessionId: event.sessionId,
378
+ filePath: event.filePath,
379
+ draftPath: event.draftPath,
380
+ content: event.content,
381
+ files: Array.isArray(event.files) ? event.files.slice(0, 40).map((file) => ({
382
+ path: file.path,
383
+ kind: file.kind,
384
+ change: file.change,
385
+ content: String(file.content || "").slice(0, 12e4)
386
+ })) : void 0
387
+ } : event;
388
+ void postRemoteSessionEvent(jobId, payload).catch(() => void 0);
389
+ if (event.type === "session_status_changed") {
390
+ const status = event.status;
391
+ if (status === "failed" || status === "stopped" || status === "awaiting_review" || status === "approved") {
392
+ void ackAttoRemoteSession(jobId, status === "failed" ? "failed" : "done").catch(() => void 0);
393
+ activeRemoteJobIds.delete(jobId);
394
+ }
395
+ }
396
+ }
397
+ async function postRemoteSessionEvent(jobId, event) {
398
+ const link = readLink();
399
+ if (!link) return;
400
+ await tesboFetch(link, `/api/atto/sessions/${encodeURIComponent(jobId)}/events`, {
401
+ method: "POST",
402
+ body: JSON.stringify(event)
403
+ });
404
+ }
405
+ async function pullRemoteSessionAnswers() {
406
+ const link = readLink();
407
+ const adapter = engineAdapterForAnswers;
408
+ if (!link || !adapter || activeRemoteJobIds.size === 0) return;
409
+ for (const jobId of [...activeRemoteJobIds]) {
410
+ try {
411
+ const response = await tesboFetch(link, `/api/atto/sessions/${encodeURIComponent(jobId)}/answers/pending`);
412
+ if (!response.ok) continue;
413
+ const body = await response.json();
414
+ const answers = Array.isArray(body.answers) ? body.answers : [];
415
+ for (const answer of answers) {
416
+ if (!answer?.questionId) continue;
417
+ const desktopSessionId = [...remoteJobByDesktopSession.entries()].find(([, id]) => id === jobId)?.[0];
418
+ if (!desktopSessionId) continue;
419
+ await adapter.answerStuckQuestion({
420
+ sessionId: desktopSessionId,
421
+ questionId: answer.questionId,
422
+ optionId: answer.optionId,
423
+ text: answer.text
424
+ });
425
+ await tesboFetch(
426
+ link,
427
+ `/api/atto/sessions/${encodeURIComponent(jobId)}/answers/${encodeURIComponent(answer.questionId)}/ack`,
428
+ { method: "POST", body: "{}" }
429
+ );
430
+ }
431
+ } catch {
432
+ }
433
+ }
434
+ }
435
+ async function pullAndDispatchPendingSessions() {
436
+ const link = readLink();
437
+ if (!link) return { started: 0, errors: [] };
438
+ const response = await tesboFetch(link, "/api/atto/sessions/pending");
439
+ if (response.status === 401) {
440
+ clearLink();
441
+ return { started: 0, errors: ["Access code stopped."] };
442
+ }
443
+ if (!response.ok) throw new Error(await errorMessage(response));
444
+ const body = await response.json();
445
+ const sessions = Array.isArray(body.sessions) ? body.sessions : [];
446
+ let started = 0;
447
+ const errors = [];
448
+ for (const item of sessions) {
449
+ if (!item?.id || !item.goal || !item.folderPath) continue;
450
+ if (claimedSessionJobs.has(item.id)) continue;
451
+ claimedSessionJobs.add(item.id);
452
+ try {
453
+ const job = {
454
+ id: String(item.id),
455
+ projectId: String(item.projectId || ""),
456
+ projectName: String(item.projectName || ""),
457
+ goal: String(item.goal || "").trim(),
458
+ targetUrl: String(item.targetUrl || "").trim(),
459
+ folderPath: String(item.folderPath || "").trim(),
460
+ browserMode: item.browserMode === "headless" ? "headless" : "headed",
461
+ createdAt: String(item.createdAt || ""),
462
+ chatSessionId: item.chatSessionId ? String(item.chatSessionId) : void 0
463
+ };
464
+ activeRemoteJobIds.add(job.id);
465
+ if (!remoteSessionSink) {
466
+ claimedSessionJobs.delete(item.id);
467
+ errors.push("Atto window is not ready to start a remote session yet.");
468
+ continue;
469
+ }
470
+ await ackAttoRemoteSession(job.id, "running");
471
+ remoteSessionSink(job);
472
+ started += 1;
473
+ } catch (error) {
474
+ claimedSessionJobs.delete(item.id);
475
+ errors.push(error instanceof Error ? error.message : "Could not start a remote session.");
476
+ }
477
+ }
478
+ if (claimedSessionJobs.size > 200) {
479
+ const keep = [...claimedSessionJobs].slice(-100);
480
+ claimedSessionJobs.clear();
481
+ for (const id of keep) claimedSessionJobs.add(id);
482
+ }
483
+ return { started, errors };
484
+ }
485
+ async function fetchAttoRemoteConfig() {
486
+ const link = readLink();
487
+ if (!link) return null;
488
+ const response = await tesboFetch(link, "/api/atto/remote-config");
489
+ if (response.status === 401) {
490
+ clearLink();
491
+ return null;
492
+ }
493
+ if (!response.ok) throw new Error(await errorMessage(response));
494
+ const body = await response.json();
495
+ return {
496
+ userName: String(body.userName || ""),
497
+ clientName: String(body.clientName || ""),
498
+ projectId: String(body.projectId || ""),
499
+ projectName: String(body.projectName || ""),
500
+ scriptSavePath: String(body.scriptSavePath || "").trim(),
501
+ browserMode: body.browserMode === "headless" ? "headless" : "headed",
502
+ targetUrl: String(body.targetUrl || "").trim(),
503
+ description: String(body.description || "").trim(),
504
+ memories: Array.isArray(body.memories) ? body.memories : [],
505
+ qualityGates: body.qualityGates && typeof body.qualityGates === "object" ? body.qualityGates : {},
506
+ install: {
507
+ package: String(body.install?.package || "npm install -g @qablehq/atto"),
508
+ chromium: String(body.install?.chromium || "npx playwright install chromium"),
509
+ note: String(body.install?.note || "")
510
+ }
511
+ };
512
+ }
513
+ async function uploadLiveFrame(jobId, desktopSessionId, mediaUrl) {
514
+ const link = readLink();
515
+ if (!link) return;
516
+ try {
517
+ const parsed = new URL(mediaUrl);
518
+ const filename = decodeURIComponent(parsed.pathname.replace(/^\/+/, ""));
519
+ const absolute = resolveSessionMediaFile(desktopSessionId, filename);
520
+ if (!absolute) return;
521
+ const buf = node_fs.readFileSync(absolute);
522
+ if (buf.length > 24e5) return;
523
+ const mime = filename.toLowerCase().endsWith(".png") ? "image/png" : "image/jpeg";
524
+ await tesboFetch(link, `/api/atto/sessions/${encodeURIComponent(jobId)}/live-frame`, {
525
+ method: "POST",
526
+ body: JSON.stringify({ imageBase64: buf.toString("base64"), mimeType: mime })
527
+ });
528
+ } catch {
529
+ }
530
+ }
531
+ const claimedDesktopCommands = /* @__PURE__ */ new Set();
532
+ async function pullAndHandleDesktopCommands() {
533
+ const link = readLink();
534
+ if (!link) return;
535
+ const response = await tesboFetch(link, "/api/atto/commands/pending");
536
+ if (response.status === 401) {
537
+ clearLink();
538
+ return;
539
+ }
540
+ if (!response.ok) return;
541
+ const body = await response.json();
542
+ const commands = Array.isArray(body.commands) ? body.commands : [];
543
+ for (const command of commands) {
544
+ if (!command?.id || command.type !== "pick_folder") continue;
545
+ if (claimedDesktopCommands.has(command.id)) continue;
546
+ claimedDesktopCommands.add(command.id);
547
+ try {
548
+ const win = electron.BrowserWindow.getFocusedWindow() ?? electron.BrowserWindow.getAllWindows()[0];
549
+ const result = win ? await electron.dialog.showOpenDialog(win, {
550
+ title: "Choose Atto project folder",
551
+ properties: ["openDirectory", "createDirectory"]
552
+ }) : await electron.dialog.showOpenDialog({
553
+ title: "Choose Atto project folder",
554
+ properties: ["openDirectory", "createDirectory"]
555
+ });
556
+ const canceled = result.canceled || result.filePaths.length === 0;
557
+ await tesboFetch(link, `/api/atto/commands/${encodeURIComponent(command.id)}/complete`, {
558
+ method: "POST",
559
+ body: JSON.stringify(canceled ? { canceled: true } : { path: result.filePaths[0] })
560
+ });
561
+ } catch {
562
+ claimedDesktopCommands.delete(command.id);
563
+ }
564
+ }
565
+ if (claimedDesktopCommands.size > 50) {
566
+ const keep = [...claimedDesktopCommands].slice(-25);
567
+ claimedDesktopCommands.clear();
568
+ for (const id of keep) claimedDesktopCommands.add(id);
569
+ }
570
+ }
571
+ function startAttoScriptPoller(intervalMs = 5e3) {
572
+ if (scriptPollTimer) return;
573
+ const tick = () => {
574
+ void pullAndSavePendingScripts().catch(() => void 0);
575
+ void pullAndDispatchPendingSessions().catch(() => void 0);
576
+ void pullAndHandleDesktopCommands().catch(() => void 0);
577
+ };
578
+ tick();
579
+ scriptPollTimer = setInterval(tick, intervalMs);
580
+ scriptPollTimer.unref?.();
581
+ }
62
582
  function registerIpcHandlers(adapter) {
63
583
  electron.ipcMain.handle(IPC_CHANNELS.submitGoal, (_e, cmd) => adapter.submitGoal(cmd));
64
584
  electron.ipcMain.handle(
@@ -88,6 +608,7 @@ function registerIpcHandlers(adapter) {
88
608
  for (const win of electron.BrowserWindow.getAllWindows()) {
89
609
  win.webContents.send(IPC_CHANNELS.engineEvent, event);
90
610
  }
611
+ mirrorEngineEventToChat(event);
91
612
  });
92
613
  }
93
614
  const DEFAULT_GATE_POLICY = {
@@ -3076,201 +3597,32 @@ function registerAppStateHandlers() {
3076
3597
  electron.ipcMain.handle(IPC_CHANNELS.getAppState, () => readAppState());
3077
3598
  electron.ipcMain.handle(IPC_CHANNELS.setAppState, (_e, value) => writeAppState(value));
3078
3599
  }
3079
- const DEFAULT_BASE_URL = "https://api-app-atto.tesbo.io";
3080
- const ACCESS_HEADER = "x-atto-access-code";
3081
- function sessionPath() {
3082
- return node_path.join(electron.app.getPath("userData"), "tesbo-link.json");
3083
- }
3084
- function readLink() {
3085
- try {
3086
- const parsed = JSON.parse(node_fs.readFileSync(sessionPath(), "utf8"));
3087
- if (typeof parsed.code !== "string" || !parsed.code.trim()) return null;
3088
- return { baseUrl: DEFAULT_BASE_URL, code: parsed.code.trim() };
3089
- } catch {
3090
- return null;
3091
- }
3092
- }
3093
- function writeLink(link) {
3094
- const path = sessionPath();
3095
- node_fs.mkdirSync(electron.app.getPath("userData"), { recursive: true });
3096
- node_fs.writeFileSync(path, JSON.stringify(link), { mode: 384 });
3097
- node_fs.chmodSync(path, 384);
3098
- }
3099
- function clearLink() {
3100
- node_fs.rmSync(sessionPath(), { force: true });
3101
- }
3102
- function disconnected(error = null) {
3103
- return { connected: false, baseUrl: DEFAULT_BASE_URL, user: null, workspaces: [], projects: [], error };
3104
- }
3105
- async function errorMessage(response) {
3106
- try {
3107
- const body = await response.json();
3108
- if (typeof body.error === "string" && body.error.trim()) return body.error;
3109
- if (typeof body.message === "string" && body.message.trim()) return body.message;
3110
- } catch {
3111
- }
3112
- return `Tesbo returned ${response.status}`;
3113
- }
3114
- async function tesboFetch(link, path, init) {
3115
- return fetch(`${link.baseUrl}${path}`, {
3116
- ...init,
3117
- headers: {
3118
- accept: "application/json",
3119
- [ACCESS_HEADER]: link.code,
3120
- ...{},
3121
- ...init?.headers
3122
- }
3123
- });
3124
- }
3125
- function asProjects(value) {
3126
- if (!Array.isArray(value)) return [];
3127
- const projects = [];
3128
- for (const item of value) {
3129
- if (!item || typeof item !== "object") continue;
3130
- const row = item;
3131
- if (typeof row.id !== "string" || typeof row.name !== "string") continue;
3132
- projects.push({
3133
- id: row.id,
3134
- key: typeof row.key === "string" ? row.key : "",
3135
- name: row.name,
3136
- role: typeof row.role === "string" ? row.role : "member",
3137
- clientName: typeof row.clientName === "string" ? row.clientName : void 0,
3138
- userName: typeof row.userName === "string" ? row.userName : void 0
3139
- });
3140
- }
3141
- return projects;
3142
- }
3143
- async function loadAccount(link) {
3144
- const response = await tesboFetch(link, "/api/atto/projects");
3145
- if (response.status === 401) {
3146
- clearLink();
3147
- return disconnected(await errorMessage(response));
3148
- }
3149
- if (!response.ok) throw new Error(await errorMessage(response));
3150
- const projects = asProjects(await response.json());
3151
- return {
3152
- connected: true,
3153
- baseUrl: link.baseUrl,
3154
- user: signedInUser(projects),
3155
- workspaces: [],
3156
- projects,
3157
- error: null
3158
- };
3159
- }
3160
- function signedInUser(projects) {
3161
- const project = projects.find((item) => item.userName || item.clientName);
3162
- if (!project) return null;
3163
- const name = [project.userName, project.clientName].filter(Boolean).join(" · ");
3164
- return { userId: project.userName || project.clientName || "", email: null, name: name || null };
3165
- }
3166
- async function tesboStatus() {
3167
- const link = readLink();
3168
- if (!link) return disconnected();
3169
- try {
3170
- return await loadAccount(link);
3171
- } catch (error) {
3172
- return disconnected(error instanceof Error ? error.message : "Could not reach Tesbo.");
3173
- }
3174
- }
3175
- async function tesboLogin(cmd) {
3176
- const code = cmd.code.trim();
3177
- if (!code) throw new Error("Paste the access code from Tesbo.");
3178
- const link = { baseUrl: DEFAULT_BASE_URL, code };
3179
- const response = await fetch(`${link.baseUrl}/api/atto/connect`, {
3180
- method: "POST",
3181
- headers: { accept: "application/json", "content-type": "application/json" },
3182
- body: JSON.stringify({ code })
3183
- });
3184
- if (!response.ok) throw new Error(await errorMessage(response));
3185
- writeLink(link);
3186
- const projects = asProjects(await response.json());
3187
- return {
3188
- connected: true,
3189
- baseUrl: link.baseUrl,
3190
- user: signedInUser(projects),
3191
- workspaces: [],
3192
- projects,
3193
- error: null
3194
- };
3195
- }
3196
- async function tesboLogout() {
3197
- clearLink();
3198
- return disconnected();
3199
- }
3200
- const SERVER_AGENTS = [
3201
- {
3202
- id: "zyra",
3203
- name: "Zyra the Test Generator",
3204
- role: "AI testcase generation agent",
3205
- summary: "Stays on Tesbo for the QAble team. This package does not open the website.",
3206
- status: "active",
3207
- detail: null
3208
- },
3209
- {
3210
- id: "nyra",
3211
- name: "NYRA",
3212
- role: "App exploration agent",
3213
- summary: "Stays on Tesbo for the QAble team. This package does not open the website.",
3214
- status: "active",
3215
- detail: null
3216
- }
3217
- ];
3218
- const COMING_SOON = [
3219
- {
3220
- id: "run-analyst",
3221
- name: "Run Analyst",
3222
- role: "Execution insight agent",
3223
- summary: "Planned for run failure clustering, flaky-test signals, and release risk notes.",
3224
- status: "coming-soon",
3225
- detail: null
3226
- },
3227
- {
3228
- id: "bug-triage",
3229
- name: "Bug Triage",
3230
- role: "Defect analysis agent",
3231
- summary: "Planned for duplicate bug checks, severity suggestions, and owner recommendations.",
3232
- status: "coming-soon",
3233
- detail: null
3234
- }
3235
- ];
3236
- async function tesboAgents(projectId) {
3237
- const link = readLink();
3238
- if (!link) throw new Error("Connect with an access code first.");
3239
- if (!projectId.trim()) throw new Error("Choose a project.");
3240
- const status = await loadAccount(link);
3241
- if (!status.connected) throw new Error(status.error || "This access code has been stopped.");
3242
- if (!status.projects.some((project) => project.id === projectId)) {
3243
- throw new Error("This project is not available for this access code.");
3244
- }
3245
- return { projectId, agents: [...SERVER_AGENTS, ...COMING_SOON], notice: null };
3246
- }
3247
- function registerTesboHandlers() {
3600
+ function registerTesboHandlers(adapter) {
3248
3601
  electron.ipcMain.handle(IPC_CHANNELS.tesboStatus, () => tesboStatus());
3249
3602
  electron.ipcMain.handle(IPC_CHANNELS.tesboLogin, (_event, cmd) => tesboLogin(cmd));
3250
3603
  electron.ipcMain.handle(IPC_CHANNELS.tesboLogout, () => tesboLogout());
3251
3604
  electron.ipcMain.handle(IPC_CHANNELS.tesboAgents, (_event, projectId) => tesboAgents(projectId));
3252
- }
3253
- const SCHEME = "taa-media";
3254
- const sessionRoots = /* @__PURE__ */ new Map();
3255
- const FIXTURES_ASSETS_DIR = node_path.join(electron.app.getAppPath(), "src/main/engine/mock/fixtures/assets");
3256
- function registerSessionMediaRoot(sessionId, absoluteDir) {
3257
- sessionRoots.set(sessionId, absoluteDir);
3258
- }
3259
- function registerMediaProtocolScheme() {
3260
- electron.protocol.registerSchemesAsPrivileged([
3261
- {
3262
- scheme: SCHEME,
3263
- privileges: { standard: true, secure: true, supportFetchAPI: true, corsEnabled: true, stream: true }
3605
+ electron.ipcMain.handle(IPC_CHANNELS.tesboRemoteConfig, () => fetchAttoRemoteConfig());
3606
+ electron.ipcMain.handle(
3607
+ IPC_CHANNELS.tesboAckRemoteSession,
3608
+ async (_event, cmd) => {
3609
+ await ackAttoRemoteSession(cmd.id, cmd.status, cmd.error, cmd.desktopSessionId);
3610
+ }
3611
+ );
3612
+ electron.ipcMain.handle(
3613
+ IPC_CHANNELS.tesboBindRemoteSession,
3614
+ async (_event, cmd) => {
3615
+ bindRemoteSessionJob(cmd.jobId, cmd.desktopSessionId);
3616
+ }
3617
+ );
3618
+ setRemoteSessionSink((job) => {
3619
+ for (const win of electron.BrowserWindow.getAllWindows()) {
3620
+ win.webContents.send(IPC_CHANNELS.tesboRemoteSession, job);
3264
3621
  }
3265
- ]);
3266
- }
3267
- function registerMediaProtocol() {
3268
- electron.protocol.handle(SCHEME, (request) => {
3269
- const url = new URL(request.url);
3270
- const filename = node_path.basename(decodeURIComponent(url.pathname.replace(/^\/+/, "")));
3271
- const root = sessionRoots.get(url.hostname) ?? FIXTURES_ASSETS_DIR;
3272
- return electron.net.fetch(node_url.pathToFileURL(node_path.join(root, filename)).toString());
3273
3622
  });
3623
+ if (adapter) attachEngineForRemoteAnswers(adapter);
3624
+ startAttoScriptPoller();
3625
+ void pullAndSavePendingScripts().catch(() => void 0);
3274
3626
  }
3275
3627
  const events = [{ "id": "evt-1", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:00.000Z", "seq": 1, "type": "session_created", "goal": "Verify that an already-registered email is rejected on sign-up", "targetUrl": "https://shop.example.test" }, { "id": "evt-2", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:01.000Z", "seq": 2, "type": "phase_changed", "phase": "exploration", "label": "Exploring the application" }, { "id": "evt-3", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:02.000Z", "seq": 3, "type": "narration_step", "stepId": "step-1", "action": "navigate", "narration": "Opening https://shop.example.test", "detail": { "toolCall": "navigate", "args": { "url": "https://shop.example.test" } }, "attachments": [{ "id": "att-1", "kind": "screenshot", "url": "taa-media://reject-duplicate-registration/01-landing.png", "caption": "Landing page" }], "status": "done" }, { "id": "evt-4", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:04.000Z", "seq": 4, "type": "narration_step", "stepId": "step-2", "action": "read_dom", "narration": "Looking at the page to find the sign-in and sign-up options", "detail": { "toolCall": "read_dom" }, "status": "done" }, { "id": "evt-5", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:06.000Z", "seq": 5, "type": "narration_step", "stepId": "step-3", "action": "click", "narration": "Clicking 'Log in' to check whether a registered test user already exists", "detail": { "selector": '[data-testid="nav-login"]', "toolCall": "click" }, "attachments": [{ "id": "att-2", "kind": "screenshot", "url": "taa-media://reject-duplicate-registration/02-login.png", "caption": "Login page" }], "status": "done" }, { "id": "evt-6", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:08.000Z", "seq": 6, "type": "narration_step", "stepId": "step-4", "action": "type", "narration": "Entering a candidate email: qa-tesbo-f3a1@test-domain.example", "detail": { "selector": '[data-testid="login-email"]', "toolCall": "type" }, "status": "done" }, { "id": "evt-7", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:09.000Z", "seq": 7, "type": "narration_step", "stepId": "step-5", "action": "click", "narration": "Submitting the login form", "detail": { "selector": '[data-testid="login-submit"]', "toolCall": "click" }, "status": "done" }, { "id": "evt-8", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:11.000Z", "seq": 8, "type": "narration_step", "stepId": "step-6", "action": "assert", "narration": "This email isn't registered yet — a test account needs to be created first", "status": "done" }, { "id": "evt-9", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:13.000Z", "seq": 9, "type": "narration_step", "stepId": "step-7", "action": "api_call", "narration": "Registering a test user directly via the sign-up API (POST /api/signup), so the precondition is satisfied without extra UI steps", "detail": { "toolCall": "api_call", "args": { "method": "POST", "path": "/api/signup" } }, "status": "done" }, { "id": "evt-10", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:15.000Z", "seq": 10, "type": "narration_step", "stepId": "step-8", "action": "navigate", "narration": "Going to the sign-up page", "detail": { "toolCall": "navigate", "args": { "url": "https://shop.example.test/signup" } }, "status": "done" }, { "id": "evt-11", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:17.000Z", "seq": 11, "type": "narration_step", "stepId": "step-9", "action": "type", "narration": "Entering the already-registered email: qa-tesbo-f3a1@test-domain.example", "detail": { "selector": '[data-testid="signup-email"]', "toolCall": "type" }, "status": "done" }, { "id": "evt-12", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:18.000Z", "seq": 12, "type": "narration_step", "stepId": "step-10", "action": "click", "narration": "Submitting the sign-up form with the duplicate email", "detail": { "selector": '[data-testid="signup-submit"]', "toolCall": "click" }, "attachments": [{ "id": "att-3", "kind": "screenshot", "url": "taa-media://reject-duplicate-registration/03-signup-rejected.png", "caption": "Duplicate sign-up rejected" }], "status": "done" }, { "id": "evt-13", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:20.000Z", "seq": 13, "type": "assertion_result", "stepId": "step-10", "passed": true, "narration": 'The sign-up was correctly rejected — "An account with this email already exists" was shown, and no duplicate account was created.', "expected": "Sign-up rejected with an existing-account error", "actual": '"An account with this email already exists"' }, { "id": "evt-14", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:21.000Z", "seq": 14, "type": "phase_changed", "phase": "script_generation", "label": "Generating the test script" }, { "id": "evt-15", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:23.000Z", "seq": 15, "type": "narration_step", "stepId": "step-11", "action": "write_file", "narration": 'Writing the Playwright test, reusing a shared "ensure a registered user exists" setup fixture other tests can reuse too', "detail": { "toolCall": "write_file" }, "status": "done" }, { "id": "evt-16", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:24.000Z", "seq": 16, "type": "code_generated", "filePath": "tests/auth/reject-duplicate-registration.spec.ts", "language": "typescript", "framework": "playwright", "content": 'import { test, expect } from "../fixtures/ensureUserExists";\n\ntest("rejects duplicate registration", async ({ page, registeredUser }) => {\n await page.goto("/signup");\n await page.getByTestId("signup-email").fill(registeredUser.email);\n await page.getByTestId("signup-password").fill(registeredUser.password);\n await page.getByTestId("signup-submit").click();\n\n await expect(page.getByRole("alert")).toHaveText(\n "An account with this email already exists",\n );\n await expect(page).toHaveURL(/\\/signup/);\n});\n' }, { "id": "evt-17", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:25.000Z", "seq": 17, "type": "phase_changed", "phase": "validation", "label": "Checking the script against your project's conventions" }, { "id": "evt-18", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:26.000Z", "seq": 18, "type": "narration_step", "stepId": "step-12", "action": "assert", "narration": "Checked locator strategy, file placement, and naming conventions — everything matches house style", "status": "done" }, { "id": "evt-19", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:27.000Z", "seq": 19, "type": "phase_changed", "phase": "execution", "label": "Running the script to confirm it's stable" }, { "id": "evt-20", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:28.000Z", "seq": 20, "type": "run_started", "runId": "run-auto-1", "runKind": "auto", "attempt": 1 }, { "id": "evt-21", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:30.000Z", "seq": 21, "type": "run_result", "runId": "run-auto-1", "runKind": "auto", "attempt": 1, "passed": true, "durationMs": 2140, "narration": "Run 1 of 3 passed" }, { "id": "evt-22", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:31.000Z", "seq": 22, "type": "run_started", "runId": "run-auto-2", "runKind": "auto", "attempt": 2 }, { "id": "evt-23", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:33.000Z", "seq": 23, "type": "run_result", "runId": "run-auto-2", "runKind": "auto", "attempt": 2, "passed": true, "durationMs": 1980, "narration": "Run 2 of 3 passed" }, { "id": "evt-24", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:34.000Z", "seq": 24, "type": "run_started", "runId": "run-auto-3", "runKind": "auto", "attempt": 3 }, { "id": "evt-25", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:36.000Z", "seq": 25, "type": "run_result", "runId": "run-auto-3", "runKind": "auto", "attempt": 3, "passed": true, "durationMs": 2050, "narration": "Run 3 of 3 passed" }, { "id": "evt-26", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:37.000Z", "seq": 26, "type": "phase_changed", "phase": "review", "label": "Ready for your review" }, { "id": "evt-27", "sessionId": "sess-reject-duplicate-registration", "timestamp": "2026-07-24T10:00:37.000Z", "seq": 27, "type": "session_status_changed", "status": "awaiting_review" }];
3276
3628
  const rejectDuplicateRegistrationFixture = {
@@ -12225,7 +12577,7 @@ electron.app.whenReady().then(() => {
12225
12577
  registerAiHandlers();
12226
12578
  registerProjectFilesHandlers();
12227
12579
  registerAppStateHandlers();
12228
- registerTesboHandlers();
12580
+ registerTesboHandlers(engine);
12229
12581
  createMainWindow();
12230
12582
  setupAutoUpdater();
12231
12583
  electron.app.on("activate", () => {