@blogic-cz/agent-tools 0.15.13 → 0.16.0

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.
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
 
3
- export class LogsNotFoundError extends Schema.TaggedErrorClass<LogsNotFoundError>()(
3
+ export class LogsNotFoundError extends Schema.TaggedError<LogsNotFoundError>()(
4
4
  "LogsNotFoundError",
5
5
  {
6
6
  message: Schema.String,
@@ -11,7 +11,7 @@ export class LogsNotFoundError extends Schema.TaggedErrorClass<LogsNotFoundError
11
11
  },
12
12
  ) {}
13
13
 
14
- export class LogsReadError extends Schema.TaggedErrorClass<LogsReadError>()("LogsReadError", {
14
+ export class LogsReadError extends Schema.TaggedError<LogsReadError>()("LogsReadError", {
15
15
  message: Schema.String,
16
16
  source: Schema.String,
17
17
  hint: Schema.optionalKey(Schema.String),
@@ -19,23 +19,20 @@ export class LogsReadError extends Schema.TaggedErrorClass<LogsReadError>()("Log
19
19
  retryable: Schema.optionalKey(Schema.Boolean),
20
20
  }) {}
21
21
 
22
- export class LogsConfigError extends Schema.TaggedErrorClass<LogsConfigError>()("LogsConfigError", {
22
+ export class LogsConfigError extends Schema.TaggedError<LogsConfigError>()("LogsConfigError", {
23
23
  message: Schema.String,
24
24
  hint: Schema.optionalKey(Schema.String),
25
25
  nextCommand: Schema.optionalKey(Schema.String),
26
26
  retryable: Schema.optionalKey(Schema.Boolean),
27
27
  }) {}
28
28
 
29
- export class LogsTimeoutError extends Schema.TaggedErrorClass<LogsTimeoutError>()(
30
- "LogsTimeoutError",
31
- {
32
- message: Schema.String,
33
- source: Schema.String,
34
- timeoutMs: Schema.Number,
35
- hint: Schema.optionalKey(Schema.String),
36
- nextCommand: Schema.optionalKey(Schema.String),
37
- retryable: Schema.optionalKey(Schema.Boolean),
38
- },
39
- ) {}
29
+ export class LogsTimeoutError extends Schema.TaggedError<LogsTimeoutError>()("LogsTimeoutError", {
30
+ message: Schema.String,
31
+ source: Schema.String,
32
+ timeoutMs: Schema.Number,
33
+ hint: Schema.optionalKey(Schema.String),
34
+ nextCommand: Schema.optionalKey(Schema.String),
35
+ retryable: Schema.optionalKey(Schema.Boolean),
36
+ }) {}
40
37
 
41
38
  export type LogsError = LogsNotFoundError | LogsReadError | LogsConfigError | LogsTimeoutError;
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
 
3
- export class ObservabilityToolError extends Schema.TaggedErrorClass<ObservabilityToolError>()(
3
+ export class ObservabilityToolError extends Schema.TaggedError<ObservabilityToolError>()(
4
4
  "ObservabilityToolError",
5
5
  {
6
6
  cause: Schema.Unknown,
File without changes
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
 
3
- export class SessionStorageNotFoundError extends Schema.TaggedErrorClass<SessionStorageNotFoundError>()(
3
+ export class SessionStorageNotFoundError extends Schema.TaggedError<SessionStorageNotFoundError>()(
4
4
  "SessionStorageNotFoundError",
5
5
  {
6
6
  message: Schema.String,
@@ -8,22 +8,19 @@ export class SessionStorageNotFoundError extends Schema.TaggedErrorClass<Session
8
8
  },
9
9
  ) {}
10
10
 
11
- export class SessionReadError extends Schema.TaggedErrorClass<SessionReadError>()(
12
- "SessionReadError",
13
- {
14
- message: Schema.String,
15
- source: Schema.String,
16
- },
17
- ) {}
11
+ export class SessionReadError extends Schema.TaggedError<SessionReadError>()("SessionReadError", {
12
+ message: Schema.String,
13
+ source: Schema.String,
14
+ }) {}
18
15
 
19
- export class SessionConfigError extends Schema.TaggedErrorClass<SessionConfigError>()(
16
+ export class SessionConfigError extends Schema.TaggedError<SessionConfigError>()(
20
17
  "SessionConfigError",
21
18
  {
22
19
  message: Schema.String,
23
20
  },
24
21
  ) {}
25
22
 
26
- export class SessionParseError extends Schema.TaggedErrorClass<SessionParseError>()(
23
+ export class SessionParseError extends Schema.TaggedError<SessionParseError>()(
27
24
  "SessionParseError",
28
25
  {
29
26
  message: Schema.String,
File without changes
@@ -0,0 +1,42 @@
1
+ export const REQUIRED_BINARIES = {
2
+ az: {
3
+ tools: "az-tool",
4
+ install:
5
+ "Install it with `brew install azure-cli` (macOS) or see https://learn.microsoft.com/cli/azure/install-azure-cli.",
6
+ },
7
+ gh: {
8
+ tools: "gh-tool",
9
+ install:
10
+ "Install it with `brew install gh` (macOS) or see https://cli.github.com/, then run `gh auth login`.",
11
+ },
12
+ git: {
13
+ tools: "gh-tool release and stack commands",
14
+ install:
15
+ "Install it with `xcode-select --install` (macOS) or see https://git-scm.com/downloads.",
16
+ },
17
+ kubectl: {
18
+ tools: "k8s-tool and db-tool tunnels",
19
+ install:
20
+ "Install it with `brew install kubectl` (macOS) or see https://kubernetes.io/docs/tasks/tools/.",
21
+ },
22
+ } as const;
23
+
24
+ export type RequiredBinary = keyof typeof REQUIRED_BINARIES;
25
+
26
+ export type MissingBinary = { binary: RequiredBinary; message: string; hint: string };
27
+
28
+ const isRequiredBinary = (binary: string): binary is RequiredBinary => binary in REQUIRED_BINARIES;
29
+
30
+ export const describeMissingBinary = (binary: RequiredBinary): MissingBinary => ({
31
+ binary,
32
+ message: `Required binary "${binary}" was not found on PATH.`,
33
+ hint: `${binary} is needed by ${REQUIRED_BINARIES[binary].tools}. ${REQUIRED_BINARIES[binary].install}`,
34
+ });
35
+
36
+ export const missingBinaryFromSpawnFailure = (
37
+ binary: string,
38
+ failure: string,
39
+ ): MissingBinary | undefined =>
40
+ isRequiredBinary(binary) && failure.includes("NotFound")
41
+ ? describeMissingBinary(binary)
42
+ : undefined;
@@ -2,7 +2,7 @@ import { Effect, Schema } from "effect";
2
2
 
3
3
  const envTemplateRegex = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
4
4
 
5
- export class EnvTemplateError extends Schema.TaggedErrorClass<EnvTemplateError>()(
5
+ export class EnvTemplateError extends Schema.TaggedError<EnvTemplateError>()(
6
6
  "@agent-tools/EnvTemplateError",
7
7
  { envVar: Schema.String },
8
8
  ) {}
@@ -3,7 +3,7 @@ import { Effect, Schema, Stream } from "effect";
3
3
 
4
4
  const DEFAULT_TIMEOUT_MS = 30000;
5
5
 
6
- export class ExecError extends Schema.TaggedErrorClass<ExecError>()("ExecError", {
6
+ export class ExecError extends Schema.TaggedError<ExecError>()("ExecError", {
7
7
  message: Schema.String,
8
8
  command: Schema.String,
9
9
  exitCode: Schema.Number,
@@ -1,4 +1,11 @@
1
- export type { BaseResult, CommandOptions, CommandResult, Environment, OutputFormat } from "./types";
1
+ export type {
2
+ BaseResult,
3
+ CommandOptions,
4
+ CommandResult,
5
+ Environment,
6
+ OutputFormat,
7
+ ToolResult,
8
+ } from "./types";
2
9
 
3
10
  export { formatAny, formatOption, formatOutput, logFormatted } from "./format";
4
11
 
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
 
3
- export class PrerequisiteRunError extends Schema.TaggedErrorClass<PrerequisiteRunError>()(
3
+ export class PrerequisiteRunError extends Schema.TaggedError<PrerequisiteRunError>()(
4
4
  "PrerequisiteRunError",
5
5
  {
6
6
  message: Schema.String,
@@ -0,0 +1,12 @@
1
+ export { runWithProfilePrerequisites } from "#shared/prerequisites/runtime";
2
+
3
+ export { resolveEnvironmentScopedPrerequisites } from "#shared/prerequisites/config";
4
+
5
+ export { isPrerequisiteRunError, PrerequisiteRunError } from "#shared/prerequisites/errors";
6
+
7
+ export type {
8
+ PrerequisiteCommandResult,
9
+ PrerequisiteCommandRunner,
10
+ } from "#shared/prerequisites/types";
11
+
12
+ export type { ProfilePrerequisites, VpnPrerequisite } from "#config/types";
@@ -2,7 +2,7 @@ import { Effect, Ref, Schema } from "effect";
2
2
 
3
3
  const WINDOW_MS = 60000;
4
4
 
5
- export class ThrottleError extends Schema.TaggedErrorClass<ThrottleError>()("ThrottleError", {
5
+ export class ThrottleError extends Schema.TaggedError<ThrottleError>()("ThrottleError", {
6
6
  message: Schema.String,
7
7
  label: Schema.String,
8
8
  limit: Schema.Number,
@@ -10,6 +10,12 @@ export type BaseResult = {
10
10
  hint?: string;
11
11
  };
12
12
 
13
+ // Widening BaseResult itself is not honest: db-tool's select branch emits no message.
14
+ export type ToolResult = BaseResult & {
15
+ message: string;
16
+ data?: unknown;
17
+ };
18
+
13
19
  export type CommandOptions = {
14
20
  cwd?: string;
15
21
  env?: Record<string, string>;
@@ -1,27 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { join } from "node:path";
3
-
4
- // Homebrew keeps libpq keg-only, so psql is routinely installed yet absent from PATH.
5
- const KEG_ONLY_PSQL_DIRECTORIES = ["/opt/homebrew/opt/libpq/bin", "/usr/local/opt/libpq/bin"];
6
-
7
- export const PSQL_MISSING_HINT =
8
- "psql was not found on PATH. On macOS install it with `brew install libpq`; libpq is keg-only, so also add /opt/homebrew/opt/libpq/bin (Apple silicon) or /usr/local/opt/libpq/bin (Intel) to PATH.";
9
-
10
- export const resolvePsqlSearchPath = (
11
- pathEnv: string | undefined,
12
- fileExists: (candidate: string) => boolean = existsSync,
13
- ): string | undefined => {
14
- const directories = (pathEnv ?? "").split(":").filter((directory) => directory.length > 0);
15
- if (directories.some((directory) => fileExists(join(directory, "psql")))) {
16
- return pathEnv;
17
- }
18
-
19
- const kegOnly = KEG_ONLY_PSQL_DIRECTORIES.find((directory) =>
20
- fileExists(join(directory, "psql")),
21
- );
22
- if (kegOnly === undefined) {
23
- return pathEnv;
24
- }
25
-
26
- return directories.length > 0 ? [...directories, kegOnly].join(":") : kegOnly;
27
- };