@certalis/agent-smith 0.1.9 → 0.1.11
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 +12 -8
- package/dist/bin.js +149 -143
- 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 +13 -3
- package/dist/https.js +423 -0
- package/dist/pool.js +12446 -0
- package/dist/post-processor.worker.js +31 -31
- package/dist/server.js +46 -42
- package/package.json +10 -10
|
@@ -334,13 +334,13 @@ class PriceCatalogue {
|
|
|
334
334
|
return PriceCatalogue.instance;
|
|
335
335
|
}
|
|
336
336
|
getCacheDir() {
|
|
337
|
-
return join(tmpdir(), "
|
|
337
|
+
return join(tmpdir(), "agent-smith");
|
|
338
338
|
}
|
|
339
339
|
getCachePath() {
|
|
340
340
|
return join(this.getCacheDir(), "models.dev.json");
|
|
341
341
|
}
|
|
342
342
|
getCacheDurationMs() {
|
|
343
|
-
const hours = Number(process.env.
|
|
343
|
+
const hours = Number(process.env.AGENT_SMITH_PRICING_REFRESH_HOURS) || 24;
|
|
344
344
|
return hours * TIME_CONSTANTS.HOUR;
|
|
345
345
|
}
|
|
346
346
|
async ensureCacheDir() {
|
|
@@ -1087,7 +1087,7 @@ class LogFileWriter {
|
|
|
1087
1087
|
stream = null;
|
|
1088
1088
|
maxFileSize = BUFFER_SIZES.LOG_FILE_MAX_SIZE;
|
|
1089
1089
|
constructor() {
|
|
1090
|
-
this.logDir = join2(tmpdir2(), "
|
|
1090
|
+
this.logDir = join2(tmpdir2(), "agent-smith-logs");
|
|
1091
1091
|
if (!existsSync(this.logDir)) {
|
|
1092
1092
|
mkdirSync(this.logDir, { recursive: true });
|
|
1093
1093
|
}
|
|
@@ -1173,11 +1173,11 @@ class Logger {
|
|
|
1173
1173
|
constructor(prefix = "", level = 1 /* INFO */, options = {}) {
|
|
1174
1174
|
this.prefix = prefix;
|
|
1175
1175
|
this.level = this.getLogLevelFromEnv() || level;
|
|
1176
|
-
this.format = process.env.
|
|
1177
|
-
this.silentConsole = options.silentConsole ?? !(process.env.
|
|
1176
|
+
this.format = process.env.AGENT_SMITH_LOG_FORMAT || "pretty";
|
|
1177
|
+
this.silentConsole = options.silentConsole ?? !(process.env.AGENT_SMITH_DEBUG === "1" || this.level === 0 /* DEBUG */);
|
|
1178
1178
|
}
|
|
1179
1179
|
getLogLevelFromEnv() {
|
|
1180
|
-
const envLevel = process.env.
|
|
1180
|
+
const envLevel = process.env.AGENT_SMITH_LOG_LEVEL?.toUpperCase();
|
|
1181
1181
|
if (envLevel && envLevel in LogLevel) {
|
|
1182
1182
|
return LogLevel[envLevel];
|
|
1183
1183
|
}
|
|
@@ -1254,7 +1254,7 @@ class Logger {
|
|
|
1254
1254
|
}
|
|
1255
1255
|
setLevel(level) {
|
|
1256
1256
|
this.level = level;
|
|
1257
|
-
this.silentConsole = !(process.env.
|
|
1257
|
+
this.silentConsole = !(process.env.AGENT_SMITH_DEBUG === "1" || this.level === 0 /* DEBUG */);
|
|
1258
1258
|
}
|
|
1259
1259
|
getLevel() {
|
|
1260
1260
|
return this.level;
|
|
@@ -1289,11 +1289,11 @@ import { platform } from "process";
|
|
|
1289
1289
|
function getPlatformConfigDir() {
|
|
1290
1290
|
if (platform === "win32") {
|
|
1291
1291
|
const baseDir = process.env.LOCALAPPDATA ?? process.env.APPDATA ?? join3(homedir(), "AppData", "Local");
|
|
1292
|
-
return join3(baseDir, "
|
|
1292
|
+
return join3(baseDir, "agent-smith");
|
|
1293
1293
|
} else {
|
|
1294
1294
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
1295
1295
|
const baseDir = xdgConfig ?? join3(homedir(), ".config");
|
|
1296
|
-
return join3(baseDir, "
|
|
1296
|
+
return join3(baseDir, "agent-smith");
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
1299
|
var init_paths_common = () => {};
|
|
@@ -1301,12 +1301,12 @@ var init_paths_common = () => {};
|
|
|
1301
1301
|
// ../../packages/config/src/paths.ts
|
|
1302
1302
|
import { join as join4 } from "path";
|
|
1303
1303
|
function resolveConfigPath() {
|
|
1304
|
-
const explicitPath = process.env.
|
|
1304
|
+
const explicitPath = process.env.AGENT_SMITH_CONFIG_PATH;
|
|
1305
1305
|
if (explicitPath) {
|
|
1306
1306
|
return explicitPath;
|
|
1307
1307
|
}
|
|
1308
1308
|
const configDir = getPlatformConfigDir();
|
|
1309
|
-
return join4(configDir, "
|
|
1309
|
+
return join4(configDir, "agent-smith.json");
|
|
1310
1310
|
}
|
|
1311
1311
|
var init_paths = __esm(() => {
|
|
1312
1312
|
init_paths_common();
|
|
@@ -1690,7 +1690,7 @@ var init_src4 = __esm(() => {
|
|
|
1690
1690
|
this.emit("change", { key, oldValue, newValue: value });
|
|
1691
1691
|
}
|
|
1692
1692
|
getStrategy() {
|
|
1693
|
-
const envStrategy = process.env.
|
|
1693
|
+
const envStrategy = process.env.AGENT_SMITH_LB_STRATEGY;
|
|
1694
1694
|
if (envStrategy && isValidStrategy(envStrategy)) {
|
|
1695
1695
|
return envStrategy;
|
|
1696
1696
|
}
|
|
@@ -1710,7 +1710,7 @@ var init_src4 = __esm(() => {
|
|
|
1710
1710
|
return Math.max(min, Math.min(max, n));
|
|
1711
1711
|
}
|
|
1712
1712
|
getDataRetentionDays() {
|
|
1713
|
-
const fromEnv = process.env.
|
|
1713
|
+
const fromEnv = process.env.AGENT_SMITH_DATA_RETENTION_DAYS;
|
|
1714
1714
|
if (fromEnv) {
|
|
1715
1715
|
const n = parseInt(fromEnv, 10);
|
|
1716
1716
|
if (!Number.isNaN(n))
|
|
@@ -1726,7 +1726,7 @@ var init_src4 = __esm(() => {
|
|
|
1726
1726
|
this.set("data_retention_days", clamped);
|
|
1727
1727
|
}
|
|
1728
1728
|
getRequestRetentionDays() {
|
|
1729
|
-
const fromEnv = process.env.
|
|
1729
|
+
const fromEnv = process.env.AGENT_SMITH_REQUEST_RETENTION_DAYS;
|
|
1730
1730
|
if (fromEnv) {
|
|
1731
1731
|
const n = parseInt(fromEnv, 10);
|
|
1732
1732
|
if (!Number.isNaN(n))
|
|
@@ -1911,34 +1911,34 @@ var init_src4 = __esm(() => {
|
|
|
1911
1911
|
port: NETWORK.DEFAULT_PORT,
|
|
1912
1912
|
teamRouting: this.getTeamRouting()
|
|
1913
1913
|
};
|
|
1914
|
-
if (process.env.
|
|
1915
|
-
defaults.clientId = process.env.
|
|
1914
|
+
if (process.env.AGENT_SMITH_CLIENT_ID) {
|
|
1915
|
+
defaults.clientId = process.env.AGENT_SMITH_CLIENT_ID;
|
|
1916
1916
|
}
|
|
1917
|
-
const retryAttempts = parseNumber(process.env.
|
|
1917
|
+
const retryAttempts = parseNumber(process.env.AGENT_SMITH_RETRY_ATTEMPTS);
|
|
1918
1918
|
if (retryAttempts !== undefined) {
|
|
1919
1919
|
defaults.retry.attempts = retryAttempts;
|
|
1920
1920
|
}
|
|
1921
|
-
const maxBodyBytes = parseNumber(process.env.
|
|
1921
|
+
const maxBodyBytes = parseNumber(process.env.AGENT_SMITH_MAX_BODY_BYTES);
|
|
1922
1922
|
if (maxBodyBytes !== undefined) {
|
|
1923
1923
|
defaults.maxBodyBytes = maxBodyBytes;
|
|
1924
1924
|
}
|
|
1925
|
-
const quotaThreshold = parseNumber(process.env.
|
|
1925
|
+
const quotaThreshold = parseNumber(process.env.AGENT_SMITH_QUOTA_THRESHOLD);
|
|
1926
1926
|
if (quotaThreshold !== undefined && quotaThreshold > 0 && quotaThreshold <= 1) {
|
|
1927
1927
|
defaults.quotaThreshold = quotaThreshold;
|
|
1928
1928
|
}
|
|
1929
|
-
const retryDelayMs = parseNumber(process.env.
|
|
1929
|
+
const retryDelayMs = parseNumber(process.env.AGENT_SMITH_RETRY_DELAY_MS);
|
|
1930
1930
|
if (retryDelayMs !== undefined) {
|
|
1931
1931
|
defaults.retry.delayMs = retryDelayMs;
|
|
1932
1932
|
}
|
|
1933
|
-
const retryBackoff = parseNumber(process.env.
|
|
1933
|
+
const retryBackoff = parseNumber(process.env.AGENT_SMITH_RETRY_BACKOFF);
|
|
1934
1934
|
if (retryBackoff !== undefined) {
|
|
1935
1935
|
defaults.retry.backoff = retryBackoff;
|
|
1936
1936
|
}
|
|
1937
|
-
const requestScopedRetryDelayMs = parseNumber(process.env.
|
|
1937
|
+
const requestScopedRetryDelayMs = parseNumber(process.env.AGENT_SMITH_REQUEST_SCOPED_429_RETRY_DELAY_MS);
|
|
1938
1938
|
if (requestScopedRetryDelayMs !== undefined) {
|
|
1939
1939
|
defaults.requestScopedRetryDelayMs = requestScopedRetryDelayMs;
|
|
1940
1940
|
}
|
|
1941
|
-
const sessionDurationMs = parseNumber(process.env.
|
|
1941
|
+
const sessionDurationMs = parseNumber(process.env.AGENT_SMITH_SESSION_DURATION_MS);
|
|
1942
1942
|
if (sessionDurationMs !== undefined) {
|
|
1943
1943
|
defaults.sessionDurationMs = sessionDurationMs;
|
|
1944
1944
|
}
|
|
@@ -1981,12 +1981,12 @@ var init_src4 = __esm(() => {
|
|
|
1981
1981
|
// ../../packages/database/src/paths.ts
|
|
1982
1982
|
import { join as join5 } from "path";
|
|
1983
1983
|
function resolveDbPath() {
|
|
1984
|
-
const explicitPath = process.env.
|
|
1984
|
+
const explicitPath = process.env.AGENT_SMITH_DB_PATH;
|
|
1985
1985
|
if (explicitPath) {
|
|
1986
1986
|
return explicitPath;
|
|
1987
1987
|
}
|
|
1988
1988
|
const configDir = getPlatformConfigDir();
|
|
1989
|
-
return join5(configDir, "
|
|
1989
|
+
return join5(configDir, "agent-smith.db");
|
|
1990
1990
|
}
|
|
1991
1991
|
var init_paths2 = __esm(() => {
|
|
1992
1992
|
init_src4();
|
|
@@ -4559,12 +4559,12 @@ var tokenEncoder = get_encoding("cl100k_base");
|
|
|
4559
4559
|
var streamDecoder = new TextDecoder("utf-8", { fatal: false });
|
|
4560
4560
|
var dbOps = new DatabaseOperations;
|
|
4561
4561
|
var asyncWriter = new AsyncDbWriter;
|
|
4562
|
-
var MAX_BUFFER_SIZE = Number(process.env.
|
|
4563
|
-
var TIMEOUT_MS = Number(process.env.
|
|
4564
|
-
var MAX_PAYLOAD_BYTES = Number(process.env.
|
|
4565
|
-
var MAX_TRACKED_REQUESTS = Number(process.env.
|
|
4566
|
-
var TOKEN_CURVE_SAMPLE_EVERY = Math.max(1, Number(process.env.
|
|
4567
|
-
var TOKEN_CURVE_MAX_SAMPLES = Math.max(1, Number(process.env.
|
|
4562
|
+
var MAX_BUFFER_SIZE = Number(process.env.AGENT_SMITH_STREAM_USAGE_BUFFER_KB || BUFFER_SIZES.STREAM_USAGE_BUFFER_KB) * 1024;
|
|
4563
|
+
var TIMEOUT_MS = Number(process.env.AGENT_SMITH_STREAM_TIMEOUT_MS || TIME_CONSTANTS.STREAM_TIMEOUT_DEFAULT);
|
|
4564
|
+
var MAX_PAYLOAD_BYTES = Number(process.env.AGENT_SMITH_MAX_PAYLOAD_BYTES || 0) || 2 * 1024 * 1024;
|
|
4565
|
+
var MAX_TRACKED_REQUESTS = Number(process.env.AGENT_SMITH_MAX_TRACKED_REQUESTS || 0) || 100;
|
|
4566
|
+
var TOKEN_CURVE_SAMPLE_EVERY = Math.max(1, Number(process.env.AGENT_SMITH_TOKEN_CURVE_SAMPLE_EVERY || 10) || 10);
|
|
4567
|
+
var TOKEN_CURVE_MAX_SAMPLES = Math.max(1, Number(process.env.AGENT_SMITH_TOKEN_CURVE_MAX_SAMPLES || 200) || 200);
|
|
4568
4568
|
var RESPONSES_TERMINAL_EVENTS = new Set([
|
|
4569
4569
|
"response.completed",
|
|
4570
4570
|
"response.failed",
|
package/dist/server.js
CHANGED
|
@@ -334,13 +334,13 @@ class PriceCatalogue {
|
|
|
334
334
|
return PriceCatalogue.instance;
|
|
335
335
|
}
|
|
336
336
|
getCacheDir() {
|
|
337
|
-
return join2(tmpdir(), "
|
|
337
|
+
return join2(tmpdir(), "agent-smith");
|
|
338
338
|
}
|
|
339
339
|
getCachePath() {
|
|
340
340
|
return join2(this.getCacheDir(), "models.dev.json");
|
|
341
341
|
}
|
|
342
342
|
getCacheDurationMs() {
|
|
343
|
-
const hours = Number(process.env.
|
|
343
|
+
const hours = Number(process.env.AGENT_SMITH_PRICING_REFRESH_HOURS) || 24;
|
|
344
344
|
return hours * TIME_CONSTANTS.HOUR;
|
|
345
345
|
}
|
|
346
346
|
async ensureCacheDir() {
|
|
@@ -1158,7 +1158,7 @@ class LogFileWriter {
|
|
|
1158
1158
|
stream = null;
|
|
1159
1159
|
maxFileSize = BUFFER_SIZES.LOG_FILE_MAX_SIZE;
|
|
1160
1160
|
constructor() {
|
|
1161
|
-
this.logDir = join3(tmpdir2(), "
|
|
1161
|
+
this.logDir = join3(tmpdir2(), "agent-smith-logs");
|
|
1162
1162
|
if (!existsSync(this.logDir)) {
|
|
1163
1163
|
mkdirSync(this.logDir, { recursive: true });
|
|
1164
1164
|
}
|
|
@@ -1244,11 +1244,11 @@ class Logger {
|
|
|
1244
1244
|
constructor(prefix = "", level = 1 /* INFO */, options = {}) {
|
|
1245
1245
|
this.prefix = prefix;
|
|
1246
1246
|
this.level = this.getLogLevelFromEnv() || level;
|
|
1247
|
-
this.format = process.env.
|
|
1248
|
-
this.silentConsole = options.silentConsole ?? !(process.env.
|
|
1247
|
+
this.format = process.env.AGENT_SMITH_LOG_FORMAT || "pretty";
|
|
1248
|
+
this.silentConsole = options.silentConsole ?? !(process.env.AGENT_SMITH_DEBUG === "1" || this.level === 0 /* DEBUG */);
|
|
1249
1249
|
}
|
|
1250
1250
|
getLogLevelFromEnv() {
|
|
1251
|
-
const envLevel = process.env.
|
|
1251
|
+
const envLevel = process.env.AGENT_SMITH_LOG_LEVEL?.toUpperCase();
|
|
1252
1252
|
if (envLevel && envLevel in LogLevel) {
|
|
1253
1253
|
return LogLevel[envLevel];
|
|
1254
1254
|
}
|
|
@@ -1325,7 +1325,7 @@ class Logger {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
setLevel(level) {
|
|
1327
1327
|
this.level = level;
|
|
1328
|
-
this.silentConsole = !(process.env.
|
|
1328
|
+
this.silentConsole = !(process.env.AGENT_SMITH_DEBUG === "1" || this.level === 0 /* DEBUG */);
|
|
1329
1329
|
}
|
|
1330
1330
|
getLevel() {
|
|
1331
1331
|
return this.level;
|
|
@@ -3297,7 +3297,7 @@ function createAuthCallbackHandler(dbOps, config, providerRegistry) {
|
|
|
3297
3297
|
sessionId: authSession.id,
|
|
3298
3298
|
code
|
|
3299
3299
|
});
|
|
3300
|
-
return htmlPage(200, "Account connected", "Your OAuth account has been connected successfully. You can close this window and return to
|
|
3300
|
+
return htmlPage(200, "Account connected", "Your OAuth account has been connected successfully. You can close this window and return to agent-smith.");
|
|
3301
3301
|
} catch (error) {
|
|
3302
3302
|
dbOps.deleteAuthSession(authSession.id);
|
|
3303
3303
|
return htmlPage(400, "Authorization failed", escapeHtml(error instanceof Error ? error.message : "Failed to complete OAuth flow."));
|
|
@@ -3809,11 +3809,11 @@ import { platform } from "process";
|
|
|
3809
3809
|
function getPlatformConfigDir() {
|
|
3810
3810
|
if (platform === "win32") {
|
|
3811
3811
|
const baseDir = process.env.LOCALAPPDATA ?? process.env.APPDATA ?? join4(homedir(), "AppData", "Local");
|
|
3812
|
-
return join4(baseDir, "
|
|
3812
|
+
return join4(baseDir, "agent-smith");
|
|
3813
3813
|
} else {
|
|
3814
3814
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
3815
3815
|
const baseDir = xdgConfig ?? join4(homedir(), ".config");
|
|
3816
|
-
return join4(baseDir, "
|
|
3816
|
+
return join4(baseDir, "agent-smith");
|
|
3817
3817
|
}
|
|
3818
3818
|
}
|
|
3819
3819
|
var init_paths_common = () => {};
|
|
@@ -3821,12 +3821,12 @@ var init_paths_common = () => {};
|
|
|
3821
3821
|
// ../../packages/config/src/paths.ts
|
|
3822
3822
|
import { join as join5 } from "path";
|
|
3823
3823
|
function resolveConfigPath() {
|
|
3824
|
-
const explicitPath = process.env.
|
|
3824
|
+
const explicitPath = process.env.AGENT_SMITH_CONFIG_PATH;
|
|
3825
3825
|
if (explicitPath) {
|
|
3826
3826
|
return explicitPath;
|
|
3827
3827
|
}
|
|
3828
3828
|
const configDir = getPlatformConfigDir();
|
|
3829
|
-
return join5(configDir, "
|
|
3829
|
+
return join5(configDir, "agent-smith.json");
|
|
3830
3830
|
}
|
|
3831
3831
|
var init_paths = __esm(() => {
|
|
3832
3832
|
init_paths_common();
|
|
@@ -4210,7 +4210,7 @@ var init_src7 = __esm(() => {
|
|
|
4210
4210
|
this.emit("change", { key, oldValue, newValue: value });
|
|
4211
4211
|
}
|
|
4212
4212
|
getStrategy() {
|
|
4213
|
-
const envStrategy = process.env.
|
|
4213
|
+
const envStrategy = process.env.AGENT_SMITH_LB_STRATEGY;
|
|
4214
4214
|
if (envStrategy && isValidStrategy(envStrategy)) {
|
|
4215
4215
|
return envStrategy;
|
|
4216
4216
|
}
|
|
@@ -4230,7 +4230,7 @@ var init_src7 = __esm(() => {
|
|
|
4230
4230
|
return Math.max(min, Math.min(max, n));
|
|
4231
4231
|
}
|
|
4232
4232
|
getDataRetentionDays() {
|
|
4233
|
-
const fromEnv = process.env.
|
|
4233
|
+
const fromEnv = process.env.AGENT_SMITH_DATA_RETENTION_DAYS;
|
|
4234
4234
|
if (fromEnv) {
|
|
4235
4235
|
const n = parseInt(fromEnv, 10);
|
|
4236
4236
|
if (!Number.isNaN(n))
|
|
@@ -4246,7 +4246,7 @@ var init_src7 = __esm(() => {
|
|
|
4246
4246
|
this.set("data_retention_days", clamped);
|
|
4247
4247
|
}
|
|
4248
4248
|
getRequestRetentionDays() {
|
|
4249
|
-
const fromEnv = process.env.
|
|
4249
|
+
const fromEnv = process.env.AGENT_SMITH_REQUEST_RETENTION_DAYS;
|
|
4250
4250
|
if (fromEnv) {
|
|
4251
4251
|
const n = parseInt(fromEnv, 10);
|
|
4252
4252
|
if (!Number.isNaN(n))
|
|
@@ -4431,34 +4431,34 @@ var init_src7 = __esm(() => {
|
|
|
4431
4431
|
port: NETWORK.DEFAULT_PORT,
|
|
4432
4432
|
teamRouting: this.getTeamRouting()
|
|
4433
4433
|
};
|
|
4434
|
-
if (process.env.
|
|
4435
|
-
defaults.clientId = process.env.
|
|
4434
|
+
if (process.env.AGENT_SMITH_CLIENT_ID) {
|
|
4435
|
+
defaults.clientId = process.env.AGENT_SMITH_CLIENT_ID;
|
|
4436
4436
|
}
|
|
4437
|
-
const retryAttempts = parseNumber(process.env.
|
|
4437
|
+
const retryAttempts = parseNumber(process.env.AGENT_SMITH_RETRY_ATTEMPTS);
|
|
4438
4438
|
if (retryAttempts !== undefined) {
|
|
4439
4439
|
defaults.retry.attempts = retryAttempts;
|
|
4440
4440
|
}
|
|
4441
|
-
const maxBodyBytes = parseNumber(process.env.
|
|
4441
|
+
const maxBodyBytes = parseNumber(process.env.AGENT_SMITH_MAX_BODY_BYTES);
|
|
4442
4442
|
if (maxBodyBytes !== undefined) {
|
|
4443
4443
|
defaults.maxBodyBytes = maxBodyBytes;
|
|
4444
4444
|
}
|
|
4445
|
-
const quotaThreshold = parseNumber(process.env.
|
|
4445
|
+
const quotaThreshold = parseNumber(process.env.AGENT_SMITH_QUOTA_THRESHOLD);
|
|
4446
4446
|
if (quotaThreshold !== undefined && quotaThreshold > 0 && quotaThreshold <= 1) {
|
|
4447
4447
|
defaults.quotaThreshold = quotaThreshold;
|
|
4448
4448
|
}
|
|
4449
|
-
const retryDelayMs = parseNumber(process.env.
|
|
4449
|
+
const retryDelayMs = parseNumber(process.env.AGENT_SMITH_RETRY_DELAY_MS);
|
|
4450
4450
|
if (retryDelayMs !== undefined) {
|
|
4451
4451
|
defaults.retry.delayMs = retryDelayMs;
|
|
4452
4452
|
}
|
|
4453
|
-
const retryBackoff = parseNumber(process.env.
|
|
4453
|
+
const retryBackoff = parseNumber(process.env.AGENT_SMITH_RETRY_BACKOFF);
|
|
4454
4454
|
if (retryBackoff !== undefined) {
|
|
4455
4455
|
defaults.retry.backoff = retryBackoff;
|
|
4456
4456
|
}
|
|
4457
|
-
const requestScopedRetryDelayMs = parseNumber(process.env.
|
|
4457
|
+
const requestScopedRetryDelayMs = parseNumber(process.env.AGENT_SMITH_REQUEST_SCOPED_429_RETRY_DELAY_MS);
|
|
4458
4458
|
if (requestScopedRetryDelayMs !== undefined) {
|
|
4459
4459
|
defaults.requestScopedRetryDelayMs = requestScopedRetryDelayMs;
|
|
4460
4460
|
}
|
|
4461
|
-
const sessionDurationMs = parseNumber(process.env.
|
|
4461
|
+
const sessionDurationMs = parseNumber(process.env.AGENT_SMITH_SESSION_DURATION_MS);
|
|
4462
4462
|
if (sessionDurationMs !== undefined) {
|
|
4463
4463
|
defaults.sessionDurationMs = sessionDurationMs;
|
|
4464
4464
|
}
|
|
@@ -4501,12 +4501,12 @@ var init_src7 = __esm(() => {
|
|
|
4501
4501
|
// ../../packages/database/src/paths.ts
|
|
4502
4502
|
import { join as join6 } from "path";
|
|
4503
4503
|
function resolveDbPath() {
|
|
4504
|
-
const explicitPath = process.env.
|
|
4504
|
+
const explicitPath = process.env.AGENT_SMITH_DB_PATH;
|
|
4505
4505
|
if (explicitPath) {
|
|
4506
4506
|
return explicitPath;
|
|
4507
4507
|
}
|
|
4508
4508
|
const configDir = getPlatformConfigDir();
|
|
4509
|
-
return join6(configDir, "
|
|
4509
|
+
return join6(configDir, "agent-smith.db");
|
|
4510
4510
|
}
|
|
4511
4511
|
var init_paths2 = __esm(() => {
|
|
4512
4512
|
init_src7();
|
|
@@ -8648,11 +8648,12 @@ async function prepareRequestBody(req, maxBodyBytes = DEFAULT_MAX_BODY_BYTES) {
|
|
|
8648
8648
|
}
|
|
8649
8649
|
};
|
|
8650
8650
|
}
|
|
8651
|
-
async function makeProxyRequest(targetUrl, method, headers3, createBodyStream, hasBody) {
|
|
8651
|
+
async function makeProxyRequest(targetUrl, method, headers3, createBodyStream, hasBody, signal) {
|
|
8652
8652
|
return fetch(targetUrl, {
|
|
8653
8653
|
method,
|
|
8654
8654
|
headers: headers3,
|
|
8655
8655
|
body: createBodyStream(),
|
|
8656
|
+
signal,
|
|
8656
8657
|
...hasBody ? { duplex: "half" } : {}
|
|
8657
8658
|
});
|
|
8658
8659
|
}
|
|
@@ -9676,7 +9677,7 @@ function createUpstreamSender(input) {
|
|
|
9676
9677
|
const requestAccount = token === input.account.access_token ? input.account : { ...input.account, access_token: token };
|
|
9677
9678
|
const headers3 = input.ctx.provider.prepareHeaders(input.req.headers, requestAccount);
|
|
9678
9679
|
const upstreamRequestStartedAt = Date.now();
|
|
9679
|
-
const response = await makeProxyRequest(targetUrl, input.req.method, headers3, () => input.createBodyStream(input.requestBody), !!input.req.body);
|
|
9680
|
+
const response = await makeProxyRequest(targetUrl, input.req.method, headers3, () => input.createBodyStream(input.requestBody), !!input.req.body, input.req.signal);
|
|
9680
9681
|
return {
|
|
9681
9682
|
response,
|
|
9682
9683
|
responseHeadersReceivedAt: Date.now(),
|
|
@@ -9800,6 +9801,7 @@ async function proxyWithAccount(req, url, account2, requestMeta, requestBodyBuff
|
|
|
9800
9801
|
const upstream = await sendAuthorizedRequest(input, createUpstreamSender(input));
|
|
9801
9802
|
return isProxyAttempt(upstream) ? upstream : await classifyUpstreamResponse(input, upstream);
|
|
9802
9803
|
} catch (err) {
|
|
9804
|
+
req.signal.throwIfAborted();
|
|
9803
9805
|
handleProxyError(err, account2, log20);
|
|
9804
9806
|
return err instanceof TokenRefreshError ? { kind: "failed" } : { kind: "transport-failure" };
|
|
9805
9807
|
}
|
|
@@ -9872,6 +9874,7 @@ function quotaExhaustionResponse(resetAt2) {
|
|
|
9872
9874
|
});
|
|
9873
9875
|
}
|
|
9874
9876
|
async function attemptAccount(request2, account2, failoverAttempts) {
|
|
9877
|
+
request2.req.signal.throwIfAborted();
|
|
9875
9878
|
const admission = request2.ctx.teamAdmission;
|
|
9876
9879
|
let permit;
|
|
9877
9880
|
try {
|
|
@@ -10427,7 +10430,7 @@ function createDefaultLogger() {
|
|
|
10427
10430
|
};
|
|
10428
10431
|
}
|
|
10429
10432
|
function resolveUsageWorkerEntrypoint() {
|
|
10430
|
-
const configuredPath = process.env.
|
|
10433
|
+
const configuredPath = process.env.AGENT_SMITH_USAGE_WORKER_PATH?.trim();
|
|
10431
10434
|
if (!configuredPath) {
|
|
10432
10435
|
return new URL("./post-processor.worker.ts", import.meta.url).href;
|
|
10433
10436
|
}
|
|
@@ -10765,8 +10768,8 @@ var DEFAULT_READY_TIMEOUT_MS, DEFAULT_ACK_TIMEOUT_MS, DEFAULT_SHUTDOWN_DELAY_MS
|
|
|
10765
10768
|
var init_usage_worker = __esm(() => {
|
|
10766
10769
|
init_src2();
|
|
10767
10770
|
init_src();
|
|
10768
|
-
DEFAULT_READY_TIMEOUT_MS = Number(process.env.
|
|
10769
|
-
DEFAULT_ACK_TIMEOUT_MS = Number(process.env.
|
|
10771
|
+
DEFAULT_READY_TIMEOUT_MS = Number(process.env.AGENT_SMITH_USAGE_WORKER_READY_TIMEOUT_MS || TIME_CONSTANTS.RETRY_DELAY_DEFAULT * 5);
|
|
10772
|
+
DEFAULT_ACK_TIMEOUT_MS = Number(process.env.AGENT_SMITH_USAGE_WORKER_ACK_TIMEOUT_MS || TIME_CONSTANTS.RETRY_DELAY_DEFAULT * 5);
|
|
10770
10773
|
});
|
|
10771
10774
|
|
|
10772
10775
|
// ../../packages/proxy/src/proxy.ts
|
|
@@ -11751,13 +11754,13 @@ function configuredKey(value) {
|
|
|
11751
11754
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
11752
11755
|
}
|
|
11753
11756
|
function createExposureConfig(config) {
|
|
11754
|
-
const configuredHost = configuredKey(process.env.
|
|
11755
|
-
const configuredTrustLoopback = process.env.
|
|
11757
|
+
const configuredHost = configuredKey(process.env.AGENT_SMITH_HOST) ?? configuredKey(config.get("host"));
|
|
11758
|
+
const configuredTrustLoopback = process.env.AGENT_SMITH_TRUST_LOOPBACK;
|
|
11756
11759
|
return {
|
|
11757
|
-
adminKey: configuredKey(process.env.
|
|
11760
|
+
adminKey: configuredKey(process.env.AGENT_SMITH_ADMIN_KEY),
|
|
11758
11761
|
bindHost: configuredHost ?? "127.0.0.1",
|
|
11759
|
-
proxyKey: configuredKey(process.env.
|
|
11760
|
-
clientKeysFile: configuredKey(process.env.
|
|
11762
|
+
proxyKey: configuredKey(process.env.AGENT_SMITH_PROXY_KEY),
|
|
11763
|
+
clientKeysFile: configuredKey(process.env.AGENT_SMITH_CLIENT_KEYS_FILE),
|
|
11761
11764
|
trustLoopback: configuredTrustLoopback === undefined ? config.get("trust_loopback") !== false : configuredTrustLoopback !== "false"
|
|
11762
11765
|
};
|
|
11763
11766
|
}
|
|
@@ -11925,7 +11928,7 @@ function bootstrapRuntime(port, serverLog) {
|
|
|
11925
11928
|
container.registerInstance(SERVICE_KEYS.PricingLogger, pricingLogger);
|
|
11926
11929
|
setPricingLogger(pricingLogger);
|
|
11927
11930
|
const apiRouter = new APIRouter({
|
|
11928
|
-
enrollmentOrigin: process.env.
|
|
11931
|
+
enrollmentOrigin: process.env.AGENT_SMITH_ENROLLMENT_ORIGIN,
|
|
11929
11932
|
config,
|
|
11930
11933
|
dbOps,
|
|
11931
11934
|
providerRegistry,
|
|
@@ -12080,7 +12083,7 @@ function serveDashboardRoute(url) {
|
|
|
12080
12083
|
}
|
|
12081
12084
|
return null;
|
|
12082
12085
|
}
|
|
12083
|
-
var DASHBOARD_MANIFEST_EXPORT = "@
|
|
12086
|
+
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;
|
|
12084
12087
|
var init_dashboard_assets = __esm(() => {
|
|
12085
12088
|
init_src2();
|
|
12086
12089
|
});
|
|
@@ -12105,7 +12108,7 @@ var init_oauth_token = __esm(() => {
|
|
|
12105
12108
|
"host",
|
|
12106
12109
|
"content-length",
|
|
12107
12110
|
"x-api-key",
|
|
12108
|
-
"x-
|
|
12111
|
+
"x-agent-smith-scenario-client-id"
|
|
12109
12112
|
];
|
|
12110
12113
|
});
|
|
12111
12114
|
|
|
@@ -12200,7 +12203,7 @@ function createStartupBanner(options) {
|
|
|
12200
12203
|
const dashboardUrl = withDashboard ? `http://localhost:${port}` : "disabled";
|
|
12201
12204
|
const supportedProviders = providers2.join(", ");
|
|
12202
12205
|
return `
|
|
12203
|
-
\uD83C\uDFAF
|
|
12206
|
+
\uD83C\uDFAF Agent Smith Server v${version}
|
|
12204
12207
|
\uD83C\uDF10 Port: ${port}
|
|
12205
12208
|
\uD83D\uDCCA Dashboard: ${dashboardUrl}
|
|
12206
12209
|
\uD83D\uDD17 Management API: http://localhost:${port}/api
|
|
@@ -12354,6 +12357,7 @@ function startServer(options) {
|
|
|
12354
12357
|
if (options?.additionalUnixSocket) {
|
|
12355
12358
|
unixServerInstance = serve({
|
|
12356
12359
|
unix: options.additionalUnixSocket,
|
|
12360
|
+
idleTimeout: NETWORK.IDLE_TIMEOUT_MAX,
|
|
12357
12361
|
fetch: fetchHandler,
|
|
12358
12362
|
websocket: websocketProxyHandler
|
|
12359
12363
|
});
|
|
@@ -12425,8 +12429,8 @@ var init_src11 = __esm(() => {
|
|
|
12425
12429
|
|
|
12426
12430
|
// src/bundled-assets.ts
|
|
12427
12431
|
import { join } from "path";
|
|
12428
|
-
process.env.
|
|
12429
|
-
process.env.
|
|
12432
|
+
process.env.AGENT_SMITH_DASHBOARD_DIST_DIR ??= join(import.meta.dir, "dashboard");
|
|
12433
|
+
process.env.AGENT_SMITH_USAGE_WORKER_PATH ??= join(import.meta.dir, "post-processor.worker.js");
|
|
12430
12434
|
|
|
12431
12435
|
// src/server.ts
|
|
12432
12436
|
init_src11();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@certalis/agent-smith",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "PROOF OF CONCEPT for ideation only: an experimental local proxy and provider pool for Claude Code and Codex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Certalis",
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"react": "^19.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
40
|
+
"@agent-smith/config": "workspace:*",
|
|
41
|
+
"@agent-smith/core": "workspace:*",
|
|
42
|
+
"@agent-smith/database": "workspace:*",
|
|
43
|
+
"@agent-smith/logger": "workspace:*",
|
|
44
|
+
"@agent-smith/oauth-flow": "workspace:*",
|
|
45
|
+
"@agent-smith/providers": "workspace:*",
|
|
46
|
+
"@agent-smith/runtime-server": "workspace:*",
|
|
47
|
+
"@agent-smith/types": "workspace:*",
|
|
48
|
+
"@agent-smith/ui": "workspace:*",
|
|
49
49
|
"@types/react": "^19.0.0",
|
|
50
50
|
"@types/node": "^20.0.0"
|
|
51
51
|
},
|