@certalis/agent-smith 0.1.0 → 0.1.1
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 +13 -0
- package/dist/bin.js +35 -33
- package/dist/server.js +11797 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -47,6 +47,19 @@ agent-smith
|
|
|
47
47
|
Or run it once without installing: `bunx @certalis/agent-smith`. To work from
|
|
48
48
|
source, clone this repository, then run `bun install && bun run ccflare`.
|
|
49
49
|
|
|
50
|
+
A host that supervises agent-smith itself can start the server in its own Bun
|
|
51
|
+
process, without the dashboard and with a private Unix socket beside the TCP port:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import startServer from "@certalis/agent-smith/server";
|
|
55
|
+
|
|
56
|
+
startServer({
|
|
57
|
+
port: 8081,
|
|
58
|
+
withDashboard: false,
|
|
59
|
+
additionalUnixSocket: "/absolute/path/control.sock",
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
50
63
|
## Quick start: Claude Code with an Anthropic API key
|
|
51
64
|
|
|
52
65
|
1. Create the config file (see [Configuration](#configuration)) with a pool for
|
package/dist/bin.js
CHANGED
|
@@ -316,7 +316,7 @@ var init_models = __esm(() => {
|
|
|
316
316
|
// ../../packages/core/src/pricing.ts
|
|
317
317
|
import { promises as fs } from "fs";
|
|
318
318
|
import { tmpdir } from "os";
|
|
319
|
-
import { join } from "path";
|
|
319
|
+
import { join as join2 } from "path";
|
|
320
320
|
|
|
321
321
|
class PriceCatalogue {
|
|
322
322
|
static instance;
|
|
@@ -335,10 +335,10 @@ class PriceCatalogue {
|
|
|
335
335
|
return PriceCatalogue.instance;
|
|
336
336
|
}
|
|
337
337
|
getCacheDir() {
|
|
338
|
-
return
|
|
338
|
+
return join2(tmpdir(), "ccflare");
|
|
339
339
|
}
|
|
340
340
|
getCachePath() {
|
|
341
|
-
return
|
|
341
|
+
return join2(this.getCacheDir(), "models.dev.json");
|
|
342
342
|
}
|
|
343
343
|
getCacheDurationMs() {
|
|
344
344
|
const hours = Number(process.env.CF_PRICING_REFRESH_HOURS) || 24;
|
|
@@ -1016,7 +1016,7 @@ import {
|
|
|
1016
1016
|
unlinkSync
|
|
1017
1017
|
} from "fs";
|
|
1018
1018
|
import { tmpdir as tmpdir2 } from "os";
|
|
1019
|
-
import { join as
|
|
1019
|
+
import { join as join3 } from "path";
|
|
1020
1020
|
function writeToStderr(message, error) {
|
|
1021
1021
|
if (typeof process === "undefined") {
|
|
1022
1022
|
return;
|
|
@@ -1032,11 +1032,11 @@ class LogFileWriter {
|
|
|
1032
1032
|
stream = null;
|
|
1033
1033
|
maxFileSize = BUFFER_SIZES.LOG_FILE_MAX_SIZE;
|
|
1034
1034
|
constructor() {
|
|
1035
|
-
this.logDir =
|
|
1035
|
+
this.logDir = join3(tmpdir2(), "ccflare-logs");
|
|
1036
1036
|
if (!existsSync(this.logDir)) {
|
|
1037
1037
|
mkdirSync(this.logDir, { recursive: true });
|
|
1038
1038
|
}
|
|
1039
|
-
this.logFile =
|
|
1039
|
+
this.logFile = join3(this.logDir, "app.log");
|
|
1040
1040
|
this.initStream();
|
|
1041
1041
|
}
|
|
1042
1042
|
initStream() {
|
|
@@ -1229,29 +1229,29 @@ var init_src3 = __esm(() => {
|
|
|
1229
1229
|
|
|
1230
1230
|
// ../../packages/config/src/paths-common.ts
|
|
1231
1231
|
import { homedir } from "os";
|
|
1232
|
-
import { join as
|
|
1232
|
+
import { join as join4 } from "path";
|
|
1233
1233
|
import { platform } from "process";
|
|
1234
1234
|
function getPlatformConfigDir() {
|
|
1235
1235
|
if (platform === "win32") {
|
|
1236
|
-
const baseDir = process.env.LOCALAPPDATA ?? process.env.APPDATA ??
|
|
1237
|
-
return
|
|
1236
|
+
const baseDir = process.env.LOCALAPPDATA ?? process.env.APPDATA ?? join4(homedir(), "AppData", "Local");
|
|
1237
|
+
return join4(baseDir, "ccflare");
|
|
1238
1238
|
} else {
|
|
1239
1239
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
1240
|
-
const baseDir = xdgConfig ??
|
|
1241
|
-
return
|
|
1240
|
+
const baseDir = xdgConfig ?? join4(homedir(), ".config");
|
|
1241
|
+
return join4(baseDir, "ccflare");
|
|
1242
1242
|
}
|
|
1243
1243
|
}
|
|
1244
1244
|
var init_paths_common = () => {};
|
|
1245
1245
|
|
|
1246
1246
|
// ../../packages/config/src/paths.ts
|
|
1247
|
-
import { join as
|
|
1247
|
+
import { join as join5 } from "path";
|
|
1248
1248
|
function resolveConfigPath() {
|
|
1249
1249
|
const explicitPath = process.env.ccflare_CONFIG_PATH;
|
|
1250
1250
|
if (explicitPath) {
|
|
1251
1251
|
return explicitPath;
|
|
1252
1252
|
}
|
|
1253
1253
|
const configDir = getPlatformConfigDir();
|
|
1254
|
-
return
|
|
1254
|
+
return join5(configDir, "ccflare.json");
|
|
1255
1255
|
}
|
|
1256
1256
|
var init_paths = __esm(() => {
|
|
1257
1257
|
init_paths_common();
|
|
@@ -1833,14 +1833,14 @@ var init_analytics_query = __esm(() => {
|
|
|
1833
1833
|
});
|
|
1834
1834
|
|
|
1835
1835
|
// ../../packages/database/src/paths.ts
|
|
1836
|
-
import { join as
|
|
1836
|
+
import { join as join6 } from "path";
|
|
1837
1837
|
function resolveDbPath() {
|
|
1838
1838
|
const explicitPath = process.env.ccflare_DB_PATH;
|
|
1839
1839
|
if (explicitPath) {
|
|
1840
1840
|
return explicitPath;
|
|
1841
1841
|
}
|
|
1842
1842
|
const configDir = getPlatformConfigDir();
|
|
1843
|
-
return
|
|
1843
|
+
return join6(configDir, "ccflare.db");
|
|
1844
1844
|
}
|
|
1845
1845
|
var init_paths2 = __esm(() => {
|
|
1846
1846
|
init_src4();
|
|
@@ -11378,7 +11378,7 @@ var init_bootstrap_runtime = __esm(() => {
|
|
|
11378
11378
|
|
|
11379
11379
|
// ../../packages/runtime-server/src/dashboard-assets.ts
|
|
11380
11380
|
import { readFileSync as readFileSync2 } from "fs";
|
|
11381
|
-
import { dirname as dirname3, isAbsolute as isAbsolute2, join as
|
|
11381
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join7, resolve as resolve2 } from "path";
|
|
11382
11382
|
function resolveConfiguredPath(configuredPath) {
|
|
11383
11383
|
return isAbsolute2(configuredPath) ? configuredPath : resolve2(process.cwd(), configuredPath);
|
|
11384
11384
|
}
|
|
@@ -11389,7 +11389,7 @@ function resolveDashboardManifestPath() {
|
|
|
11389
11389
|
}
|
|
11390
11390
|
const configuredDistDir = process.env[DASHBOARD_DIST_DIR_ENV]?.trim();
|
|
11391
11391
|
if (configuredDistDir) {
|
|
11392
|
-
return
|
|
11392
|
+
return join7(resolveConfiguredPath(configuredDistDir), "manifest.json");
|
|
11393
11393
|
}
|
|
11394
11394
|
return Bun.resolveSync(DASHBOARD_MANIFEST_EXPORT, process.cwd());
|
|
11395
11395
|
}
|
|
@@ -11408,7 +11408,7 @@ function loadDashboardAssets() {
|
|
|
11408
11408
|
return dashboardAssets;
|
|
11409
11409
|
}
|
|
11410
11410
|
function resolveDashboardAsset(assetPath) {
|
|
11411
|
-
return
|
|
11411
|
+
return join7(loadDashboardAssets().distDir, assetPath.replace(/^\//, ""));
|
|
11412
11412
|
}
|
|
11413
11413
|
function serveDashboardFile(assetPath, contentType, cacheControl) {
|
|
11414
11414
|
const fullPath = resolveDashboardAsset(assetPath);
|
|
@@ -13400,7 +13400,7 @@ import {
|
|
|
13400
13400
|
writeFileSync as writeFileSync2
|
|
13401
13401
|
} from "fs";
|
|
13402
13402
|
import { homedir as homedir2 } from "os";
|
|
13403
|
-
import { dirname as dirname4, join as
|
|
13403
|
+
import { dirname as dirname4, join as join8 } from "path";
|
|
13404
13404
|
function shellQuote(value) {
|
|
13405
13405
|
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
13406
13406
|
}
|
|
@@ -13446,7 +13446,7 @@ ${overrides} \\
|
|
|
13446
13446
|
async function installClientWrappers(options) {
|
|
13447
13447
|
mkdirSync4(options.binDir, { recursive: true, mode: 448 });
|
|
13448
13448
|
if (options.claudePath) {
|
|
13449
|
-
const claude =
|
|
13449
|
+
const claude = join8(options.binDir, "claude");
|
|
13450
13450
|
writeFileSync2(claude, claudeWrapper(options.claudePath, proxyBaseUrl(options.port, "claude-code", "anthropic-messages", options.providerPoolWires)), {
|
|
13451
13451
|
encoding: "utf8",
|
|
13452
13452
|
mode: 448
|
|
@@ -13454,7 +13454,7 @@ async function installClientWrappers(options) {
|
|
|
13454
13454
|
chmodSync(claude, 448);
|
|
13455
13455
|
}
|
|
13456
13456
|
if (options.codexPath) {
|
|
13457
|
-
const codex =
|
|
13457
|
+
const codex = join8(options.binDir, "codex");
|
|
13458
13458
|
writeFileSync2(codex, codexWrapper(options.codexPath, proxyBaseUrl(options.port, "codex", "openai-responses", options.providerPoolWires)), {
|
|
13459
13459
|
encoding: "utf8",
|
|
13460
13460
|
mode: 448
|
|
@@ -13464,14 +13464,14 @@ async function installClientWrappers(options) {
|
|
|
13464
13464
|
}
|
|
13465
13465
|
function defaultShellProfile() {
|
|
13466
13466
|
const shell = process.env.SHELL?.split("/").pop();
|
|
13467
|
-
return
|
|
13467
|
+
return join8(homedir2(), shell === "bash" ? ".bashrc" : ".zshrc");
|
|
13468
13468
|
}
|
|
13469
13469
|
function getLocalRoutingPaths() {
|
|
13470
13470
|
const configDir = dirname4(resolveConfigPath());
|
|
13471
13471
|
return {
|
|
13472
|
-
binDir:
|
|
13472
|
+
binDir: join8(configDir, "client-bin"),
|
|
13473
13473
|
shellProfile: defaultShellProfile(),
|
|
13474
|
-
statePath:
|
|
13474
|
+
statePath: join8(configDir, "client-routing.json")
|
|
13475
13475
|
};
|
|
13476
13476
|
}
|
|
13477
13477
|
function isExecutable(path) {
|
|
@@ -13486,7 +13486,7 @@ function findClientExecutable(name, binDir, path) {
|
|
|
13486
13486
|
for (const directory of path.split(":")) {
|
|
13487
13487
|
if (!directory || directory === binDir)
|
|
13488
13488
|
continue;
|
|
13489
|
-
const candidate =
|
|
13489
|
+
const candidate = join8(directory, name);
|
|
13490
13490
|
if (isExecutable(candidate))
|
|
13491
13491
|
return candidate;
|
|
13492
13492
|
}
|
|
@@ -13517,7 +13517,7 @@ function getLocalRoutingStatus(paths2 = {}) {
|
|
|
13517
13517
|
shellProfileHasRouting = existsSync3(shellProfile) && readFileSync3(shellProfile, "utf8").includes(ROUTING_BEGIN);
|
|
13518
13518
|
} catch {}
|
|
13519
13519
|
return {
|
|
13520
|
-
enabled: shellProfileHasRouting && (existsSync3(
|
|
13520
|
+
enabled: shellProfileHasRouting && (existsSync3(join8(binDir, "claude")) || existsSync3(join8(binDir, "codex"))),
|
|
13521
13521
|
binDir,
|
|
13522
13522
|
shellProfile
|
|
13523
13523
|
};
|
|
@@ -13567,7 +13567,7 @@ function disableLocalClientRouting(paths2 = {}) {
|
|
|
13567
13567
|
writeFileSync2(shellProfile, removeRoutingFromShellProfile(readFileSync3(shellProfile, "utf8")), { encoding: "utf8", mode: 384 });
|
|
13568
13568
|
}
|
|
13569
13569
|
for (const name of ["claude", "codex"]) {
|
|
13570
|
-
const wrapper =
|
|
13570
|
+
const wrapper = join8(binDir, name);
|
|
13571
13571
|
if (existsSync3(wrapper))
|
|
13572
13572
|
unlinkSync2(wrapper);
|
|
13573
13573
|
}
|
|
@@ -13826,7 +13826,7 @@ __export(exports_theme, {
|
|
|
13826
13826
|
});
|
|
13827
13827
|
import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
13828
13828
|
import { homedir as homedir3 } from "os";
|
|
13829
|
-
import { join as
|
|
13829
|
+
import { join as join9 } from "path";
|
|
13830
13830
|
function loadPersistedThemeId() {
|
|
13831
13831
|
try {
|
|
13832
13832
|
if (existsSync4(CONFIG_FILE)) {
|
|
@@ -13868,8 +13868,8 @@ function getAvailableThemes() {
|
|
|
13868
13868
|
var CONFIG_DIR, CONFIG_FILE, currentThemeId, currentColors, C, NAV_ITEMS, SCREEN_TITLES;
|
|
13869
13869
|
var init_theme = __esm(() => {
|
|
13870
13870
|
init_src12();
|
|
13871
|
-
CONFIG_DIR =
|
|
13872
|
-
CONFIG_FILE =
|
|
13871
|
+
CONFIG_DIR = join9(homedir3(), ".config", "ccflare");
|
|
13872
|
+
CONFIG_FILE = join9(CONFIG_DIR, "theme.json");
|
|
13873
13873
|
currentThemeId = loadPersistedThemeId();
|
|
13874
13874
|
currentColors = themeToTuiColors(getThemeById(currentThemeId) ?? getDefaultTheme("dark"));
|
|
13875
13875
|
C = new Proxy({}, {
|
|
@@ -17477,8 +17477,10 @@ var init_main = __esm(() => {
|
|
|
17477
17477
|
});
|
|
17478
17478
|
});
|
|
17479
17479
|
|
|
17480
|
+
// src/bundled-assets.ts
|
|
17481
|
+
import { join } from "path";
|
|
17482
|
+
process.env.CF_DASHBOARD_DIST_DIR ??= join(import.meta.dir, "dashboard");
|
|
17483
|
+
process.env.CF_USAGE_WORKER_PATH ??= join(import.meta.dir, "post-processor.worker.js");
|
|
17484
|
+
|
|
17480
17485
|
// src/bin.ts
|
|
17481
|
-
import { join as join9 } from "path";
|
|
17482
|
-
process.env.CF_DASHBOARD_DIST_DIR ??= join9(import.meta.dir, "dashboard");
|
|
17483
|
-
process.env.CF_USAGE_WORKER_PATH ??= join9(import.meta.dir, "post-processor.worker.js");
|
|
17484
17486
|
await Promise.resolve().then(() => (init_main(), exports_main));
|