dsh-agy 0.2.2 → 0.2.4
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/README.md +41 -4
- package/lib/{session-KoIh3xdB.mjs → accounts-DbTTxX_z.mjs} +1125 -546
- package/lib/accounts-DbTTxX_z.mjs.map +1 -0
- package/lib/{models-1rf_Wfo2.mjs → catalog-iuikPZIb.mjs} +29 -81
- package/lib/catalog-iuikPZIb.mjs.map +1 -0
- package/lib/cli/index.d.mts.map +1 -1
- package/lib/cli/index.mjs +149 -12
- package/lib/cli/index.mjs.map +1 -1
- package/lib/{exchange-DBRzR2M-.mjs → exchange-BvrLu2E4.mjs} +8 -5
- package/lib/exchange-BvrLu2E4.mjs.map +1 -0
- package/lib/{import-C4CRBTbi.mjs → import-DSvpbB0T.mjs} +30 -8
- package/lib/import-DSvpbB0T.mjs.map +1 -0
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +6 -1
- package/lib/index.mjs.map +1 -1
- package/lib/models-DRWVi33p.mjs +136 -0
- package/lib/models-DRWVi33p.mjs.map +1 -0
- package/lib/{plugin-common-CQoDUeqE.mjs → plugin-common-D7lc-W6b.mjs} +79 -11
- package/lib/plugin-common-D7lc-W6b.mjs.map +1 -0
- package/lib/proxy-DQPIwUov.mjs +269 -0
- package/lib/proxy-DQPIwUov.mjs.map +1 -0
- package/lib/{translate-BQuSQW35.mjs → translate-COjBTH4-.mjs} +27 -6
- package/lib/translate-COjBTH4-.mjs.map +1 -0
- package/lib/web/plugin.d.mts.map +1 -1
- package/lib/web/plugin.mjs +202 -8
- package/lib/web/plugin.mjs.map +1 -1
- package/package.json +4 -1
- package/lib/exchange-DBRzR2M-.mjs.map +0 -1
- package/lib/import-C4CRBTbi.mjs.map +0 -1
- package/lib/models-1rf_Wfo2.mjs.map +0 -1
- package/lib/plugin-common-CQoDUeqE.mjs.map +0 -1
- package/lib/session-KoIh3xdB.mjs.map +0 -1
- package/lib/translate-BQuSQW35.mjs.map +0 -1
package/lib/web/plugin.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
1
|
+
import { d as isAgyDisabled, f as generateFingerprint, g as resolveAntigravityVersionBounded, n as maskProxyUrl, p as recordFingerprintVersion } from "../accounts-DbTTxX_z.mjs";
|
|
2
|
+
import { a as proxyUrlForLogs, r as normalizeProxyUrl, t as isProxyReachable } from "../proxy-DQPIwUov.mjs";
|
|
3
|
+
import { t as createAgyRuntime } from "../plugin-common-D7lc-W6b.mjs";
|
|
4
|
+
import { t as exchangeAntigravity } from "../exchange-BvrLu2E4.mjs";
|
|
5
|
+
import { n as upsertImportedAccount, r as authorizeAntigravity, t as importManySources } from "../import-DSvpbB0T.mjs";
|
|
5
6
|
//#region src/web/i18n.ts
|
|
6
7
|
const I18N_DICT = {
|
|
7
8
|
en: {
|
|
@@ -895,6 +896,15 @@ function renderDashboardHtml() {
|
|
|
895
896
|
'<button class="btn btn-secondary btn-sm" id="btn-action-fp">' + esc(t('fingerprint')) + '</button>' +
|
|
896
897
|
'<button class="btn btn-danger btn-sm" id="btn-action-delete">' + esc(t('deleteAccount')) + '</button>' +
|
|
897
898
|
'</div>' +
|
|
899
|
+
'</div>' +
|
|
900
|
+
|
|
901
|
+
'<div style="margin-top:14px;padding:10px 12px;border:1px solid var(--border-l1);border-radius:8px;background:var(--bg-surface-elevated);display:flex;flex-wrap:wrap;gap:8px;align-items:center;">' +
|
|
902
|
+
'<span style="font-size:13px;font-weight:500;white-space:nowrap;">Proxy:</span>' +
|
|
903
|
+
'<input id="proxy-input-' + selectedIndex + '" placeholder="socks5://user:pass@host:1080" style="flex:1;min-width:220px;font-family:var(--ds-font-family-code);font-size:12.5px;padding:6px 10px;background:var(--bg-input);border:1px solid var(--border-l2);border-radius:6px;color:var(--text-primary);outline:none;">' +
|
|
904
|
+
'<button class="btn btn-primary btn-sm" id="btn-proxy-save">Save</button>' +
|
|
905
|
+
'<button class="btn btn-secondary btn-sm" id="btn-proxy-clear">Clear</button>' +
|
|
906
|
+
'<button class="btn btn-secondary btn-sm" id="btn-proxy-test">Test</button>' +
|
|
907
|
+
'<span id="proxy-status" style="font-size:12px;color:var(--text-secondary);">' + ((a.proxy || a.proxyMasked) ? 'Current: ' + esc(a.proxy || a.proxyMasked) : 'No proxy (using env)') + '</span>' +
|
|
898
908
|
'</div>' +
|
|
899
909
|
|
|
900
910
|
'<div style="margin-top:16px;">' +
|
|
@@ -1026,6 +1036,58 @@ function renderDashboardHtml() {
|
|
|
1026
1036
|
btnTestAll.disabled = false;
|
|
1027
1037
|
};
|
|
1028
1038
|
|
|
1039
|
+
// Proxy actions
|
|
1040
|
+
const btnProxySave = $('btn-proxy-save');
|
|
1041
|
+
if (btnProxySave) btnProxySave.onclick = async () => {
|
|
1042
|
+
const input = $('proxy-input-' + index);
|
|
1043
|
+
const proxy = input ? input.value.trim() : '';
|
|
1044
|
+
btnProxySave.disabled = true;
|
|
1045
|
+
try {
|
|
1046
|
+
const r = await api('/proxy', { method: 'POST', body: JSON.stringify({ index, proxy }) });
|
|
1047
|
+
const masked = r.proxy || r.proxyMasked || '';
|
|
1048
|
+
const statusEl = $('proxy-status');
|
|
1049
|
+
if (statusEl) statusEl.textContent = masked ? 'Current: ' + masked : 'No proxy (using env)';
|
|
1050
|
+
toast(masked ? 'Proxy saved: ' + masked : 'Proxy cleared (using env)', 'success');
|
|
1051
|
+
render();
|
|
1052
|
+
} catch (e) { toast(String(e), 'error'); }
|
|
1053
|
+
finally { btnProxySave.disabled = false; }
|
|
1054
|
+
};
|
|
1055
|
+
const btnProxyClear = $('btn-proxy-clear');
|
|
1056
|
+
if (btnProxyClear) btnProxyClear.onclick = async () => {
|
|
1057
|
+
btnProxyClear.disabled = true;
|
|
1058
|
+
try {
|
|
1059
|
+
await api('/proxy', { method: 'POST', body: JSON.stringify({ index, proxy: '' }) });
|
|
1060
|
+
const statusEl = $('proxy-status');
|
|
1061
|
+
if (statusEl) statusEl.textContent = 'No proxy (using env)';
|
|
1062
|
+
const input = $('proxy-input-' + index);
|
|
1063
|
+
if (input) input.value = '';
|
|
1064
|
+
toast('Proxy cleared (using env)', 'success');
|
|
1065
|
+
render();
|
|
1066
|
+
} catch (e) { toast(String(e), 'error'); }
|
|
1067
|
+
finally { btnProxyClear.disabled = false; }
|
|
1068
|
+
};
|
|
1069
|
+
const btnProxyTest = $('btn-proxy-test');
|
|
1070
|
+
if (btnProxyTest) btnProxyTest.onclick = async () => {
|
|
1071
|
+
const input = $('proxy-input-' + index);
|
|
1072
|
+
const val = input ? input.value.trim() : '';
|
|
1073
|
+
const body = val ? { index, proxy: val } : { index };
|
|
1074
|
+
btnProxyTest.disabled = true;
|
|
1075
|
+
btnProxyTest.textContent = '...';
|
|
1076
|
+
try {
|
|
1077
|
+
const r = await api('/proxy/test', { method: 'POST', body: JSON.stringify(body) });
|
|
1078
|
+
const masked = r.masked ? esc(r.masked) : '';
|
|
1079
|
+
const statusEl = $('proxy-status');
|
|
1080
|
+
if (r.ok) {
|
|
1081
|
+
toast('Proxy reachable: ' + (r.masked || ''), 'success');
|
|
1082
|
+
if (statusEl) statusEl.textContent = 'Reachable: ' + (r.masked || '');
|
|
1083
|
+
} else {
|
|
1084
|
+
toast('Proxy unreachable: ' + (r.masked || '') + (r.error ? ' - ' + r.error : ''), 'error');
|
|
1085
|
+
if (statusEl) statusEl.textContent = 'Unreachable: ' + (r.masked || '') + (r.error ? ' (' + r.error + ')' : '');
|
|
1086
|
+
}
|
|
1087
|
+
} catch (e) { toast(String(e), 'error'); }
|
|
1088
|
+
finally { btnProxyTest.disabled = false; btnProxyTest.textContent = 'Test'; }
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1029
1091
|
// Single model tests
|
|
1030
1092
|
document.querySelectorAll('[data-test-model]').forEach((btn) => {
|
|
1031
1093
|
btn.onclick = async () => {
|
|
@@ -1310,7 +1372,9 @@ function createAgyWebRoutes(options) {
|
|
|
1310
1372
|
createdAt: account.fingerprint.createdAt
|
|
1311
1373
|
} : null,
|
|
1312
1374
|
fingerprintHistory: (account.fingerprintHistory ?? []).length,
|
|
1313
|
-
quota: null
|
|
1375
|
+
quota: null,
|
|
1376
|
+
proxy: account.proxy ? maskProxyUrl(account.proxy) : null,
|
|
1377
|
+
proxyMasked: account.proxy ? maskProxyUrl(account.proxy) : null
|
|
1314
1378
|
};
|
|
1315
1379
|
list.push(entry);
|
|
1316
1380
|
}
|
|
@@ -1318,7 +1382,7 @@ function createAgyWebRoutes(options) {
|
|
|
1318
1382
|
const session = await sessions.getSession().catch(() => void 0);
|
|
1319
1383
|
if (!session || session.index !== entry.index) continue;
|
|
1320
1384
|
try {
|
|
1321
|
-
const { fetchAvailableModels } = await import("../models-
|
|
1385
|
+
const { fetchAvailableModels } = await import("../models-DRWVi33p.mjs").then((n) => n.r);
|
|
1322
1386
|
const discovered = await fetchAvailableModels(session.auth.access, session.account.projectId);
|
|
1323
1387
|
const models = Object.entries(discovered.models ?? {});
|
|
1324
1388
|
if (models.length > 0) {
|
|
@@ -1388,7 +1452,8 @@ function createAgyWebRoutes(options) {
|
|
|
1388
1452
|
expiresAt: new Date(result.expires).toISOString(),
|
|
1389
1453
|
authMethod: "oauth",
|
|
1390
1454
|
email: result.email ?? null,
|
|
1391
|
-
projectId: result.projectId || null
|
|
1455
|
+
projectId: result.projectId || null,
|
|
1456
|
+
clientId: result.clientId || null
|
|
1392
1457
|
}, { overwriteExisting: true });
|
|
1393
1458
|
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
1394
1459
|
res.end(renderCallbackHtml({
|
|
@@ -1437,6 +1502,15 @@ function createAgyWebRoutes(options) {
|
|
|
1437
1502
|
sendJson(res, 400, { error: error instanceof Error ? error.message : String(error) });
|
|
1438
1503
|
}
|
|
1439
1504
|
};
|
|
1505
|
+
const handleHealth = async (req, res) => {
|
|
1506
|
+
try {
|
|
1507
|
+
const body = await readJson(req);
|
|
1508
|
+
const indices = Array.isArray(body.indices) ? body.indices.map((value) => Number(value)) : void 0;
|
|
1509
|
+
sendJson(res, 200, { results: await sessions.checkAccounts(indices) });
|
|
1510
|
+
} catch (error) {
|
|
1511
|
+
sendJson(res, 400, { error: error instanceof Error ? error.message : String(error) });
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1440
1514
|
const handleDelete = async (req, res) => {
|
|
1441
1515
|
try {
|
|
1442
1516
|
const body = await readJson(req);
|
|
@@ -1474,7 +1548,7 @@ function createAgyWebRoutes(options) {
|
|
|
1474
1548
|
return;
|
|
1475
1549
|
}
|
|
1476
1550
|
try {
|
|
1477
|
-
const { listAgyModels } = await import("../models-
|
|
1551
|
+
const { listAgyModels } = await import("../models-DRWVi33p.mjs").then((n) => n.r);
|
|
1478
1552
|
const models = await listAgyModels(session.auth.access, session.account.projectId);
|
|
1479
1553
|
sendJson(res, 200, {
|
|
1480
1554
|
account: session.account.email ?? null,
|
|
@@ -1542,6 +1616,107 @@ function createAgyWebRoutes(options) {
|
|
|
1542
1616
|
sendJson(res, 400, { error: error instanceof Error ? error.message : String(error) });
|
|
1543
1617
|
}
|
|
1544
1618
|
};
|
|
1619
|
+
const handleProxy = async (req, res) => {
|
|
1620
|
+
try {
|
|
1621
|
+
const body = await readJson(req);
|
|
1622
|
+
const rawIdx = Number(body.index);
|
|
1623
|
+
if (!Number.isInteger(rawIdx) || !Number.isFinite(rawIdx) || rawIdx < 0) {
|
|
1624
|
+
sendJson(res, 400, { error: "invalid index" });
|
|
1625
|
+
return;
|
|
1626
|
+
}
|
|
1627
|
+
const index = rawIdx;
|
|
1628
|
+
const raw = typeof body.proxy === "string" ? body.proxy : "";
|
|
1629
|
+
if (!raw.trim()) {
|
|
1630
|
+
await store.mutate((storage) => {
|
|
1631
|
+
const account = storage.accounts[index];
|
|
1632
|
+
if (!account) throw new Error("account not found");
|
|
1633
|
+
delete account.proxy;
|
|
1634
|
+
});
|
|
1635
|
+
sendJson(res, 200, {
|
|
1636
|
+
ok: true,
|
|
1637
|
+
proxy: null,
|
|
1638
|
+
proxyMasked: null,
|
|
1639
|
+
rawLogs: null
|
|
1640
|
+
});
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
let normalized;
|
|
1644
|
+
try {
|
|
1645
|
+
normalized = normalizeProxyUrl(raw);
|
|
1646
|
+
} catch (e) {
|
|
1647
|
+
sendJson(res, 400, { error: e instanceof Error ? e.message : String(e) });
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
await store.mutate((storage) => {
|
|
1651
|
+
const account = storage.accounts[index];
|
|
1652
|
+
if (!account) throw new Error("account not found");
|
|
1653
|
+
account.proxy = normalized;
|
|
1654
|
+
});
|
|
1655
|
+
sendJson(res, 200, {
|
|
1656
|
+
ok: true,
|
|
1657
|
+
proxy: maskProxyUrl(normalized),
|
|
1658
|
+
proxyMasked: maskProxyUrl(normalized),
|
|
1659
|
+
rawLogs: proxyUrlForLogs(normalized)
|
|
1660
|
+
});
|
|
1661
|
+
} catch (error) {
|
|
1662
|
+
sendJson(res, 400, { error: error instanceof Error ? error.message : String(error) });
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
const handleProxyTest = async (req, res) => {
|
|
1666
|
+
try {
|
|
1667
|
+
const body = await readJson(req);
|
|
1668
|
+
const rawIdx2 = body.index !== void 0 ? Number(body.index) : NaN;
|
|
1669
|
+
const hasExplicitProxy = typeof body.proxy === "string" && body.proxy.trim() !== "";
|
|
1670
|
+
if (!hasExplicitProxy) {
|
|
1671
|
+
if (!Number.isInteger(rawIdx2) || !Number.isFinite(rawIdx2) || rawIdx2 < 0) {
|
|
1672
|
+
sendJson(res, 400, { error: "invalid index" });
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
} else if (body.index !== void 0) {
|
|
1676
|
+
if (!Number.isInteger(rawIdx2) || !Number.isFinite(rawIdx2) || rawIdx2 < 0) {
|
|
1677
|
+
sendJson(res, 400, { error: "invalid index" });
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
const index = hasExplicitProxy && body.index === void 0 ? -1 : rawIdx2;
|
|
1682
|
+
let target;
|
|
1683
|
+
if (hasExplicitProxy) try {
|
|
1684
|
+
target = normalizeProxyUrl(body.proxy);
|
|
1685
|
+
} catch (e) {
|
|
1686
|
+
sendJson(res, 400, { error: e instanceof Error ? e.message : String(e) });
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
else {
|
|
1690
|
+
const account = (await store.load()).accounts[index];
|
|
1691
|
+
if (!account) {
|
|
1692
|
+
sendJson(res, 400, { error: "account not found" });
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
if (!account.proxy) {
|
|
1696
|
+
sendJson(res, 400, { error: "no proxy configured for this account" });
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
target = account.proxy;
|
|
1700
|
+
}
|
|
1701
|
+
const masked = maskProxyUrl(target) ?? proxyUrlForLogs(target);
|
|
1702
|
+
let ok = false;
|
|
1703
|
+
let errMsg;
|
|
1704
|
+
try {
|
|
1705
|
+
ok = await isProxyReachable(target, 2e3);
|
|
1706
|
+
if (!ok) errMsg = "proxy unreachable: " + masked;
|
|
1707
|
+
} catch (e) {
|
|
1708
|
+
ok = false;
|
|
1709
|
+
errMsg = e instanceof Error ? e.message : String(e);
|
|
1710
|
+
}
|
|
1711
|
+
sendJson(res, 200, {
|
|
1712
|
+
ok,
|
|
1713
|
+
masked,
|
|
1714
|
+
...errMsg ? { error: errMsg } : {}
|
|
1715
|
+
});
|
|
1716
|
+
} catch (error) {
|
|
1717
|
+
sendJson(res, 400, { error: error instanceof Error ? error.message : String(error) });
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1545
1720
|
return [
|
|
1546
1721
|
{
|
|
1547
1722
|
kind: "exact",
|
|
@@ -1590,6 +1765,11 @@ function createAgyWebRoutes(options) {
|
|
|
1590
1765
|
path: "/agy/api/verify",
|
|
1591
1766
|
handler: handleVerify
|
|
1592
1767
|
},
|
|
1768
|
+
{
|
|
1769
|
+
kind: "exact",
|
|
1770
|
+
path: "/agy/api/health",
|
|
1771
|
+
handler: handleHealth
|
|
1772
|
+
},
|
|
1593
1773
|
{
|
|
1594
1774
|
kind: "exact",
|
|
1595
1775
|
path: "/agy/api/delete",
|
|
@@ -1619,6 +1799,16 @@ function createAgyWebRoutes(options) {
|
|
|
1619
1799
|
kind: "exact",
|
|
1620
1800
|
path: "/agy/api/fingerprint",
|
|
1621
1801
|
handler: handleFingerprint
|
|
1802
|
+
},
|
|
1803
|
+
{
|
|
1804
|
+
kind: "exact",
|
|
1805
|
+
path: "/agy/api/proxy",
|
|
1806
|
+
handler: handleProxy
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
kind: "exact",
|
|
1810
|
+
path: "/agy/api/proxy/test",
|
|
1811
|
+
handler: handleProxyTest
|
|
1622
1812
|
}
|
|
1623
1813
|
];
|
|
1624
1814
|
}
|
|
@@ -1627,6 +1817,10 @@ function createAgyWebRoutes(options) {
|
|
|
1627
1817
|
const name = "dsh-agy-web";
|
|
1628
1818
|
const inject = ["llm", "webServer"];
|
|
1629
1819
|
function apply(ctx) {
|
|
1820
|
+
if (isAgyDisabled()) {
|
|
1821
|
+
ctx.logger.warn("[dsh-agy] disabled by DSH_AGY_DISABLE=1 — skipping /agy registration");
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1630
1824
|
ctx.effect(async () => {
|
|
1631
1825
|
const webServer = ctx.get("webServer");
|
|
1632
1826
|
if (!webServer) return () => {};
|