Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243import * as Data from "effect/Data";import * as Effect from "effect/Effect";
export class AgentFailure extends Data.TaggedError("AgentFailure")<{ message: string;}> {}
// Native RPCs do not transport Effect errors or guarantee cancellation. Each// caller supplies its public failure and rechecks authorization after yielding.export function agentCall<A>( operation: () => PromiseLike<A>, message = "Personal runtime unavailable",) { return Effect.tryPromise({ try: operation, catch: () => new AgentFailure({ message }), });}
export function agentValidation<A>(validate: () => A) { return Effect.try({ try: validate, catch: (error) => error instanceof AgentFailure ? error : new AgentFailure({ message: error instanceof Error ? error.message : "Invalid operation", }), });}
export function runAgent<A, E>( program: Effect.Effect<A, E>, signal?: AbortSignal,): Promise<A> { if (signal?.aborted) return Promise.reject( new AgentFailure({ message: "Operation interrupted" }), ); return Effect.runPromise(program, { signal });}