@qablehq/atto 0.0.33 → 0.0.34
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 +109 -2
- package/out/renderer/assets/index-DahmD4CZ.js +35093 -0
- package/out/renderer/index.html +1 -1
- package/package.json +1 -1
package/out/main/index.js
CHANGED
|
@@ -559,10 +559,35 @@ async function fetchAttoRemoteConfig() {
|
|
|
559
559
|
}
|
|
560
560
|
if (!response.ok) throw new Error(await errorMessage(response));
|
|
561
561
|
const body = await response.json();
|
|
562
|
+
const projectId = String(body.projectId || "");
|
|
563
|
+
let aiSynced = false;
|
|
564
|
+
let aiProvider = "";
|
|
565
|
+
let aiModel = "";
|
|
566
|
+
let aiName = "";
|
|
567
|
+
const remoteAi = body.ai;
|
|
568
|
+
if (projectId && remoteAi && String(remoteAi.apiKey || "").trim()) {
|
|
569
|
+
try {
|
|
570
|
+
const { applyTesboWebsiteAi: applyTesboWebsiteAi2 } = await Promise.resolve().then(() => ConnectionManager);
|
|
571
|
+
const applied = await applyTesboWebsiteAi2({
|
|
572
|
+
projectId: `tesbo-${projectId}`,
|
|
573
|
+
provider: String(remoteAi.provider || "openai"),
|
|
574
|
+
apiKey: String(remoteAi.apiKey || ""),
|
|
575
|
+
model: remoteAi.model,
|
|
576
|
+
baseUrl: remoteAi.baseUrl,
|
|
577
|
+
keyName: remoteAi.name
|
|
578
|
+
});
|
|
579
|
+
aiSynced = applied.synced;
|
|
580
|
+
aiProvider = applied.providerId;
|
|
581
|
+
aiModel = applied.model;
|
|
582
|
+
aiName = String(remoteAi.name || "");
|
|
583
|
+
} catch (error) {
|
|
584
|
+
console.error("[tesbo] could not apply website AI key", error);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
562
587
|
return {
|
|
563
588
|
userName: String(body.userName || ""),
|
|
564
589
|
clientName: String(body.clientName || ""),
|
|
565
|
-
projectId
|
|
590
|
+
projectId,
|
|
566
591
|
projectName: String(body.projectName || ""),
|
|
567
592
|
scriptSavePath: String(body.scriptSavePath || "").trim(),
|
|
568
593
|
browserMode: body.browserMode === "headless" ? "headless" : "headed",
|
|
@@ -574,7 +599,11 @@ async function fetchAttoRemoteConfig() {
|
|
|
574
599
|
package: String(body.install?.package || "npm install -g @qablehq/atto"),
|
|
575
600
|
chromium: String(body.install?.chromium || "npx playwright install chromium"),
|
|
576
601
|
note: String(body.install?.note || "")
|
|
577
|
-
}
|
|
602
|
+
},
|
|
603
|
+
aiSynced,
|
|
604
|
+
aiProvider: aiProvider || void 0,
|
|
605
|
+
aiModel: aiModel || void 0,
|
|
606
|
+
aiName: aiName || void 0
|
|
578
607
|
};
|
|
579
608
|
}
|
|
580
609
|
async function readLiveFramePayload(desktopSessionId, mediaUrl) {
|
|
@@ -1944,6 +1973,54 @@ function labelFor(providerId, accountHint) {
|
|
|
1944
1973
|
const base = getProviderOption(providerId).label;
|
|
1945
1974
|
return accountHint ? `${base} — ${accountHint}` : base;
|
|
1946
1975
|
}
|
|
1976
|
+
async function applyTesboWebsiteAi(input) {
|
|
1977
|
+
const projectId = String(input.projectId || "").trim();
|
|
1978
|
+
const apiKey = String(input.apiKey || "").trim();
|
|
1979
|
+
if (!projectId || !apiKey) return { synced: false, providerId: "openai", model: "" };
|
|
1980
|
+
const providerId = mapWebsiteProvider(input.provider);
|
|
1981
|
+
const provider = getProviderOption(providerId);
|
|
1982
|
+
const model = String(input.model || "").trim() || provider.defaultModel;
|
|
1983
|
+
const connectionId = `tesbo-web-${projectId}`;
|
|
1984
|
+
const accountHint = `···${apiKey.slice(-4)}`;
|
|
1985
|
+
const existing = await getStoredConnection(connectionId);
|
|
1986
|
+
let sameKey = false;
|
|
1987
|
+
if (existing?.secret) {
|
|
1988
|
+
try {
|
|
1989
|
+
sameKey = await readApiKey(existing) === apiKey;
|
|
1990
|
+
} catch {
|
|
1991
|
+
sameKey = false;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
if (!existing || !sameKey || existing.providerId !== providerId || existing.model !== model) {
|
|
1995
|
+
await saveConnection({
|
|
1996
|
+
id: connectionId,
|
|
1997
|
+
providerId,
|
|
1998
|
+
authKind: "api_key",
|
|
1999
|
+
label: input.keyName?.trim() ? `Tesbo — ${input.keyName.trim()}` : labelFor(providerId, accountHint),
|
|
2000
|
+
accountHint,
|
|
2001
|
+
model,
|
|
2002
|
+
baseUrl: input.baseUrl?.trim() || provider.defaultBaseUrl,
|
|
2003
|
+
plainSecret: apiKey,
|
|
2004
|
+
health: existing?.health ?? { state: "unchecked" },
|
|
2005
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
await setBinding(projectId, { default: { connectionId, model } });
|
|
2009
|
+
return { synced: true, providerId, model };
|
|
2010
|
+
}
|
|
2011
|
+
function mapWebsiteProvider(raw) {
|
|
2012
|
+
const p = String(raw || "").toLowerCase().trim();
|
|
2013
|
+
if (p.includes("anthropic") || p.includes("claude")) return "anthropic";
|
|
2014
|
+
if (p.includes("openai") || p === "chatgpt") return "openai";
|
|
2015
|
+
if (p.includes("grok") || p.includes("xai")) return "grok";
|
|
2016
|
+
if (p.includes("gemini") || p.includes("google")) return "gemini";
|
|
2017
|
+
if (p.includes("mistral")) return "mistral";
|
|
2018
|
+
if (p.includes("groq")) return "groq";
|
|
2019
|
+
if (p.includes("openrouter")) return "openrouter";
|
|
2020
|
+
if (p.includes("ollama")) return "ollama";
|
|
2021
|
+
if (p.includes("lmstudio") || p.includes("lm studio")) return "lmstudio";
|
|
2022
|
+
return "openai";
|
|
2023
|
+
}
|
|
1947
2024
|
async function createApiKeyConnection(input) {
|
|
1948
2025
|
const provider = getProviderOption(input.providerId);
|
|
1949
2026
|
const apiKey = input.apiKey.trim();
|
|
@@ -2063,6 +2140,36 @@ async function getClient(projectId, role, opts = {}) {
|
|
|
2063
2140
|
return withRetry(await meter(target, fallbackModel));
|
|
2064
2141
|
});
|
|
2065
2142
|
}
|
|
2143
|
+
async function getClientForConnection(connectionId, model) {
|
|
2144
|
+
const connection = await getStoredConnection(connectionId);
|
|
2145
|
+
if (!connection) throw new LlmError("That AI connection no longer exists.");
|
|
2146
|
+
return buildClient(
|
|
2147
|
+
connection,
|
|
2148
|
+
model || connection.model || getProviderOption(connection.providerId).defaultModel
|
|
2149
|
+
);
|
|
2150
|
+
}
|
|
2151
|
+
async function projectHasUsableConnection(projectId) {
|
|
2152
|
+
try {
|
|
2153
|
+
await resolveForRole(projectId, "agent");
|
|
2154
|
+
return true;
|
|
2155
|
+
} catch {
|
|
2156
|
+
return false;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
const ConnectionManager = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2160
|
+
__proto__: null,
|
|
2161
|
+
applyTesboWebsiteAi,
|
|
2162
|
+
createApiKeyConnection,
|
|
2163
|
+
deleteConnection,
|
|
2164
|
+
getClient,
|
|
2165
|
+
getClientForConnection,
|
|
2166
|
+
getProjectSetup,
|
|
2167
|
+
listConnections,
|
|
2168
|
+
projectHasUsableConnection,
|
|
2169
|
+
saveOAuthConnection,
|
|
2170
|
+
setProjectBinding,
|
|
2171
|
+
verifyConnection
|
|
2172
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
2066
2173
|
function tesboDir(projectFolder) {
|
|
2067
2174
|
return node_path.join(projectFolder, ".tesbo");
|
|
2068
2175
|
}
|