ToolSourceError
Errors a tool source reports when it cannot do what it was asked: tell which tools it has, or run
one. A tool that ran and reported its own failure is one of them, as CallFailedError.
ToolSourceError says which source failed and holds the reason, so callers can recover from one
reason with Effect.catchReason("ToolSourceError", "AuthenticationError", ...), as a host does
to ask for a connection again. The operation that failed is the one the caller ran, which its
span names.
Each reason has a description, what happened in the words of whoever reports it, and says with
isRetryable whether trying again may succeed. modelMessage is what a model reads of it. The
descriptions of InvalidInputError and CallFailedError are written for it, to say what to
correct and what the tool said. The description of any other reason may name an address or
another internal, so the model reads only its default message.
Since v0.1.0
Constructors
Section titled “Constructors”reasonFromHttpClientError
Section titled “reasonFromHttpClientError”Why a request that got no answer failed: a server that could not be reached is unavailable, and anything else about the request is unknown.
Signature
declare const reasonFromHttpClientError: (error: HttpClientError.HttpClientError) => ToolSourceErrorReasonSince v0.1.0
Errors
Section titled “Errors”AuthenticationError (class)
Section titled “AuthenticationError (class)”The source’s credentials are missing, invalid, or not allowed to do this.
Signature
declare class AuthenticationErrorSince v0.1.0
CallFailedError (class)
Section titled “CallFailedError (class)”The tool ran and reported that it failed. Its description is what the tool said.
Signature
declare class CallFailedErrorSince v0.1.0
InvalidInputError (class)
Section titled “InvalidInputError (class)”The input does not match the tool’s parameters. Its description says what to correct.
Signature
declare class InvalidInputErrorSince v0.1.0
InvalidResponseError (class)
Section titled “InvalidResponseError (class)”The source answered in a way its protocol does not allow, such as a result that is not JSON.
Signature
declare class InvalidResponseErrorSince v0.1.0
NotFoundError (class)
Section titled “NotFoundError (class)”The source has no tool of the name it was asked to run, such as one it has removed since.
Signature
declare class NotFoundErrorSince v0.1.0
ToolSourceError (class)
Section titled “ToolSourceError (class)”What every operation of a tool source fails with: the source that failed, by its name, and the
reason. Only an UnavailableError is worth trying again, as isRetryable says.
Example (Recovering from one reason)
import type { ToolSource } from "@amends-dev/toolkit"import { Effect } from "effect"
declare const github: ToolSource.ToolSourcedeclare const askToConnectAgain: Effect.Effect<void>
// A refused credential is the connection's to fix; the other reasons stay failures.const definitions = github.discover.pipe( Effect.catchReason("ToolSourceError", "AuthenticationError", () => Effect.as(askToConnectAgain, [])))Signature
declare class ToolSourceErrorSince v0.1.0
ToolSourceErrorReason
Section titled “ToolSourceErrorReason”Why a tool source failed: one of the errors above, which ToolSourceError.reason holds.
Signature
declare const ToolSourceErrorReason: Schema.toTaggedUnion< "_tag", readonly [ typeof AuthenticationError, typeof NotFoundError, typeof InvalidInputError, typeof CallFailedError, typeof UnavailableError, typeof InvalidResponseError, typeof UnsupportedError, typeof UnknownError ]>Since v0.1.0
ToolSourceErrorReason (type alias)
Section titled “ToolSourceErrorReason (type alias)”Signature
type ToolSourceErrorReason = typeof ToolSourceErrorReason.TypeSince v0.1.0
UnavailableError (class)
Section titled “UnavailableError (class)”The source cannot answer now: it said that it is down or busy, or it could not be reached. The only reason worth trying again.
Signature
declare class UnavailableErrorSince v0.1.0
UnknownError (class)
Section titled “UnknownError (class)”The source failed in a way no other reason names, such as a defect in its code or a request that could not be sent. The model reads only that the source failed.
Signature
declare class UnknownErrorSince v0.1.0
UnsupportedError (class)
Section titled “UnsupportedError (class)”The source does not do what was asked, such as running a tool that asks for input first, returning an answer of a media type a tool cannot return, or speaking the server’s protocol.
Signature
declare class UnsupportedErrorSince v0.1.0