@certalis/agent-smith 0.1.14 → 0.1.15
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 +19 -11
- package/dist/bin.js +180 -18
- package/dist/client-launcher.js +2295 -0
- package/dist/https.js +3 -1
- package/dist/pool.js +28 -9
- package/dist/post-processor.worker.js +27 -8
- package/dist/server.js +27 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,8 +105,7 @@ Copy [`https-client.json`](examples/config/https-client.json) into your private
|
|
|
105
105
|
Agent Smith config. Put the device key in the owner-only file named by
|
|
106
106
|
`proxy_key_file`, not in the JSON or a shell profile. `base_url` is the endpoint
|
|
107
107
|
visible to your machine, not a second pool. The key can spend from the pool, but
|
|
108
|
-
cannot administer it. Remote client routing is off by default
|
|
109
|
-
`client.enabled` to `true` when this machine should use the shared pool.
|
|
108
|
+
cannot administer it. Remote client routing is off by default.
|
|
110
109
|
|
|
111
110
|
An SSH tunnel remains an option for development. Use
|
|
112
111
|
[`team-client.json`](examples/config/team-client.json) and forward its local port
|
|
@@ -116,10 +115,10 @@ to the private server:
|
|
|
116
115
|
ssh -N -L 18181:127.0.0.1:8080 agent-smith-pool
|
|
117
116
|
```
|
|
118
117
|
|
|
119
|
-
Then
|
|
118
|
+
Then turn on shared-pool use with the shipped command:
|
|
120
119
|
|
|
121
120
|
```bash
|
|
122
|
-
agent-smith
|
|
121
|
+
agent-smith client on
|
|
123
122
|
```
|
|
124
123
|
|
|
125
124
|
Open a new terminal and use `claude` or `codex` normally. The wrappers only add
|
|
@@ -128,12 +127,21 @@ second proxy. The forwarding key is for inference, not dashboard or management
|
|
|
128
127
|
access.
|
|
129
128
|
|
|
130
129
|
Claude sends one device credential in the API-key header to the gateway; it is
|
|
131
|
-
not an Anthropic Console key. Claude.ai cloud connectors are not available by default in this
|
|
132
|
-
mode;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
not an Anthropic Console key. Claude in Chrome and claude.ai cloud connectors are not available by default in this
|
|
131
|
+
mode; `client.keep_claude_login` keeps them on. See the
|
|
132
|
+
[client behavior and limits](docs/https-edge.md#configure-and-prove).
|
|
133
|
+
|
|
134
|
+
Use `agent-smith client off` to use ordinary local Claude Code/Codex again;
|
|
135
|
+
`agent-smith client status` shows the switch and launcher setup. Add `--raw` for
|
|
136
|
+
JSON instead of readable text. These commands work outside any repository.
|
|
137
|
+
|
|
138
|
+
The first `on` installs the launchers (or updates previously generated ones).
|
|
139
|
+
Later switches change only `client.enabled`: each new client process reads the
|
|
140
|
+
current origin, key-file path and flag. Off keeps the launchers installed, reads
|
|
141
|
+
no forwarding key and delegates to the native client without changing its login.
|
|
142
|
+
Restart/resume existing sessions after switching. No proxy restart is needed.
|
|
143
|
+
`install-client` remains the explicit setup/removal command; it is not needed
|
|
144
|
+
between on/off switches.
|
|
137
145
|
|
|
138
146
|
## Configuration
|
|
139
147
|
|
|
@@ -153,7 +161,7 @@ Restart agent-smith after changing `providers`, `provider_pools`, `alerts` or
|
|
|
153
161
|
| `providers.<name>.base_url` | The upstream URL, for an endpoint compatible with one of the strategies. |
|
|
154
162
|
| `providers.<name>.models` | The models a provider serves, as `"client model": "provider model"`. A trailing `*` matches a prefix. Without it, the provider serves every model name unchanged. |
|
|
155
163
|
| `provider_pools.<protocol>` | The ordered providers for `anthropic-messages` or `openai-responses`. Clients reach it at `/v1/pool/<protocol>/*`, and the local wrappers use it automatically. |
|
|
156
|
-
| `client` |
|
|
164
|
+
| `client` | This machine's shared-pool switch, origin and forwarding-key file. Use `agent-smith client on`, `off` or `status`; it does not define providers or a separate pool. |
|
|
157
165
|
| `team_routing` | Which subscription accounts may share a pool, and their usage caps. See the [configuration guide](docs/configuration.md#team-routing). |
|
|
158
166
|
| `alerts` | A Slack webhook or bot token and/or an email address that hear when a seat spends extra usage and when every account is full. A filled value turns its channel on. See [Alerts](docs/configuration.md#alerts). |
|
|
159
167
|
| `block_when_all_full` | `true` by default: when every account is full, every request is refused until the soonest reset, so none spends extra usage. |
|
package/dist/bin.js
CHANGED
|
@@ -1436,6 +1436,9 @@ function sanitizeClientRouting(value) {
|
|
|
1436
1436
|
if (typeof value.proxy_key_file === "string" && (value.proxy_key_file.startsWith("/") || value.proxy_key_file.startsWith("~/")) && value.proxy_key_file.length <= 1024) {
|
|
1437
1437
|
client.proxy_key_file = value.proxy_key_file;
|
|
1438
1438
|
}
|
|
1439
|
+
if (typeof value.keep_claude_login === "boolean") {
|
|
1440
|
+
client.keep_claude_login = value.keep_claude_login;
|
|
1441
|
+
}
|
|
1439
1442
|
return Object.keys(client).length > 0 ? client : undefined;
|
|
1440
1443
|
}
|
|
1441
1444
|
function sanitizeProviderModels(value) {
|
|
@@ -1526,6 +1529,26 @@ function sanitizeTeamRouting(value) {
|
|
|
1526
1529
|
}
|
|
1527
1530
|
return result;
|
|
1528
1531
|
}
|
|
1532
|
+
function readClientRouting(configPath = resolveConfigPath()) {
|
|
1533
|
+
let data;
|
|
1534
|
+
try {
|
|
1535
|
+
data = JSON.parse(readFileSync(configPath, "utf8"));
|
|
1536
|
+
} catch {
|
|
1537
|
+
throw new Error("Agent Smith client config could not be read");
|
|
1538
|
+
}
|
|
1539
|
+
if (!isRecord(data) || data.client !== undefined && !isRecord(data.client) || isRecord(data.client) && data.client.enabled !== undefined && typeof data.client.enabled !== "boolean") {
|
|
1540
|
+
throw new Error("Agent Smith client config is invalid");
|
|
1541
|
+
}
|
|
1542
|
+
return clientRouting(sanitizeClientRouting(data.client));
|
|
1543
|
+
}
|
|
1544
|
+
function clientRouting(client) {
|
|
1545
|
+
return {
|
|
1546
|
+
enabled: client?.enabled === true,
|
|
1547
|
+
...client?.base_url && { baseUrl: client.base_url },
|
|
1548
|
+
...client?.proxy_key_file && { proxyKeyFile: client.proxy_key_file },
|
|
1549
|
+
...client?.keep_claude_login === true && { keepClaudeLogin: true }
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1529
1552
|
var log2, PROVIDER_STRATEGIES, BUILTIN_PROVIDER_CONFIGS, BUILTIN_PROVIDER_CONFIG_BY_NAME, PROVIDER_NAME_PATTERN, TEAM_ROUTING_DEFAULTS, MAX_ENROLLMENT_EMAILS = 200, MAX_ALERT_VALUE_LENGTH = 512, Config;
|
|
1530
1553
|
var init_src4 = __esm(() => {
|
|
1531
1554
|
init_src2();
|
|
@@ -1728,14 +1751,10 @@ var init_src4 = __esm(() => {
|
|
|
1728
1751
|
};
|
|
1729
1752
|
}
|
|
1730
1753
|
getClientRouting() {
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
...client?.proxy_key_file && {
|
|
1736
|
-
proxyKeyFile: client.proxy_key_file
|
|
1737
|
-
}
|
|
1738
|
-
};
|
|
1754
|
+
return clientRouting(this.data.client);
|
|
1755
|
+
}
|
|
1756
|
+
setClientRoutingEnabled(enabled) {
|
|
1757
|
+
this.persistStrictly("client", { ...this.data.client, enabled });
|
|
1739
1758
|
}
|
|
1740
1759
|
getBlockWhenAllFull() {
|
|
1741
1760
|
return this.data.block_when_all_full !== false;
|
|
@@ -14161,6 +14180,7 @@ import {
|
|
|
14161
14180
|
} from "fs";
|
|
14162
14181
|
import { homedir as homedir2 } from "os";
|
|
14163
14182
|
import { dirname as dirname4, join as join8 } from "path";
|
|
14183
|
+
import { fileURLToPath } from "url";
|
|
14164
14184
|
function shellQuote(value) {
|
|
14165
14185
|
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
14166
14186
|
}
|
|
@@ -14201,14 +14221,22 @@ function proxyKeySetup(proxyKeyFile) {
|
|
|
14201
14221
|
fi
|
|
14202
14222
|
export AGENT_SMITH_PROXY_KEY=$(cat ${shellQuote(proxyKeyFile)})`;
|
|
14203
14223
|
}
|
|
14204
|
-
function
|
|
14224
|
+
function claudeProxyCredential(keepClaudeLogin) {
|
|
14225
|
+
if (!keepClaudeLogin) {
|
|
14226
|
+
return `export ANTHROPIC_API_KEY="$AGENT_SMITH_PROXY_KEY"`;
|
|
14227
|
+
}
|
|
14228
|
+
return `unset ANTHROPIC_API_KEY
|
|
14229
|
+
export ANTHROPIC_CUSTOM_HEADERS="\${ANTHROPIC_CUSTOM_HEADERS:+$ANTHROPIC_CUSTOM_HEADERS
|
|
14230
|
+
}x-api-key: $AGENT_SMITH_PROXY_KEY"`;
|
|
14231
|
+
}
|
|
14232
|
+
function claudeWrapper(claudePath, baseUrl, proxyKeyFile, keepClaudeLogin) {
|
|
14205
14233
|
return `#!/bin/sh
|
|
14206
14234
|
# Generated by agent-smith. This file delegates to the real Claude Code binary.
|
|
14207
14235
|
unset AGENT_SMITH_ADMIN_KEY
|
|
14208
14236
|
unset AGENT_SMITH_PROXY_KEY
|
|
14209
14237
|
unset ANTHROPIC_AUTH_TOKEN
|
|
14210
14238
|
${proxyKeySetup(proxyKeyFile)}
|
|
14211
|
-
|
|
14239
|
+
${claudeProxyCredential(keepClaudeLogin)}
|
|
14212
14240
|
unset AGENT_SMITH_PROXY_KEY
|
|
14213
14241
|
export ANTHROPIC_BASE_URL=${shellQuote(baseUrl)}
|
|
14214
14242
|
exec ${shellQuote(claudePath)} "$@"
|
|
@@ -14236,6 +14264,26 @@ ${overrides} \\
|
|
|
14236
14264
|
`;
|
|
14237
14265
|
}
|
|
14238
14266
|
async function installClientWrappers(options) {
|
|
14267
|
+
if (options.clientConfigPath) {
|
|
14268
|
+
const launcher = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "./client-launcher.ts" : "./client-launcher.js", import.meta.url));
|
|
14269
|
+
mkdirSync4(options.binDir, { recursive: true, mode: 448 });
|
|
14270
|
+
for (const [tool, target] of [
|
|
14271
|
+
["claude", options.claudePath],
|
|
14272
|
+
["codex", options.codexPath]
|
|
14273
|
+
]) {
|
|
14274
|
+
if (!target)
|
|
14275
|
+
continue;
|
|
14276
|
+
if (target === join8(options.binDir, tool))
|
|
14277
|
+
throw new Error("A client launcher cannot call itself");
|
|
14278
|
+
const wrapper = join8(options.binDir, tool);
|
|
14279
|
+
writeFileSync2(wrapper, `#!/bin/sh
|
|
14280
|
+
${CONFIG_CLIENT_MARKER}
|
|
14281
|
+
exec ${[process.execPath, launcher, options.clientConfigPath, tool, target].map(shellQuote).join(" ")} "$@"
|
|
14282
|
+
`, { encoding: "utf8", mode: 448 });
|
|
14283
|
+
chmodSync2(wrapper, 448);
|
|
14284
|
+
}
|
|
14285
|
+
return;
|
|
14286
|
+
}
|
|
14239
14287
|
if (options.baseUrl && !options.proxyKeyFile) {
|
|
14240
14288
|
throw new Error("A configured Agent Smith server requires a forwarding key file");
|
|
14241
14289
|
}
|
|
@@ -14243,7 +14291,7 @@ async function installClientWrappers(options) {
|
|
|
14243
14291
|
const proxyKeyFile = options.proxyKeyFile ? validateProxyKeyFile(options.proxyKeyFile) : undefined;
|
|
14244
14292
|
if (options.claudePath) {
|
|
14245
14293
|
const claude = join8(options.binDir, "claude");
|
|
14246
|
-
writeFileSync2(claude, claudeWrapper(options.claudePath, proxyBaseUrl(options.port, options.baseUrl, "claude-code", "anthropic-messages", options.providerPoolWires), proxyKeyFile), {
|
|
14294
|
+
writeFileSync2(claude, claudeWrapper(options.claudePath, proxyBaseUrl(options.port, options.baseUrl, "claude-code", "anthropic-messages", options.providerPoolWires), proxyKeyFile, options.keepClaudeLogin === true), {
|
|
14247
14295
|
encoding: "utf8",
|
|
14248
14296
|
mode: 448
|
|
14249
14297
|
});
|
|
@@ -14304,7 +14352,7 @@ function readSavedClientPaths(statePath) {
|
|
|
14304
14352
|
} catch {}
|
|
14305
14353
|
return null;
|
|
14306
14354
|
}
|
|
14307
|
-
function
|
|
14355
|
+
function installedRoutingStatus(paths2 = {}) {
|
|
14308
14356
|
const defaults = getLocalRoutingPaths();
|
|
14309
14357
|
const binDir = paths2.binDir ?? defaults.binDir;
|
|
14310
14358
|
const shellProfile = paths2.shellProfile ?? defaults.shellProfile;
|
|
@@ -14318,6 +14366,58 @@ function getLocalRoutingStatus(paths2 = {}) {
|
|
|
14318
14366
|
shellProfile
|
|
14319
14367
|
};
|
|
14320
14368
|
}
|
|
14369
|
+
function getLocalRoutingStatus(paths2 = {}) {
|
|
14370
|
+
const status = installedRoutingStatus(paths2);
|
|
14371
|
+
if (!configClientWrappersInstalled(paths2))
|
|
14372
|
+
return status;
|
|
14373
|
+
try {
|
|
14374
|
+
return { ...status, enabled: readClientRouting().enabled };
|
|
14375
|
+
} catch {
|
|
14376
|
+
return { ...status, enabled: false };
|
|
14377
|
+
}
|
|
14378
|
+
}
|
|
14379
|
+
function configClientWrappersInstalled(paths2 = {}) {
|
|
14380
|
+
const binDir = paths2.binDir ?? getLocalRoutingPaths().binDir;
|
|
14381
|
+
const files = ["claude", "codex"].map((name) => join8(binDir, name)).filter(existsSync3);
|
|
14382
|
+
return installedRoutingStatus(paths2).enabled && files.length > 0 && files.every((path) => readFileSync4(path, "utf8").includes(CONFIG_CLIENT_MARKER));
|
|
14383
|
+
}
|
|
14384
|
+
async function launchConfiguredClient(configPath, tool, target, args) {
|
|
14385
|
+
if (tool !== "claude" && tool !== "codex")
|
|
14386
|
+
throw new Error("Unknown Agent Smith client");
|
|
14387
|
+
const client2 = readClientRouting(configPath);
|
|
14388
|
+
const env = { ...process.env };
|
|
14389
|
+
delete env.AGENT_SMITH_ADMIN_KEY;
|
|
14390
|
+
delete env.AGENT_SMITH_PROXY_KEY;
|
|
14391
|
+
let command = [target, ...args];
|
|
14392
|
+
if (client2.enabled) {
|
|
14393
|
+
if (!client2.baseUrl || !client2.proxyKeyFile)
|
|
14394
|
+
throw new Error("client.base_url and client.proxy_key_file are required");
|
|
14395
|
+
const keyFile = validateProxyKeyFile(client2.proxyKeyFile);
|
|
14396
|
+
const wires = Object.keys(new Config(configPath).getProviderPools());
|
|
14397
|
+
const base = proxyBaseUrl(8080, client2.baseUrl, tool === "claude" ? "claude-code" : "codex", tool === "claude" ? "anthropic-messages" : "openai-responses", wires);
|
|
14398
|
+
const script = tool === "claude" ? claudeWrapper(target, base, keyFile, client2.keepClaudeLogin === true) : codexWrapper(target, base, keyFile);
|
|
14399
|
+
command = ["/bin/sh", "-c", script, "--", ...args];
|
|
14400
|
+
}
|
|
14401
|
+
const child = Bun.spawn(command, {
|
|
14402
|
+
env,
|
|
14403
|
+
stdin: "inherit",
|
|
14404
|
+
stdout: "inherit",
|
|
14405
|
+
stderr: "inherit"
|
|
14406
|
+
});
|
|
14407
|
+
const forward = {
|
|
14408
|
+
SIGINT: () => child.kill("SIGINT"),
|
|
14409
|
+
SIGTERM: () => child.kill("SIGTERM"),
|
|
14410
|
+
SIGHUP: () => child.kill("SIGHUP")
|
|
14411
|
+
};
|
|
14412
|
+
for (const [signal, listener] of Object.entries(forward))
|
|
14413
|
+
process.on(signal, listener);
|
|
14414
|
+
try {
|
|
14415
|
+
return await child.exited;
|
|
14416
|
+
} finally {
|
|
14417
|
+
for (const [signal, listener] of Object.entries(forward))
|
|
14418
|
+
process.off(signal, listener);
|
|
14419
|
+
}
|
|
14420
|
+
}
|
|
14321
14421
|
async function enableLocalClientRouting(options) {
|
|
14322
14422
|
const defaults = getLocalRoutingPaths();
|
|
14323
14423
|
const binDir = options.binDir ?? defaults.binDir;
|
|
@@ -14344,7 +14444,9 @@ async function enableLocalClientRouting(options) {
|
|
|
14344
14444
|
port: options.port,
|
|
14345
14445
|
baseUrl: options.baseUrl,
|
|
14346
14446
|
proxyKeyFile: options.proxyKeyFile,
|
|
14347
|
-
|
|
14447
|
+
keepClaudeLogin: options.keepClaudeLogin,
|
|
14448
|
+
clientConfigPath: options.clientConfigPath,
|
|
14449
|
+
providerPoolWires: options.providerPoolWires ?? (options.clientConfigPath ? [] : Object.keys(new Config().getProviderPools()))
|
|
14348
14450
|
});
|
|
14349
14451
|
const existingProfile = existsSync3(shellProfile) ? readFileSync4(shellProfile, "utf8") : "";
|
|
14350
14452
|
writeFileSync2(shellProfile, updateShellProfileForRouting(existingProfile, binDir), { encoding: "utf8", mode: 384 });
|
|
@@ -14395,7 +14497,7 @@ export PATH=${shellDoubleQuote(`${binDir}:$PATH`)}
|
|
|
14395
14497
|
${ROUTING_END}
|
|
14396
14498
|
`;
|
|
14397
14499
|
}
|
|
14398
|
-
var ROUTING_BEGIN = "# >>> agent-smith local routing >>>", ROUTING_END = "# <<< agent-smith local routing <<<", LOCAL_CLIENT_KEY = "agent-smith-local";
|
|
14500
|
+
var ROUTING_BEGIN = "# >>> agent-smith local routing >>>", ROUTING_END = "# <<< agent-smith local routing <<<", LOCAL_CLIENT_KEY = "agent-smith-local", CONFIG_CLIENT_MARKER = "# agent-smith config-driven client";
|
|
14399
14501
|
var init_local_routing = __esm(() => {
|
|
14400
14502
|
init_src4();
|
|
14401
14503
|
});
|
|
@@ -14603,6 +14705,58 @@ var init_core = __esm(() => {
|
|
|
14603
14705
|
init_strategy3();
|
|
14604
14706
|
});
|
|
14605
14707
|
|
|
14708
|
+
// src/core/client-command.ts
|
|
14709
|
+
import { existsSync as existsSync4 } from "fs";
|
|
14710
|
+
import { parseArgs as parseArgs2 } from "util";
|
|
14711
|
+
async function runClientCommand(argv) {
|
|
14712
|
+
const { positionals, values } = parseArgs2({
|
|
14713
|
+
args: argv,
|
|
14714
|
+
options: { raw: { type: "boolean" } },
|
|
14715
|
+
allowPositionals: true,
|
|
14716
|
+
strict: true
|
|
14717
|
+
});
|
|
14718
|
+
const [command] = positionals;
|
|
14719
|
+
if (positionals.length !== 1 || !["on", "off", "status"].includes(command ?? ""))
|
|
14720
|
+
throw new Error("usage: agent-smith client on|off|status [--raw]");
|
|
14721
|
+
const configPath = resolveConfigPath();
|
|
14722
|
+
const client2 = existsSync4(configPath) ? readClientRouting(configPath) : { enabled: false };
|
|
14723
|
+
let installed = configClientWrappersInstalled();
|
|
14724
|
+
if (command !== "status") {
|
|
14725
|
+
const enabled = command === "on";
|
|
14726
|
+
if (enabled) {
|
|
14727
|
+
if (!client2.baseUrl || !client2.proxyKeyFile)
|
|
14728
|
+
throw new Error("Set client.base_url and client.proxy_key_file before enabling the pool");
|
|
14729
|
+
validateProxyKeyFile(client2.proxyKeyFile);
|
|
14730
|
+
}
|
|
14731
|
+
if (!installed && (enabled || getLocalRoutingStatus().enabled)) {
|
|
14732
|
+
await enableLocalClientRouting({
|
|
14733
|
+
port: 8080,
|
|
14734
|
+
clientConfigPath: configPath
|
|
14735
|
+
});
|
|
14736
|
+
installed = true;
|
|
14737
|
+
}
|
|
14738
|
+
new Config(configPath).setClientRoutingEnabled(enabled);
|
|
14739
|
+
client2.enabled = enabled;
|
|
14740
|
+
}
|
|
14741
|
+
const status = {
|
|
14742
|
+
enabled: client2.enabled,
|
|
14743
|
+
installed,
|
|
14744
|
+
...client2.baseUrl && { baseUrl: client2.baseUrl }
|
|
14745
|
+
};
|
|
14746
|
+
if (values.raw)
|
|
14747
|
+
console.log(JSON.stringify(status));
|
|
14748
|
+
else {
|
|
14749
|
+
console.log(`Shared pool: ${status.enabled ? "on" : "off"}`);
|
|
14750
|
+
console.log(`Launchers: ${installed ? "installed" : "not configured; use client on to set up"}`);
|
|
14751
|
+
if (command !== "status")
|
|
14752
|
+
console.log("Restart existing Claude/Codex sessions to use this setting. After first setup, open a new terminal.");
|
|
14753
|
+
}
|
|
14754
|
+
}
|
|
14755
|
+
var init_client_command = __esm(() => {
|
|
14756
|
+
init_src4();
|
|
14757
|
+
init_local_routing();
|
|
14758
|
+
});
|
|
14759
|
+
|
|
14606
14760
|
// src/poc-notice.ts
|
|
14607
14761
|
var POC_BANNER = "PROOF OF CONCEPT \xB7 read the README before enabling sign-ins", POC_NOTICE = `\u26A0 PROOF OF CONCEPT, FOR IDEATION ONLY
|
|
14608
14762
|
agent-smith is an experiment, not a product: no warranty and no support.
|
|
@@ -14622,12 +14776,12 @@ __export(exports_theme, {
|
|
|
14622
14776
|
NAV_ITEMS: () => NAV_ITEMS,
|
|
14623
14777
|
C: () => C
|
|
14624
14778
|
});
|
|
14625
|
-
import { existsSync as
|
|
14779
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
14626
14780
|
import { homedir as homedir3 } from "os";
|
|
14627
14781
|
import { join as join9 } from "path";
|
|
14628
14782
|
function loadPersistedThemeId() {
|
|
14629
14783
|
try {
|
|
14630
|
-
if (
|
|
14784
|
+
if (existsSync5(CONFIG_FILE)) {
|
|
14631
14785
|
const data = JSON.parse(readFileSync5(CONFIG_FILE, "utf-8"));
|
|
14632
14786
|
if (data?.themeId && getThemeById(data.themeId)) {
|
|
14633
14787
|
return data.themeId;
|
|
@@ -14638,7 +14792,7 @@ function loadPersistedThemeId() {
|
|
|
14638
14792
|
}
|
|
14639
14793
|
function persistThemeId(themeId) {
|
|
14640
14794
|
try {
|
|
14641
|
-
if (!
|
|
14795
|
+
if (!existsSync5(CONFIG_DIR)) {
|
|
14642
14796
|
mkdirSync5(CONFIG_DIR, { recursive: true });
|
|
14643
14797
|
}
|
|
14644
14798
|
writeFileSync3(CONFIG_FILE, JSON.stringify({ themeId }), "utf-8");
|
|
@@ -18067,6 +18221,10 @@ Accounts:`);
|
|
|
18067
18221
|
}
|
|
18068
18222
|
}
|
|
18069
18223
|
async function main() {
|
|
18224
|
+
if (process.argv[2] === "client") {
|
|
18225
|
+
await runClientCommand(process.argv.slice(3));
|
|
18226
|
+
return;
|
|
18227
|
+
}
|
|
18070
18228
|
container.registerInstance(SERVICE_KEYS.Config, new Config);
|
|
18071
18229
|
container.registerInstance(SERVICE_KEYS.Logger, new Logger("TUI"));
|
|
18072
18230
|
DatabaseFactory.initialize();
|
|
@@ -18083,6 +18241,7 @@ ${POC_NOTICE}
|
|
|
18083
18241
|
Usage: agent-smith [options]
|
|
18084
18242
|
agent-smith run [--port <number>] -- [claude arguments]
|
|
18085
18243
|
agent-smith install-client
|
|
18244
|
+
agent-smith client on|off|status [--raw]
|
|
18086
18245
|
|
|
18087
18246
|
Options:
|
|
18088
18247
|
--serve Start API server with dashboard
|
|
@@ -18139,7 +18298,9 @@ Examples:
|
|
|
18139
18298
|
await enableLocalClientRouting({
|
|
18140
18299
|
port: port2,
|
|
18141
18300
|
baseUrl: client2.baseUrl,
|
|
18142
|
-
proxyKeyFile: client2.proxyKeyFile
|
|
18301
|
+
proxyKeyFile: client2.proxyKeyFile,
|
|
18302
|
+
keepClaudeLogin: client2.keepClaudeLogin,
|
|
18303
|
+
clientConfigPath: resolveConfigPath()
|
|
18143
18304
|
});
|
|
18144
18305
|
console.log(`Client wrappers configured for ${client2.baseUrl}.`);
|
|
18145
18306
|
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.");
|
|
@@ -18271,6 +18432,7 @@ var init_main = __esm(() => {
|
|
|
18271
18432
|
init_src11();
|
|
18272
18433
|
init_core();
|
|
18273
18434
|
init_core();
|
|
18435
|
+
init_client_command();
|
|
18274
18436
|
main().catch(async (error) => {
|
|
18275
18437
|
console.error("Error:", error.message);
|
|
18276
18438
|
try {
|