@certalis/agent-smith 0.1.6 → 0.1.7

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 CHANGED
@@ -85,28 +85,24 @@ startServer({
85
85
 
86
86
  Codex works the same way with an OpenAI API key and an `openai-responses` pool.
87
87
 
88
- ## Connect an authorized development caller through SSH
88
+ ## Connect an authorized caller to a private shared pool
89
89
 
90
- The agents box and a development laptop both send requests to one proxy with a
91
- forwarding key. A laptop can reach a private server through an SSH tunnel in
92
- v1.
90
+ The agents service and a laptop can send requests to one proxy with a
91
+ forwarding key. Put the server and callers on a private network first; the
92
+ recommended WireGuard shape is documented in the
93
+ [private-network guide](docs/private-network.md). It keeps the database and
94
+ provider tokens on the server, and exposes the proxy only on the private
95
+ network.
93
96
 
94
97
  This is connectivity only, not team tenancy: the shared forwarding key does
95
98
  not identify an individual caller or enforce per-client fairness. Do not
96
99
  distribute it team-wide until the B2/W7 tenancy work exists.
97
100
 
98
- Copy [`team-client.json`](examples/config/team-client.json) into your private
99
- Agent-smith config. Put the forwarding key in the owner-only file named by
100
- `proxy_key_file`, not in the JSON or a shell profile. `base_url` is the endpoint
101
- visible to your machine, not a second pool. The key can spend from the pool, but
102
- cannot administer it.
103
-
104
- For an SSH tunnel, forward a local port to the private server and leave that SSH
105
- session running:
106
-
107
- ```bash
108
- ssh -N -L 18181:127.0.0.1:8080 agent-smith-pool
109
- ```
101
+ Copy [`private-network-client.json`](examples/config/private-network-client.json)
102
+ into your private Agent-smith config. Put the forwarding key in the owner-only
103
+ file named by `proxy_key_file`, not in the JSON or a shell profile. `base_url`
104
+ is the private endpoint visible to that machine, not a second pool. The key can
105
+ spend from the pool, but cannot administer it.
110
106
 
111
107
  Then install the normal `claude` and `codex` wrappers once:
112
108
 
@@ -116,8 +112,9 @@ agent-smith install-client
116
112
 
117
113
  Open a new terminal and use `claude` or `codex` normally. The wrappers only add
118
114
  their own marked `PATH` entry; they do not replace the real binaries or start a
119
- second proxy. The forwarding key is for inference, not dashboard or management
120
- access.
115
+ second proxy. Edit the `client` section and rerun `agent-smith install-client`
116
+ when the private address changes; do not hand-edit the generated wrappers. The
117
+ forwarding key is for inference, not dashboard or management access.
121
118
 
122
119
  ## Configuration
123
120
 
@@ -193,14 +190,14 @@ to `acme` and are sent as `acme-large`. `acme` serves no other model.
193
190
  ```
194
191
 
195
192
  **A laptop using a private shared pool**
196
- ([`team-client.json`](examples/config/team-client.json)). The example uses an
197
- SSH-local port; use the direct private origin instead on a host that can reach
198
- the pool without SSH.
193
+ ([`private-network-client.json`](examples/config/private-network-client.json)).
194
+ The address is reachable only through the private network described in the
195
+ [deployment guide](docs/private-network.md).
199
196
 
200
197
  ```json
201
198
  {
202
199
  "client": {
203
- "base_url": "http://127.0.0.1:18181",
200
+ "base_url": "http://10.76.0.1:8080",
204
201
  "proxy_key_file": "~/.config/ccflare/team-pool.key"
205
202
  }
206
203
  }
package/dist/bin.js CHANGED
@@ -11684,12 +11684,24 @@ function requestAddress(server, req) {
11684
11684
  function configuredKey(value) {
11685
11685
  return typeof value === "string" && value.length > 0 ? value : undefined;
11686
11686
  }
11687
+ function configuredBindHosts(value) {
11688
+ if (value === undefined)
11689
+ return;
11690
+ const bindHosts = [
11691
+ ...new Set(value.split(",").map((host) => host.trim()).filter(Boolean))
11692
+ ];
11693
+ return bindHosts.length > 0 ? bindHosts : undefined;
11694
+ }
11687
11695
  function createExposureConfig(config) {
11688
11696
  const configuredHost = configuredKey(process.env.CF_HOST) ?? configuredKey(config.get("host"));
11697
+ const bindHosts = configuredBindHosts(process.env.CF_BIND_HOSTS) ?? [
11698
+ configuredHost ?? "127.0.0.1"
11699
+ ];
11689
11700
  const configuredTrustLoopback = process.env.CF_TRUST_LOOPBACK;
11690
11701
  return {
11691
11702
  adminKey: configuredKey(process.env.CF_ADMIN_KEY),
11692
- bindHost: configuredHost ?? "127.0.0.1",
11703
+ bindHost: bindHosts[0],
11704
+ bindHosts,
11693
11705
  proxyKey: configuredKey(process.env.CF_PROXY_KEY),
11694
11706
  trustLoopback: configuredTrustLoopback === undefined ? config.get("trust_loopback") !== false : configuredTrustLoopback !== "false"
11695
11707
  };
@@ -11741,7 +11753,7 @@ function hostnameFromHostHeader(host) {
11741
11753
  function isWildcardHost(host) {
11742
11754
  return host === "0.0.0.0" || host === "::";
11743
11755
  }
11744
- function isLocalHostHeader(hostHeader, bindHost) {
11756
+ function isLocalHostHeader(hostHeader, bindHosts) {
11745
11757
  if (hostHeader === null) {
11746
11758
  return true;
11747
11759
  }
@@ -11749,7 +11761,8 @@ function isLocalHostHeader(hostHeader, bindHost) {
11749
11761
  if (!hostname) {
11750
11762
  return false;
11751
11763
  }
11752
- return LOOPBACK_HOSTS.has(hostname) || !isWildcardHost(bindHost) && hostname === bindHost.toLowerCase();
11764
+ const configuredHosts = typeof bindHosts === "string" ? [bindHosts] : bindHosts;
11765
+ return LOOPBACK_HOSTS.has(hostname) || configuredHosts.some((bindHost) => !isWildcardHost(bindHost) && hostname === bindHost.toLowerCase());
11753
11766
  }
11754
11767
  function isSameOriginManagementRequest(req, url) {
11755
11768
  const fetchSite = req.headers.get("sec-fetch-site");
@@ -11764,12 +11777,12 @@ function jsonError(status, message) {
11764
11777
  }
11765
11778
  function exposureFailure(req, url, server, config) {
11766
11779
  const remote = requestAddress(server, req);
11767
- const loopbackExempt = config.trustLoopback && (remote.hasRequestIp ? isLoopbackAddress(remote.address) : isLocalHostHeader(url.host, config.bindHost)) && !isForwardedRequest(req.headers);
11780
+ const loopbackExempt = config.trustLoopback && (remote.hasRequestIp ? isLoopbackAddress(remote.address) : isLocalHostHeader(url.host, config.bindHosts)) && !isForwardedRequest(req.headers);
11768
11781
  const role = keyRole(req, url, config);
11769
11782
  if (!role && !loopbackExempt) {
11770
11783
  return jsonError(401, "A proxy key is required for this request");
11771
11784
  }
11772
- if (!role && !isLocalHostHeader(req.headers.get("host"), config.bindHost)) {
11785
+ if (!role && !isLocalHostHeader(req.headers.get("host"), config.bindHosts)) {
11773
11786
  return jsonError(403, "Host header is not allowed for a loopback request");
11774
11787
  }
11775
11788
  if (url.pathname.startsWith("/api/")) {
@@ -12053,6 +12066,7 @@ function createServerFetchHandler({
12053
12066
  withDashboard,
12054
12067
  exposureConfig = {
12055
12068
  bindHost: "127.0.0.1",
12069
+ bindHosts: ["127.0.0.1"],
12056
12070
  trustLoopback: true
12057
12071
  },
12058
12072
  handleProxyRequest = handleProxy,
@@ -12199,8 +12213,10 @@ async function stopServerRuntime() {
12199
12213
  serverStopPromise = (async () => {
12200
12214
  const errors2 = [];
12201
12215
  const activeServer = serverInstance;
12216
+ const activeAdditionalServers = additionalServerInstances;
12202
12217
  const activeUnixServer = unixServerInstance;
12203
12218
  serverInstance = null;
12219
+ additionalServerInstances = [];
12204
12220
  unixServerInstance = null;
12205
12221
  try {
12206
12222
  await activeUnixServer?.stop(true);
@@ -12212,6 +12228,13 @@ async function stopServerRuntime() {
12212
12228
  } catch (error) {
12213
12229
  errors2.push(toError("Failed to stop Bun server", error));
12214
12230
  }
12231
+ for (const [index, server] of activeAdditionalServers.entries()) {
12232
+ try {
12233
+ await server.stop(true);
12234
+ } catch (error) {
12235
+ errors2.push(toError(`Failed to stop additional Bun server ${index + 1}`, error));
12236
+ }
12237
+ }
12215
12238
  stopRetentionMaintenance();
12216
12239
  try {
12217
12240
  await waitForProxyBackgroundTasks();
@@ -12290,6 +12313,16 @@ function startServer(options) {
12290
12313
  fetch: fetchHandler,
12291
12314
  websocket: websocketProxyHandler
12292
12315
  });
12316
+ const activePort2 = serverInstance.port ?? runtimeConfig2.port;
12317
+ for (const hostname of exposureConfig.bindHosts.slice(1)) {
12318
+ additionalServerInstances.push(serve({
12319
+ hostname,
12320
+ port: activePort2,
12321
+ idleTimeout: NETWORK.IDLE_TIMEOUT_MAX,
12322
+ fetch: fetchHandler,
12323
+ websocket: websocketProxyHandler
12324
+ }));
12325
+ }
12293
12326
  } catch (error) {
12294
12327
  stopServerRuntime().catch(() => {
12295
12328
  lifecycleLog.error("Failed to clean up after listener startup failure");
@@ -12325,7 +12358,7 @@ async function handleGracefulShutdown(signal) {
12325
12358
  process.exit(1);
12326
12359
  }
12327
12360
  }
12328
- var serverLog, lifecycleLog, serverInstance = null, unixServerInstance = null, stopRetentionJob = null, serverStopPromise = null;
12361
+ var serverLog, lifecycleLog, serverInstance = null, additionalServerInstances, unixServerInstance = null, stopRetentionJob = null, serverStopPromise = null;
12329
12362
  var init_src11 = __esm(() => {
12330
12363
  init_src9();
12331
12364
  init_src2();
@@ -12343,6 +12376,7 @@ var init_src11 = __esm(() => {
12343
12376
  lifecycleLog = new Logger("ServerLifecycle", 1 /* INFO */, {
12344
12377
  silentConsole: false
12345
12378
  });
12379
+ additionalServerInstances = [];
12346
12380
  process.on("SIGINT", () => handleGracefulShutdown("SIGINT"));
12347
12381
  process.on("SIGTERM", () => handleGracefulShutdown("SIGTERM"));
12348
12382
  if (false) {}
package/dist/server.js CHANGED
@@ -11683,12 +11683,24 @@ function requestAddress(server, req) {
11683
11683
  function configuredKey(value) {
11684
11684
  return typeof value === "string" && value.length > 0 ? value : undefined;
11685
11685
  }
11686
+ function configuredBindHosts(value) {
11687
+ if (value === undefined)
11688
+ return;
11689
+ const bindHosts = [
11690
+ ...new Set(value.split(",").map((host) => host.trim()).filter(Boolean))
11691
+ ];
11692
+ return bindHosts.length > 0 ? bindHosts : undefined;
11693
+ }
11686
11694
  function createExposureConfig(config) {
11687
11695
  const configuredHost = configuredKey(process.env.CF_HOST) ?? configuredKey(config.get("host"));
11696
+ const bindHosts = configuredBindHosts(process.env.CF_BIND_HOSTS) ?? [
11697
+ configuredHost ?? "127.0.0.1"
11698
+ ];
11688
11699
  const configuredTrustLoopback = process.env.CF_TRUST_LOOPBACK;
11689
11700
  return {
11690
11701
  adminKey: configuredKey(process.env.CF_ADMIN_KEY),
11691
- bindHost: configuredHost ?? "127.0.0.1",
11702
+ bindHost: bindHosts[0],
11703
+ bindHosts,
11692
11704
  proxyKey: configuredKey(process.env.CF_PROXY_KEY),
11693
11705
  trustLoopback: configuredTrustLoopback === undefined ? config.get("trust_loopback") !== false : configuredTrustLoopback !== "false"
11694
11706
  };
@@ -11740,7 +11752,7 @@ function hostnameFromHostHeader(host) {
11740
11752
  function isWildcardHost(host) {
11741
11753
  return host === "0.0.0.0" || host === "::";
11742
11754
  }
11743
- function isLocalHostHeader(hostHeader, bindHost) {
11755
+ function isLocalHostHeader(hostHeader, bindHosts) {
11744
11756
  if (hostHeader === null) {
11745
11757
  return true;
11746
11758
  }
@@ -11748,7 +11760,8 @@ function isLocalHostHeader(hostHeader, bindHost) {
11748
11760
  if (!hostname) {
11749
11761
  return false;
11750
11762
  }
11751
- return LOOPBACK_HOSTS.has(hostname) || !isWildcardHost(bindHost) && hostname === bindHost.toLowerCase();
11763
+ const configuredHosts = typeof bindHosts === "string" ? [bindHosts] : bindHosts;
11764
+ return LOOPBACK_HOSTS.has(hostname) || configuredHosts.some((bindHost) => !isWildcardHost(bindHost) && hostname === bindHost.toLowerCase());
11752
11765
  }
11753
11766
  function isSameOriginManagementRequest(req, url) {
11754
11767
  const fetchSite = req.headers.get("sec-fetch-site");
@@ -11763,12 +11776,12 @@ function jsonError(status, message) {
11763
11776
  }
11764
11777
  function exposureFailure(req, url, server, config) {
11765
11778
  const remote = requestAddress(server, req);
11766
- const loopbackExempt = config.trustLoopback && (remote.hasRequestIp ? isLoopbackAddress(remote.address) : isLocalHostHeader(url.host, config.bindHost)) && !isForwardedRequest(req.headers);
11779
+ const loopbackExempt = config.trustLoopback && (remote.hasRequestIp ? isLoopbackAddress(remote.address) : isLocalHostHeader(url.host, config.bindHosts)) && !isForwardedRequest(req.headers);
11767
11780
  const role = keyRole(req, url, config);
11768
11781
  if (!role && !loopbackExempt) {
11769
11782
  return jsonError(401, "A proxy key is required for this request");
11770
11783
  }
11771
- if (!role && !isLocalHostHeader(req.headers.get("host"), config.bindHost)) {
11784
+ if (!role && !isLocalHostHeader(req.headers.get("host"), config.bindHosts)) {
11772
11785
  return jsonError(403, "Host header is not allowed for a loopback request");
11773
11786
  }
11774
11787
  if (url.pathname.startsWith("/api/")) {
@@ -12052,6 +12065,7 @@ function createServerFetchHandler({
12052
12065
  withDashboard,
12053
12066
  exposureConfig = {
12054
12067
  bindHost: "127.0.0.1",
12068
+ bindHosts: ["127.0.0.1"],
12055
12069
  trustLoopback: true
12056
12070
  },
12057
12071
  handleProxyRequest = handleProxy,
@@ -12198,8 +12212,10 @@ async function stopServerRuntime() {
12198
12212
  serverStopPromise = (async () => {
12199
12213
  const errors2 = [];
12200
12214
  const activeServer = serverInstance;
12215
+ const activeAdditionalServers = additionalServerInstances;
12201
12216
  const activeUnixServer = unixServerInstance;
12202
12217
  serverInstance = null;
12218
+ additionalServerInstances = [];
12203
12219
  unixServerInstance = null;
12204
12220
  try {
12205
12221
  await activeUnixServer?.stop(true);
@@ -12211,6 +12227,13 @@ async function stopServerRuntime() {
12211
12227
  } catch (error) {
12212
12228
  errors2.push(toError("Failed to stop Bun server", error));
12213
12229
  }
12230
+ for (const [index, server] of activeAdditionalServers.entries()) {
12231
+ try {
12232
+ await server.stop(true);
12233
+ } catch (error) {
12234
+ errors2.push(toError(`Failed to stop additional Bun server ${index + 1}`, error));
12235
+ }
12236
+ }
12214
12237
  stopRetentionMaintenance();
12215
12238
  try {
12216
12239
  await waitForProxyBackgroundTasks();
@@ -12289,6 +12312,16 @@ function startServer(options) {
12289
12312
  fetch: fetchHandler,
12290
12313
  websocket: websocketProxyHandler
12291
12314
  });
12315
+ const activePort2 = serverInstance.port ?? runtimeConfig2.port;
12316
+ for (const hostname of exposureConfig.bindHosts.slice(1)) {
12317
+ additionalServerInstances.push(serve({
12318
+ hostname,
12319
+ port: activePort2,
12320
+ idleTimeout: NETWORK.IDLE_TIMEOUT_MAX,
12321
+ fetch: fetchHandler,
12322
+ websocket: websocketProxyHandler
12323
+ }));
12324
+ }
12292
12325
  } catch (error) {
12293
12326
  stopServerRuntime().catch(() => {
12294
12327
  lifecycleLog.error("Failed to clean up after listener startup failure");
@@ -12324,7 +12357,7 @@ async function handleGracefulShutdown(signal) {
12324
12357
  process.exit(1);
12325
12358
  }
12326
12359
  }
12327
- var serverLog, lifecycleLog, serverInstance = null, unixServerInstance = null, stopRetentionJob = null, serverStopPromise = null;
12360
+ var serverLog, lifecycleLog, serverInstance = null, additionalServerInstances, unixServerInstance = null, stopRetentionJob = null, serverStopPromise = null;
12328
12361
  var init_src11 = __esm(() => {
12329
12362
  init_src9();
12330
12363
  init_src2();
@@ -12342,6 +12375,7 @@ var init_src11 = __esm(() => {
12342
12375
  lifecycleLog = new Logger("ServerLifecycle", 1 /* INFO */, {
12343
12376
  silentConsole: false
12344
12377
  });
12378
+ additionalServerInstances = [];
12345
12379
  process.on("SIGINT", () => handleGracefulShutdown("SIGINT"));
12346
12380
  process.on("SIGTERM", () => handleGracefulShutdown("SIGTERM"));
12347
12381
  if (false) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certalis/agent-smith",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
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",