@blogic-cz/agent-tools 0.4.1 → 0.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogic-cz/agent-tools",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "CLI tools for AI coding agent workflows — GitHub, database, Kubernetes, Azure DevOps, logs, and sessions",
5
5
  "keywords": [
6
6
  "agent",
@@ -17,6 +17,21 @@ import { detectSchemaError, isValidTableName, isMutationQuery } from "./security
17
17
 
18
18
  const LOCALHOST_HOSTS = new Set(["localhost", "127.0.0.1"]);
19
19
 
20
+ export function resolveDbAccessMode(
21
+ env: string,
22
+ host: string,
23
+ hasKubectlConfig: boolean,
24
+ ): Pick<DbConfig, "allowMutations" | "host" | "needsTunnel"> {
25
+ const isLocalHost = LOCALHOST_HOSTS.has(host);
26
+ const isLocalEnvironment = env === "local";
27
+
28
+ return {
29
+ host,
30
+ needsTunnel: hasKubectlConfig && !isLocalEnvironment && isLocalHost,
31
+ allowMutations: isLocalEnvironment,
32
+ };
33
+ }
34
+
20
35
  export class DbService extends ServiceMap.Service<
21
36
  DbService,
22
37
  {
@@ -506,19 +521,21 @@ export class DbService extends ServiceMap.Service<
506
521
  throw new Error(`Unknown environment "${env}". Available: ${available}`);
507
522
  }
508
523
 
509
- const isLocal = LOCALHOST_HOSTS.has(envConfig.host);
510
- const isLocalEnvironment = env === "local";
511
- const needsTunnel = dbConfig.kubectl !== undefined && !isLocalEnvironment && isLocal;
524
+ const accessMode = resolveDbAccessMode(
525
+ env,
526
+ envConfig.host,
527
+ dbConfig.kubectl !== undefined,
528
+ );
512
529
 
513
530
  return {
514
- host: envConfig.host,
531
+ host: accessMode.host,
515
532
  user: envConfig.user,
516
533
  database: envConfig.database,
517
534
  password: envConfig.password,
518
535
  passwordEnvVar: envConfig.passwordEnvVar,
519
536
  port: envConfig.port,
520
- needsTunnel,
521
- allowMutations: isLocalEnvironment,
537
+ needsTunnel: accessMode.needsTunnel,
538
+ allowMutations: accessMode.allowMutations,
522
539
  };
523
540
  };
524
541