@certalis/agent-smith 0.1.8 → 0.1.10
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 +20 -10
- package/dist/bin.js +158 -144
- package/dist/dashboard/{chunk-h03pp3xg.js → chunk-rnbsj0t8.js} +6 -6
- package/dist/dashboard/{chunk-h03pp3xg.js.map → chunk-rnbsj0t8.js.map} +58 -58
- package/dist/dashboard/index.html +3 -3
- package/dist/dashboard/manifest.json +2 -2
- package/dist/edge.js +9 -2
- package/dist/https.js +420 -0
- package/dist/pool.js +12445 -0
- package/dist/post-processor.worker.js +34 -31
- package/dist/server.js +50 -43
- package/package.json +10 -10
package/dist/bin.js
CHANGED
|
@@ -335,13 +335,13 @@ class PriceCatalogue {
|
|
|
335
335
|
return PriceCatalogue.instance;
|
|
336
336
|
}
|
|
337
337
|
getCacheDir() {
|
|
338
|
-
return join2(tmpdir(), "
|
|
338
|
+
return join2(tmpdir(), "agent-smith");
|
|
339
339
|
}
|
|
340
340
|
getCachePath() {
|
|
341
341
|
return join2(this.getCacheDir(), "models.dev.json");
|
|
342
342
|
}
|
|
343
343
|
getCacheDurationMs() {
|
|
344
|
-
const hours = Number(process.env.
|
|
344
|
+
const hours = Number(process.env.AGENT_SMITH_PRICING_REFRESH_HOURS) || 24;
|
|
345
345
|
return hours * TIME_CONSTANTS.HOUR;
|
|
346
346
|
}
|
|
347
347
|
async ensureCacheDir() {
|
|
@@ -1035,7 +1035,7 @@ class LogFileWriter {
|
|
|
1035
1035
|
stream = null;
|
|
1036
1036
|
maxFileSize = BUFFER_SIZES.LOG_FILE_MAX_SIZE;
|
|
1037
1037
|
constructor() {
|
|
1038
|
-
this.logDir = join3(tmpdir2(), "
|
|
1038
|
+
this.logDir = join3(tmpdir2(), "agent-smith-logs");
|
|
1039
1039
|
if (!existsSync(this.logDir)) {
|
|
1040
1040
|
mkdirSync(this.logDir, { recursive: true });
|
|
1041
1041
|
}
|
|
@@ -1121,11 +1121,11 @@ class Logger {
|
|
|
1121
1121
|
constructor(prefix = "", level = 1 /* INFO */, options = {}) {
|
|
1122
1122
|
this.prefix = prefix;
|
|
1123
1123
|
this.level = this.getLogLevelFromEnv() || level;
|
|
1124
|
-
this.format = process.env.
|
|
1125
|
-
this.silentConsole = options.silentConsole ?? !(process.env.
|
|
1124
|
+
this.format = process.env.AGENT_SMITH_LOG_FORMAT || "pretty";
|
|
1125
|
+
this.silentConsole = options.silentConsole ?? !(process.env.AGENT_SMITH_DEBUG === "1" || this.level === 0 /* DEBUG */);
|
|
1126
1126
|
}
|
|
1127
1127
|
getLogLevelFromEnv() {
|
|
1128
|
-
const envLevel = process.env.
|
|
1128
|
+
const envLevel = process.env.AGENT_SMITH_LOG_LEVEL?.toUpperCase();
|
|
1129
1129
|
if (envLevel && envLevel in LogLevel) {
|
|
1130
1130
|
return LogLevel[envLevel];
|
|
1131
1131
|
}
|
|
@@ -1202,7 +1202,7 @@ class Logger {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
setLevel(level) {
|
|
1204
1204
|
this.level = level;
|
|
1205
|
-
this.silentConsole = !(process.env.
|
|
1205
|
+
this.silentConsole = !(process.env.AGENT_SMITH_DEBUG === "1" || this.level === 0 /* DEBUG */);
|
|
1206
1206
|
}
|
|
1207
1207
|
getLevel() {
|
|
1208
1208
|
return this.level;
|
|
@@ -1237,11 +1237,11 @@ import { platform } from "process";
|
|
|
1237
1237
|
function getPlatformConfigDir() {
|
|
1238
1238
|
if (platform === "win32") {
|
|
1239
1239
|
const baseDir = process.env.LOCALAPPDATA ?? process.env.APPDATA ?? join4(homedir(), "AppData", "Local");
|
|
1240
|
-
return join4(baseDir, "
|
|
1240
|
+
return join4(baseDir, "agent-smith");
|
|
1241
1241
|
} else {
|
|
1242
1242
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
1243
1243
|
const baseDir = xdgConfig ?? join4(homedir(), ".config");
|
|
1244
|
-
return join4(baseDir, "
|
|
1244
|
+
return join4(baseDir, "agent-smith");
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
1247
|
var init_paths_common = () => {};
|
|
@@ -1249,12 +1249,12 @@ var init_paths_common = () => {};
|
|
|
1249
1249
|
// ../../packages/config/src/paths.ts
|
|
1250
1250
|
import { join as join5 } from "path";
|
|
1251
1251
|
function resolveConfigPath() {
|
|
1252
|
-
const explicitPath = process.env.
|
|
1252
|
+
const explicitPath = process.env.AGENT_SMITH_CONFIG_PATH;
|
|
1253
1253
|
if (explicitPath) {
|
|
1254
1254
|
return explicitPath;
|
|
1255
1255
|
}
|
|
1256
1256
|
const configDir = getPlatformConfigDir();
|
|
1257
|
-
return join5(configDir, "
|
|
1257
|
+
return join5(configDir, "agent-smith.json");
|
|
1258
1258
|
}
|
|
1259
1259
|
var init_paths = __esm(() => {
|
|
1260
1260
|
init_paths_common();
|
|
@@ -1421,6 +1421,8 @@ function sanitizeClientRouting(value) {
|
|
|
1421
1421
|
if (!isRecord(value))
|
|
1422
1422
|
return;
|
|
1423
1423
|
const client = {};
|
|
1424
|
+
if (typeof value.enabled === "boolean")
|
|
1425
|
+
client.enabled = value.enabled;
|
|
1424
1426
|
if (typeof value.base_url === "string") {
|
|
1425
1427
|
try {
|
|
1426
1428
|
const url = new URL(value.base_url);
|
|
@@ -1636,7 +1638,7 @@ var init_src4 = __esm(() => {
|
|
|
1636
1638
|
this.emit("change", { key, oldValue, newValue: value });
|
|
1637
1639
|
}
|
|
1638
1640
|
getStrategy() {
|
|
1639
|
-
const envStrategy = process.env.
|
|
1641
|
+
const envStrategy = process.env.AGENT_SMITH_LB_STRATEGY;
|
|
1640
1642
|
if (envStrategy && isValidStrategy(envStrategy)) {
|
|
1641
1643
|
return envStrategy;
|
|
1642
1644
|
}
|
|
@@ -1656,7 +1658,7 @@ var init_src4 = __esm(() => {
|
|
|
1656
1658
|
return Math.max(min, Math.min(max, n));
|
|
1657
1659
|
}
|
|
1658
1660
|
getDataRetentionDays() {
|
|
1659
|
-
const fromEnv = process.env.
|
|
1661
|
+
const fromEnv = process.env.AGENT_SMITH_DATA_RETENTION_DAYS;
|
|
1660
1662
|
if (fromEnv) {
|
|
1661
1663
|
const n = parseInt(fromEnv, 10);
|
|
1662
1664
|
if (!Number.isNaN(n))
|
|
@@ -1672,7 +1674,7 @@ var init_src4 = __esm(() => {
|
|
|
1672
1674
|
this.set("data_retention_days", clamped);
|
|
1673
1675
|
}
|
|
1674
1676
|
getRequestRetentionDays() {
|
|
1675
|
-
const fromEnv = process.env.
|
|
1677
|
+
const fromEnv = process.env.AGENT_SMITH_REQUEST_RETENTION_DAYS;
|
|
1676
1678
|
if (fromEnv) {
|
|
1677
1679
|
const n = parseInt(fromEnv, 10);
|
|
1678
1680
|
if (!Number.isNaN(n))
|
|
@@ -1726,6 +1728,7 @@ var init_src4 = __esm(() => {
|
|
|
1726
1728
|
getClientRouting() {
|
|
1727
1729
|
const client = this.data.client;
|
|
1728
1730
|
return {
|
|
1731
|
+
enabled: client?.enabled === true,
|
|
1729
1732
|
...client?.base_url && { baseUrl: client.base_url },
|
|
1730
1733
|
...client?.proxy_key_file && {
|
|
1731
1734
|
proxyKeyFile: client.proxy_key_file
|
|
@@ -1856,34 +1859,34 @@ var init_src4 = __esm(() => {
|
|
|
1856
1859
|
port: NETWORK.DEFAULT_PORT,
|
|
1857
1860
|
teamRouting: this.getTeamRouting()
|
|
1858
1861
|
};
|
|
1859
|
-
if (process.env.
|
|
1860
|
-
defaults.clientId = process.env.
|
|
1862
|
+
if (process.env.AGENT_SMITH_CLIENT_ID) {
|
|
1863
|
+
defaults.clientId = process.env.AGENT_SMITH_CLIENT_ID;
|
|
1861
1864
|
}
|
|
1862
|
-
const retryAttempts = parseNumber(process.env.
|
|
1865
|
+
const retryAttempts = parseNumber(process.env.AGENT_SMITH_RETRY_ATTEMPTS);
|
|
1863
1866
|
if (retryAttempts !== undefined) {
|
|
1864
1867
|
defaults.retry.attempts = retryAttempts;
|
|
1865
1868
|
}
|
|
1866
|
-
const maxBodyBytes = parseNumber(process.env.
|
|
1869
|
+
const maxBodyBytes = parseNumber(process.env.AGENT_SMITH_MAX_BODY_BYTES);
|
|
1867
1870
|
if (maxBodyBytes !== undefined) {
|
|
1868
1871
|
defaults.maxBodyBytes = maxBodyBytes;
|
|
1869
1872
|
}
|
|
1870
|
-
const quotaThreshold = parseNumber(process.env.
|
|
1873
|
+
const quotaThreshold = parseNumber(process.env.AGENT_SMITH_QUOTA_THRESHOLD);
|
|
1871
1874
|
if (quotaThreshold !== undefined && quotaThreshold > 0 && quotaThreshold <= 1) {
|
|
1872
1875
|
defaults.quotaThreshold = quotaThreshold;
|
|
1873
1876
|
}
|
|
1874
|
-
const retryDelayMs = parseNumber(process.env.
|
|
1877
|
+
const retryDelayMs = parseNumber(process.env.AGENT_SMITH_RETRY_DELAY_MS);
|
|
1875
1878
|
if (retryDelayMs !== undefined) {
|
|
1876
1879
|
defaults.retry.delayMs = retryDelayMs;
|
|
1877
1880
|
}
|
|
1878
|
-
const retryBackoff = parseNumber(process.env.
|
|
1881
|
+
const retryBackoff = parseNumber(process.env.AGENT_SMITH_RETRY_BACKOFF);
|
|
1879
1882
|
if (retryBackoff !== undefined) {
|
|
1880
1883
|
defaults.retry.backoff = retryBackoff;
|
|
1881
1884
|
}
|
|
1882
|
-
const requestScopedRetryDelayMs = parseNumber(process.env.
|
|
1885
|
+
const requestScopedRetryDelayMs = parseNumber(process.env.AGENT_SMITH_REQUEST_SCOPED_429_RETRY_DELAY_MS);
|
|
1883
1886
|
if (requestScopedRetryDelayMs !== undefined) {
|
|
1884
1887
|
defaults.requestScopedRetryDelayMs = requestScopedRetryDelayMs;
|
|
1885
1888
|
}
|
|
1886
|
-
const sessionDurationMs = parseNumber(process.env.
|
|
1889
|
+
const sessionDurationMs = parseNumber(process.env.AGENT_SMITH_SESSION_DURATION_MS);
|
|
1887
1890
|
if (sessionDurationMs !== undefined) {
|
|
1888
1891
|
defaults.sessionDurationMs = sessionDurationMs;
|
|
1889
1892
|
}
|
|
@@ -1979,12 +1982,12 @@ var init_analytics_query = __esm(() => {
|
|
|
1979
1982
|
// ../../packages/database/src/paths.ts
|
|
1980
1983
|
import { join as join6 } from "path";
|
|
1981
1984
|
function resolveDbPath() {
|
|
1982
|
-
const explicitPath = process.env.
|
|
1985
|
+
const explicitPath = process.env.AGENT_SMITH_DB_PATH;
|
|
1983
1986
|
if (explicitPath) {
|
|
1984
1987
|
return explicitPath;
|
|
1985
1988
|
}
|
|
1986
1989
|
const configDir = getPlatformConfigDir();
|
|
1987
|
-
return join6(configDir, "
|
|
1990
|
+
return join6(configDir, "agent-smith.db");
|
|
1988
1991
|
}
|
|
1989
1992
|
var init_paths2 = __esm(() => {
|
|
1990
1993
|
init_src4();
|
|
@@ -4636,7 +4639,8 @@ var init_base = __esm(() => {
|
|
|
4636
4639
|
TRANSPORT_HEADERS_TO_DELETE = [
|
|
4637
4640
|
"host",
|
|
4638
4641
|
"accept-encoding",
|
|
4639
|
-
"content-encoding"
|
|
4642
|
+
"content-encoding",
|
|
4643
|
+
"transfer-encoding"
|
|
4640
4644
|
];
|
|
4641
4645
|
CLIENT_CREDENTIAL_HEADERS_TO_DELETE = [
|
|
4642
4646
|
"api-key",
|
|
@@ -6473,7 +6477,7 @@ function createAuthCallbackHandler(dbOps, config, providerRegistry) {
|
|
|
6473
6477
|
sessionId: authSession.id,
|
|
6474
6478
|
code
|
|
6475
6479
|
});
|
|
6476
|
-
return htmlPage(200, "Account connected", "Your OAuth account has been connected successfully. You can close this window and return to
|
|
6480
|
+
return htmlPage(200, "Account connected", "Your OAuth account has been connected successfully. You can close this window and return to agent-smith.");
|
|
6477
6481
|
} catch (error) {
|
|
6478
6482
|
dbOps.deleteAuthSession(authSession.id);
|
|
6479
6483
|
return htmlPage(400, "Authorization failed", escapeHtml(error instanceof Error ? error.message : "Failed to complete OAuth flow."));
|
|
@@ -8645,11 +8649,12 @@ async function prepareRequestBody(req, maxBodyBytes = DEFAULT_MAX_BODY_BYTES) {
|
|
|
8645
8649
|
}
|
|
8646
8650
|
};
|
|
8647
8651
|
}
|
|
8648
|
-
async function makeProxyRequest(targetUrl, method, headers3, createBodyStream, hasBody) {
|
|
8652
|
+
async function makeProxyRequest(targetUrl, method, headers3, createBodyStream, hasBody, signal) {
|
|
8649
8653
|
return fetch(targetUrl, {
|
|
8650
8654
|
method,
|
|
8651
8655
|
headers: headers3,
|
|
8652
8656
|
body: createBodyStream(),
|
|
8657
|
+
signal,
|
|
8653
8658
|
...hasBody ? { duplex: "half" } : {}
|
|
8654
8659
|
});
|
|
8655
8660
|
}
|
|
@@ -9673,7 +9678,7 @@ function createUpstreamSender(input) {
|
|
|
9673
9678
|
const requestAccount = token === input.account.access_token ? input.account : { ...input.account, access_token: token };
|
|
9674
9679
|
const headers3 = input.ctx.provider.prepareHeaders(input.req.headers, requestAccount);
|
|
9675
9680
|
const upstreamRequestStartedAt = Date.now();
|
|
9676
|
-
const response = await makeProxyRequest(targetUrl, input.req.method, headers3, () => input.createBodyStream(input.requestBody), !!input.req.body);
|
|
9681
|
+
const response = await makeProxyRequest(targetUrl, input.req.method, headers3, () => input.createBodyStream(input.requestBody), !!input.req.body, input.req.signal);
|
|
9677
9682
|
return {
|
|
9678
9683
|
response,
|
|
9679
9684
|
responseHeadersReceivedAt: Date.now(),
|
|
@@ -9797,6 +9802,7 @@ async function proxyWithAccount(req, url, account2, requestMeta, requestBodyBuff
|
|
|
9797
9802
|
const upstream = await sendAuthorizedRequest(input, createUpstreamSender(input));
|
|
9798
9803
|
return isProxyAttempt(upstream) ? upstream : await classifyUpstreamResponse(input, upstream);
|
|
9799
9804
|
} catch (err) {
|
|
9805
|
+
req.signal.throwIfAborted();
|
|
9800
9806
|
handleProxyError(err, account2, log20);
|
|
9801
9807
|
return err instanceof TokenRefreshError ? { kind: "failed" } : { kind: "transport-failure" };
|
|
9802
9808
|
}
|
|
@@ -9869,6 +9875,7 @@ function quotaExhaustionResponse(resetAt2) {
|
|
|
9869
9875
|
});
|
|
9870
9876
|
}
|
|
9871
9877
|
async function attemptAccount(request2, account2, failoverAttempts) {
|
|
9878
|
+
request2.req.signal.throwIfAborted();
|
|
9872
9879
|
const admission = request2.ctx.teamAdmission;
|
|
9873
9880
|
let permit;
|
|
9874
9881
|
try {
|
|
@@ -10424,7 +10431,7 @@ function createDefaultLogger() {
|
|
|
10424
10431
|
};
|
|
10425
10432
|
}
|
|
10426
10433
|
function resolveUsageWorkerEntrypoint() {
|
|
10427
|
-
const configuredPath = process.env.
|
|
10434
|
+
const configuredPath = process.env.AGENT_SMITH_USAGE_WORKER_PATH?.trim();
|
|
10428
10435
|
if (!configuredPath) {
|
|
10429
10436
|
return new URL("./post-processor.worker.ts", import.meta.url).href;
|
|
10430
10437
|
}
|
|
@@ -10762,8 +10769,8 @@ var DEFAULT_READY_TIMEOUT_MS, DEFAULT_ACK_TIMEOUT_MS, DEFAULT_SHUTDOWN_DELAY_MS
|
|
|
10762
10769
|
var init_usage_worker = __esm(() => {
|
|
10763
10770
|
init_src2();
|
|
10764
10771
|
init_src();
|
|
10765
|
-
DEFAULT_READY_TIMEOUT_MS = Number(process.env.
|
|
10766
|
-
DEFAULT_ACK_TIMEOUT_MS = Number(process.env.
|
|
10772
|
+
DEFAULT_READY_TIMEOUT_MS = Number(process.env.AGENT_SMITH_USAGE_WORKER_READY_TIMEOUT_MS || TIME_CONSTANTS.RETRY_DELAY_DEFAULT * 5);
|
|
10773
|
+
DEFAULT_ACK_TIMEOUT_MS = Number(process.env.AGENT_SMITH_USAGE_WORKER_ACK_TIMEOUT_MS || TIME_CONSTANTS.RETRY_DELAY_DEFAULT * 5);
|
|
10767
10774
|
});
|
|
10768
10775
|
|
|
10769
10776
|
// ../../packages/proxy/src/proxy.ts
|
|
@@ -11748,13 +11755,13 @@ function configuredKey(value) {
|
|
|
11748
11755
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
11749
11756
|
}
|
|
11750
11757
|
function createExposureConfig(config) {
|
|
11751
|
-
const configuredHost = configuredKey(process.env.
|
|
11752
|
-
const configuredTrustLoopback = process.env.
|
|
11758
|
+
const configuredHost = configuredKey(process.env.AGENT_SMITH_HOST) ?? configuredKey(config.get("host"));
|
|
11759
|
+
const configuredTrustLoopback = process.env.AGENT_SMITH_TRUST_LOOPBACK;
|
|
11753
11760
|
return {
|
|
11754
|
-
adminKey: configuredKey(process.env.
|
|
11761
|
+
adminKey: configuredKey(process.env.AGENT_SMITH_ADMIN_KEY),
|
|
11755
11762
|
bindHost: configuredHost ?? "127.0.0.1",
|
|
11756
|
-
proxyKey: configuredKey(process.env.
|
|
11757
|
-
clientKeysFile: configuredKey(process.env.
|
|
11763
|
+
proxyKey: configuredKey(process.env.AGENT_SMITH_PROXY_KEY),
|
|
11764
|
+
clientKeysFile: configuredKey(process.env.AGENT_SMITH_CLIENT_KEYS_FILE),
|
|
11758
11765
|
trustLoopback: configuredTrustLoopback === undefined ? config.get("trust_loopback") !== false : configuredTrustLoopback !== "false"
|
|
11759
11766
|
};
|
|
11760
11767
|
}
|
|
@@ -11922,7 +11929,7 @@ function bootstrapRuntime(port, serverLog) {
|
|
|
11922
11929
|
container.registerInstance(SERVICE_KEYS.PricingLogger, pricingLogger);
|
|
11923
11930
|
setPricingLogger(pricingLogger);
|
|
11924
11931
|
const apiRouter = new APIRouter({
|
|
11925
|
-
enrollmentOrigin: process.env.
|
|
11932
|
+
enrollmentOrigin: process.env.AGENT_SMITH_ENROLLMENT_ORIGIN,
|
|
11926
11933
|
config,
|
|
11927
11934
|
dbOps,
|
|
11928
11935
|
providerRegistry,
|
|
@@ -12077,7 +12084,7 @@ function serveDashboardRoute(url) {
|
|
|
12077
12084
|
}
|
|
12078
12085
|
return null;
|
|
12079
12086
|
}
|
|
12080
|
-
var DASHBOARD_MANIFEST_EXPORT = "@
|
|
12087
|
+
var DASHBOARD_MANIFEST_EXPORT = "@agent-smith/web/manifest.json", DASHBOARD_DIST_DIR_ENV = "AGENT_SMITH_DASHBOARD_DIST_DIR", DASHBOARD_MANIFEST_PATH_ENV = "AGENT_SMITH_DASHBOARD_MANIFEST_PATH", dashboardAssets = null;
|
|
12081
12088
|
var init_dashboard_assets = __esm(() => {
|
|
12082
12089
|
init_src2();
|
|
12083
12090
|
});
|
|
@@ -12102,7 +12109,7 @@ var init_oauth_token = __esm(() => {
|
|
|
12102
12109
|
"host",
|
|
12103
12110
|
"content-length",
|
|
12104
12111
|
"x-api-key",
|
|
12105
|
-
"x-
|
|
12112
|
+
"x-agent-smith-scenario-client-id"
|
|
12106
12113
|
];
|
|
12107
12114
|
});
|
|
12108
12115
|
|
|
@@ -12197,7 +12204,7 @@ function createStartupBanner(options) {
|
|
|
12197
12204
|
const dashboardUrl = withDashboard ? `http://localhost:${port}` : "disabled";
|
|
12198
12205
|
const supportedProviders = providers2.join(", ");
|
|
12199
12206
|
return `
|
|
12200
|
-
\uD83C\uDFAF
|
|
12207
|
+
\uD83C\uDFAF Agent Smith Server v${version}
|
|
12201
12208
|
\uD83C\uDF10 Port: ${port}
|
|
12202
12209
|
\uD83D\uDCCA Dashboard: ${dashboardUrl}
|
|
12203
12210
|
\uD83D\uDD17 Management API: http://localhost:${port}/api
|
|
@@ -12804,6 +12811,79 @@ var init_request_presenters = __esm(() => {
|
|
|
12804
12811
|
};
|
|
12805
12812
|
});
|
|
12806
12813
|
|
|
12814
|
+
// ../../packages/ui/src/themes/agent-smith.ts
|
|
12815
|
+
var agentSmithLight, agentSmithDark;
|
|
12816
|
+
var init_agent_smith = __esm(() => {
|
|
12817
|
+
agentSmithLight = {
|
|
12818
|
+
id: "agent-smith-light",
|
|
12819
|
+
name: "Agent Smith Light",
|
|
12820
|
+
family: "agent-smith",
|
|
12821
|
+
appearance: "light",
|
|
12822
|
+
background: "#ffffff",
|
|
12823
|
+
foreground: "#0a0a0f",
|
|
12824
|
+
card: "#ffffff",
|
|
12825
|
+
cardForeground: "#0a0a0f",
|
|
12826
|
+
popover: "#ffffff",
|
|
12827
|
+
popoverForeground: "#0a0a0f",
|
|
12828
|
+
primary: "#f38020",
|
|
12829
|
+
primaryForeground: "#ffffff",
|
|
12830
|
+
secondary: "#f0f0f3",
|
|
12831
|
+
secondaryForeground: "#191920",
|
|
12832
|
+
muted: "#f0f0f3",
|
|
12833
|
+
mutedForeground: "#6e6e7a",
|
|
12834
|
+
accent: "#f38020",
|
|
12835
|
+
accentForeground: "#ffffff",
|
|
12836
|
+
destructive: "#e5484d",
|
|
12837
|
+
destructiveForeground: "#fafafa",
|
|
12838
|
+
border: "#e4e4e9",
|
|
12839
|
+
input: "#e4e4e9",
|
|
12840
|
+
ring: "#f38020",
|
|
12841
|
+
success: "#16a34a",
|
|
12842
|
+
warning: "#ca8a04",
|
|
12843
|
+
error: "#dc2626",
|
|
12844
|
+
info: "#2563eb",
|
|
12845
|
+
chart1: "#f38020",
|
|
12846
|
+
chart2: "#3b82f6",
|
|
12847
|
+
chart3: "#8b5cf6",
|
|
12848
|
+
chart4: "#ec4899",
|
|
12849
|
+
chart5: "#10b981"
|
|
12850
|
+
};
|
|
12851
|
+
agentSmithDark = {
|
|
12852
|
+
id: "agent-smith-dark",
|
|
12853
|
+
name: "Agent Smith Dark",
|
|
12854
|
+
family: "agent-smith",
|
|
12855
|
+
appearance: "dark",
|
|
12856
|
+
background: "#111318",
|
|
12857
|
+
foreground: "#f2f2f2",
|
|
12858
|
+
card: "#181b22",
|
|
12859
|
+
cardForeground: "#f2f2f2",
|
|
12860
|
+
popover: "#181b22",
|
|
12861
|
+
popoverForeground: "#f2f2f2",
|
|
12862
|
+
primary: "#f38020",
|
|
12863
|
+
primaryForeground: "#ffffff",
|
|
12864
|
+
secondary: "#262b33",
|
|
12865
|
+
secondaryForeground: "#f2f2f2",
|
|
12866
|
+
muted: "#262b33",
|
|
12867
|
+
mutedForeground: "#838996",
|
|
12868
|
+
accent: "#f38020",
|
|
12869
|
+
accentForeground: "#ffffff",
|
|
12870
|
+
destructive: "#e5484d",
|
|
12871
|
+
destructiveForeground: "#fafafa",
|
|
12872
|
+
border: "#2a303a",
|
|
12873
|
+
input: "#262b33",
|
|
12874
|
+
ring: "#f38020",
|
|
12875
|
+
success: "#3fb950",
|
|
12876
|
+
warning: "#d29922",
|
|
12877
|
+
error: "#f85149",
|
|
12878
|
+
info: "#58a6ff",
|
|
12879
|
+
chart1: "#f38020",
|
|
12880
|
+
chart2: "#58a6ff",
|
|
12881
|
+
chart3: "#bc8cff",
|
|
12882
|
+
chart4: "#f778ba",
|
|
12883
|
+
chart5: "#3fb950"
|
|
12884
|
+
};
|
|
12885
|
+
});
|
|
12886
|
+
|
|
12807
12887
|
// ../../packages/ui/src/themes/catppuccin.ts
|
|
12808
12888
|
var catppuccinMocha, catppuccinMacchiato, catppuccinFrappe, catppuccinLatte;
|
|
12809
12889
|
var init_catppuccin = __esm(() => {
|
|
@@ -12945,79 +13025,6 @@ var init_catppuccin = __esm(() => {
|
|
|
12945
13025
|
};
|
|
12946
13026
|
});
|
|
12947
13027
|
|
|
12948
|
-
// ../../packages/ui/src/themes/ccflare.ts
|
|
12949
|
-
var ccflareLight, ccflareDark;
|
|
12950
|
-
var init_ccflare = __esm(() => {
|
|
12951
|
-
ccflareLight = {
|
|
12952
|
-
id: "ccflare-light",
|
|
12953
|
-
name: "ccflare Light",
|
|
12954
|
-
family: "ccflare",
|
|
12955
|
-
appearance: "light",
|
|
12956
|
-
background: "#ffffff",
|
|
12957
|
-
foreground: "#0a0a0f",
|
|
12958
|
-
card: "#ffffff",
|
|
12959
|
-
cardForeground: "#0a0a0f",
|
|
12960
|
-
popover: "#ffffff",
|
|
12961
|
-
popoverForeground: "#0a0a0f",
|
|
12962
|
-
primary: "#f38020",
|
|
12963
|
-
primaryForeground: "#ffffff",
|
|
12964
|
-
secondary: "#f0f0f3",
|
|
12965
|
-
secondaryForeground: "#191920",
|
|
12966
|
-
muted: "#f0f0f3",
|
|
12967
|
-
mutedForeground: "#6e6e7a",
|
|
12968
|
-
accent: "#f38020",
|
|
12969
|
-
accentForeground: "#ffffff",
|
|
12970
|
-
destructive: "#e5484d",
|
|
12971
|
-
destructiveForeground: "#fafafa",
|
|
12972
|
-
border: "#e4e4e9",
|
|
12973
|
-
input: "#e4e4e9",
|
|
12974
|
-
ring: "#f38020",
|
|
12975
|
-
success: "#16a34a",
|
|
12976
|
-
warning: "#ca8a04",
|
|
12977
|
-
error: "#dc2626",
|
|
12978
|
-
info: "#2563eb",
|
|
12979
|
-
chart1: "#f38020",
|
|
12980
|
-
chart2: "#3b82f6",
|
|
12981
|
-
chart3: "#8b5cf6",
|
|
12982
|
-
chart4: "#ec4899",
|
|
12983
|
-
chart5: "#10b981"
|
|
12984
|
-
};
|
|
12985
|
-
ccflareDark = {
|
|
12986
|
-
id: "ccflare-dark",
|
|
12987
|
-
name: "ccflare Dark",
|
|
12988
|
-
family: "ccflare",
|
|
12989
|
-
appearance: "dark",
|
|
12990
|
-
background: "#111318",
|
|
12991
|
-
foreground: "#f2f2f2",
|
|
12992
|
-
card: "#181b22",
|
|
12993
|
-
cardForeground: "#f2f2f2",
|
|
12994
|
-
popover: "#181b22",
|
|
12995
|
-
popoverForeground: "#f2f2f2",
|
|
12996
|
-
primary: "#f38020",
|
|
12997
|
-
primaryForeground: "#ffffff",
|
|
12998
|
-
secondary: "#262b33",
|
|
12999
|
-
secondaryForeground: "#f2f2f2",
|
|
13000
|
-
muted: "#262b33",
|
|
13001
|
-
mutedForeground: "#838996",
|
|
13002
|
-
accent: "#f38020",
|
|
13003
|
-
accentForeground: "#ffffff",
|
|
13004
|
-
destructive: "#e5484d",
|
|
13005
|
-
destructiveForeground: "#fafafa",
|
|
13006
|
-
border: "#2a303a",
|
|
13007
|
-
input: "#262b33",
|
|
13008
|
-
ring: "#f38020",
|
|
13009
|
-
success: "#3fb950",
|
|
13010
|
-
warning: "#d29922",
|
|
13011
|
-
error: "#f85149",
|
|
13012
|
-
info: "#58a6ff",
|
|
13013
|
-
chart1: "#f38020",
|
|
13014
|
-
chart2: "#58a6ff",
|
|
13015
|
-
chart3: "#bc8cff",
|
|
13016
|
-
chart4: "#f778ba",
|
|
13017
|
-
chart5: "#3fb950"
|
|
13018
|
-
};
|
|
13019
|
-
});
|
|
13020
|
-
|
|
13021
13028
|
// ../../packages/ui/src/themes/dracula.ts
|
|
13022
13029
|
var dracula;
|
|
13023
13030
|
var init_dracula = __esm(() => {
|
|
@@ -13495,12 +13502,12 @@ function getThemeById(id) {
|
|
|
13495
13502
|
return THEME_REGISTRY.find((t) => t.id === id);
|
|
13496
13503
|
}
|
|
13497
13504
|
function getDefaultTheme(appearance) {
|
|
13498
|
-
return appearance === "dark" ?
|
|
13505
|
+
return appearance === "dark" ? agentSmithDark : agentSmithLight;
|
|
13499
13506
|
}
|
|
13500
13507
|
var THEME_REGISTRY, THEME_FAMILIES;
|
|
13501
13508
|
var init_themes = __esm(() => {
|
|
13509
|
+
init_agent_smith();
|
|
13502
13510
|
init_catppuccin();
|
|
13503
|
-
init_ccflare();
|
|
13504
13511
|
init_dracula();
|
|
13505
13512
|
init_gruvbox();
|
|
13506
13513
|
init_nord();
|
|
@@ -13509,8 +13516,8 @@ var init_themes = __esm(() => {
|
|
|
13509
13516
|
init_solarized();
|
|
13510
13517
|
init_tokyo_night();
|
|
13511
13518
|
THEME_REGISTRY = [
|
|
13512
|
-
|
|
13513
|
-
|
|
13519
|
+
agentSmithLight,
|
|
13520
|
+
agentSmithDark,
|
|
13514
13521
|
tokyoNight,
|
|
13515
13522
|
catppuccinMocha,
|
|
13516
13523
|
catppuccinMacchiato,
|
|
@@ -14055,17 +14062,17 @@ function validateProxyKeyFile(proxyKeyFile) {
|
|
|
14055
14062
|
try {
|
|
14056
14063
|
metadata = statSync3(resolvedPath);
|
|
14057
14064
|
} catch {
|
|
14058
|
-
throw new Error("Agent
|
|
14065
|
+
throw new Error("Agent Smith forwarding-key file is not readable");
|
|
14059
14066
|
}
|
|
14060
14067
|
if (!metadata.isFile()) {
|
|
14061
|
-
throw new Error("Agent
|
|
14068
|
+
throw new Error("Agent Smith forwarding-key path must be a file");
|
|
14062
14069
|
}
|
|
14063
14070
|
if ((metadata.mode & 63) !== 0) {
|
|
14064
|
-
throw new Error("Agent
|
|
14071
|
+
throw new Error("Agent Smith forwarding-key file must be owner-only");
|
|
14065
14072
|
}
|
|
14066
14073
|
const key = readFileSync4(resolvedPath, "utf8").trim();
|
|
14067
14074
|
if (!/^[\x21-\x7e]{1,512}$/.test(key)) {
|
|
14068
|
-
throw new Error("Agent
|
|
14075
|
+
throw new Error("Agent Smith forwarding-key file is invalid");
|
|
14069
14076
|
}
|
|
14070
14077
|
return resolvedPath;
|
|
14071
14078
|
}
|
|
@@ -14074,7 +14081,7 @@ function proxyKeySetup(proxyKeyFile) {
|
|
|
14074
14081
|
return `export AGENT_SMITH_PROXY_KEY=${shellQuote(LOCAL_CLIENT_KEY)}`;
|
|
14075
14082
|
}
|
|
14076
14083
|
return `if [ ! -r ${shellQuote(proxyKeyFile)} ]; then
|
|
14077
|
-
echo "Agent
|
|
14084
|
+
echo "Agent Smith forwarding-key file is not readable" >&2
|
|
14078
14085
|
exit 1
|
|
14079
14086
|
fi
|
|
14080
14087
|
export AGENT_SMITH_PROXY_KEY=$(cat ${shellQuote(proxyKeyFile)})`;
|
|
@@ -14082,11 +14089,12 @@ export AGENT_SMITH_PROXY_KEY=$(cat ${shellQuote(proxyKeyFile)})`;
|
|
|
14082
14089
|
function claudeWrapper(claudePath, baseUrl, proxyKeyFile) {
|
|
14083
14090
|
return `#!/bin/sh
|
|
14084
14091
|
# Generated by agent-smith. This file delegates to the real Claude Code binary.
|
|
14085
|
-
unset
|
|
14086
|
-
unset
|
|
14092
|
+
unset AGENT_SMITH_ADMIN_KEY
|
|
14093
|
+
unset AGENT_SMITH_PROXY_KEY
|
|
14094
|
+
unset ANTHROPIC_AUTH_TOKEN
|
|
14087
14095
|
${proxyKeySetup(proxyKeyFile)}
|
|
14088
14096
|
export ANTHROPIC_API_KEY="$AGENT_SMITH_PROXY_KEY"
|
|
14089
|
-
|
|
14097
|
+
unset AGENT_SMITH_PROXY_KEY
|
|
14090
14098
|
export ANTHROPIC_BASE_URL=${shellQuote(baseUrl)}
|
|
14091
14099
|
exec ${shellQuote(claudePath)} "$@"
|
|
14092
14100
|
`;
|
|
@@ -14094,7 +14102,7 @@ exec ${shellQuote(claudePath)} "$@"
|
|
|
14094
14102
|
function codexWrapper(codexPath, baseUrl, proxyKeyFile) {
|
|
14095
14103
|
const config = [
|
|
14096
14104
|
'model_provider="agent_smith"',
|
|
14097
|
-
'model_providers.agent_smith.name="Agent
|
|
14105
|
+
'model_providers.agent_smith.name="Agent Smith"',
|
|
14098
14106
|
`model_providers.agent_smith.base_url="${baseUrl}"`,
|
|
14099
14107
|
'model_providers.agent_smith.env_key="AGENT_SMITH_PROXY_KEY"',
|
|
14100
14108
|
'model_providers.agent_smith.wire_api="responses"',
|
|
@@ -14104,8 +14112,8 @@ function codexWrapper(codexPath, baseUrl, proxyKeyFile) {
|
|
|
14104
14112
|
const overrides = config.map((entry) => ` -c ${shellQuote(entry)}`).join(" \\\n");
|
|
14105
14113
|
return `#!/bin/sh
|
|
14106
14114
|
# Generated by agent-smith. This file delegates to the real Codex binary.
|
|
14107
|
-
unset
|
|
14108
|
-
unset
|
|
14115
|
+
unset AGENT_SMITH_ADMIN_KEY
|
|
14116
|
+
unset AGENT_SMITH_PROXY_KEY
|
|
14109
14117
|
${proxyKeySetup(proxyKeyFile)}
|
|
14110
14118
|
exec ${shellQuote(codexPath)} \\
|
|
14111
14119
|
${overrides} \\
|
|
@@ -14114,7 +14122,7 @@ ${overrides} \\
|
|
|
14114
14122
|
}
|
|
14115
14123
|
async function installClientWrappers(options) {
|
|
14116
14124
|
if (options.baseUrl && !options.proxyKeyFile) {
|
|
14117
|
-
throw new Error("A configured Agent
|
|
14125
|
+
throw new Error("A configured Agent Smith server requires a forwarding key file");
|
|
14118
14126
|
}
|
|
14119
14127
|
mkdirSync4(options.binDir, { recursive: true, mode: 448 });
|
|
14120
14128
|
const proxyKeyFile = options.proxyKeyFile ? validateProxyKeyFile(options.proxyKeyFile) : undefined;
|
|
@@ -14369,18 +14377,18 @@ function claudeProxyBaseUrl(port, usePool = false) {
|
|
|
14369
14377
|
}
|
|
14370
14378
|
function claudeRunEnvironment(port, proxyKey, environment = process.env, usePool = false) {
|
|
14371
14379
|
const childEnvironment = { ...environment };
|
|
14372
|
-
delete childEnvironment.
|
|
14373
|
-
delete childEnvironment.
|
|
14380
|
+
delete childEnvironment.AGENT_SMITH_ADMIN_KEY;
|
|
14381
|
+
delete childEnvironment.AGENT_SMITH_PROXY_KEY;
|
|
14382
|
+
delete childEnvironment.ANTHROPIC_AUTH_TOKEN;
|
|
14374
14383
|
return {
|
|
14375
14384
|
...childEnvironment,
|
|
14376
14385
|
ANTHROPIC_API_KEY: proxyKey,
|
|
14377
|
-
ANTHROPIC_AUTH_TOKEN: proxyKey,
|
|
14378
14386
|
ANTHROPIC_BASE_URL: claudeProxyBaseUrl(port, usePool)
|
|
14379
14387
|
};
|
|
14380
14388
|
}
|
|
14381
14389
|
function requireProxyKey(proxyKey) {
|
|
14382
14390
|
if (!proxyKey) {
|
|
14383
|
-
throw new Error("
|
|
14391
|
+
throw new Error("agent-smith run requires AGENT_SMITH_PROXY_KEY to authenticate its local proxy");
|
|
14384
14392
|
}
|
|
14385
14393
|
return proxyKey;
|
|
14386
14394
|
}
|
|
@@ -14511,7 +14519,7 @@ function loadPersistedThemeId() {
|
|
|
14511
14519
|
}
|
|
14512
14520
|
}
|
|
14513
14521
|
} catch {}
|
|
14514
|
-
return "
|
|
14522
|
+
return "agent-smith-dark";
|
|
14515
14523
|
}
|
|
14516
14524
|
function persistThemeId(themeId) {
|
|
14517
14525
|
try {
|
|
@@ -14543,7 +14551,7 @@ function getAvailableThemes() {
|
|
|
14543
14551
|
var CONFIG_DIR, CONFIG_FILE, currentThemeId, currentColors, C, NAV_ITEMS, SCREEN_TITLES;
|
|
14544
14552
|
var init_theme = __esm(() => {
|
|
14545
14553
|
init_src12();
|
|
14546
|
-
CONFIG_DIR = join9(homedir3(), ".config", "
|
|
14554
|
+
CONFIG_DIR = join9(homedir3(), ".config", "agent-smith");
|
|
14547
14555
|
CONFIG_FILE = join9(CONFIG_DIR, "theme.json");
|
|
14548
14556
|
currentThemeId = loadPersistedThemeId();
|
|
14549
14557
|
currentColors = themeToTuiColors(getThemeById(currentThemeId) ?? getDefaultTheme("dark"));
|
|
@@ -15133,7 +15141,7 @@ function AccountsScreen({ refreshKey, port }) {
|
|
|
15133
15141
|
/* @__PURE__ */ jsxs("text", {
|
|
15134
15142
|
fg: C.dim,
|
|
15135
15143
|
children: [
|
|
15136
|
-
"The real clients are not overwritten. Agent
|
|
15144
|
+
"The real clients are not overwritten. Agent Smith adds only its marked PATH block to ",
|
|
15137
15145
|
paths2.shellProfile,
|
|
15138
15146
|
"."
|
|
15139
15147
|
]
|
|
@@ -15141,7 +15149,7 @@ function AccountsScreen({ refreshKey, port }) {
|
|
|
15141
15149
|
]
|
|
15142
15150
|
}) : /* @__PURE__ */ jsx("text", {
|
|
15143
15151
|
fg: C.dim,
|
|
15144
|
-
children: "Remove Agent
|
|
15152
|
+
children: "Remove Agent Smith's wrappers and its marked PATH block. The real clients remain unchanged."
|
|
15145
15153
|
}),
|
|
15146
15154
|
/* @__PURE__ */ jsx("text", {
|
|
15147
15155
|
fg: C.muted,
|
|
@@ -17643,7 +17651,7 @@ function ThemePicker({ onClose }) {
|
|
|
17643
17651
|
}),
|
|
17644
17652
|
/* @__PURE__ */ jsx12("text", {
|
|
17645
17653
|
fg: C.muted,
|
|
17646
|
-
children: "Persists to ~/.config/
|
|
17654
|
+
children: "Persists to ~/.config/agent-smith/theme.json"
|
|
17647
17655
|
})
|
|
17648
17656
|
]
|
|
17649
17657
|
}) : /* @__PURE__ */ jsx12("text", {
|
|
@@ -17989,7 +17997,7 @@ Examples:
|
|
|
17989
17997
|
agent-smith --pause work # Pause account
|
|
17990
17998
|
agent-smith --analyze # Run performance analysis
|
|
17991
17999
|
agent-smith --stats # View stats
|
|
17992
|
-
agent-smith install-client # Configure Claude Code and Codex for this Agent
|
|
18000
|
+
agent-smith install-client # Configure Claude Code and Codex for this Agent Smith server
|
|
17993
18001
|
`);
|
|
17994
18002
|
process.exit(0);
|
|
17995
18003
|
}
|
|
@@ -18004,6 +18012,11 @@ Examples:
|
|
|
18004
18012
|
if (parsed.installClient) {
|
|
18005
18013
|
const config2 = new Config;
|
|
18006
18014
|
const client2 = config2.getClientRouting();
|
|
18015
|
+
if (!client2.enabled) {
|
|
18016
|
+
disableLocalClientRouting();
|
|
18017
|
+
console.log("Remote client routing is disabled (client.enabled=false).");
|
|
18018
|
+
return;
|
|
18019
|
+
}
|
|
18007
18020
|
if (!client2.baseUrl || !client2.proxyKeyFile) {
|
|
18008
18021
|
throw new Error("client.base_url and client.proxy_key_file are required before installing client wrappers");
|
|
18009
18022
|
}
|
|
@@ -18013,14 +18026,15 @@ Examples:
|
|
|
18013
18026
|
baseUrl: client2.baseUrl,
|
|
18014
18027
|
proxyKeyFile: client2.proxyKeyFile
|
|
18015
18028
|
});
|
|
18016
|
-
console.log(`
|
|
18029
|
+
console.log(`Client wrappers configured for ${client2.baseUrl}.`);
|
|
18030
|
+
console.log("Open a new shell and launch Claude Code or Codex through these wrappers. Already-running sessions are unchanged; restart or resume them through the wrapper.");
|
|
18017
18031
|
return;
|
|
18018
18032
|
}
|
|
18019
18033
|
if (parsed.run) {
|
|
18020
18034
|
printPocNotice();
|
|
18021
18035
|
const config2 = new Config;
|
|
18022
18036
|
const port2 = parsed.port || config2.getRuntime().port || NETWORK.DEFAULT_PORT;
|
|
18023
|
-
const proxyKey = requireProxyKey(process.env.
|
|
18037
|
+
const proxyKey = requireProxyKey(process.env.AGENT_SMITH_PROXY_KEY ?? "");
|
|
18024
18038
|
const proxyServer = startServer({ port: port2, withDashboard: false });
|
|
18025
18039
|
let exitCode;
|
|
18026
18040
|
try {
|
|
@@ -18171,8 +18185,8 @@ var init_main = __esm(() => {
|
|
|
18171
18185
|
|
|
18172
18186
|
// src/bundled-assets.ts
|
|
18173
18187
|
import { join } from "path";
|
|
18174
|
-
process.env.
|
|
18175
|
-
process.env.
|
|
18188
|
+
process.env.AGENT_SMITH_DASHBOARD_DIST_DIR ??= join(import.meta.dir, "dashboard");
|
|
18189
|
+
process.env.AGENT_SMITH_USAGE_WORKER_PATH ??= join(import.meta.dir, "post-processor.worker.js");
|
|
18176
18190
|
|
|
18177
18191
|
// src/bin.ts
|
|
18178
18192
|
await Promise.resolve().then(() => (init_main(), exports_main));
|