39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import type { GarnetClient } from "@common/garnet";
|
|
import type { NatsClient } from "@common/nats";
|
|
import type { RoomContextService } from "@room/room-context-service";
|
|
import type { ZodType } from "zod";
|
|
import type { OnboardingSession } from "@skills/onboarding/types";
|
|
import type { ToolRegistry } from "./registry.js";
|
|
|
|
export interface ToolContext {
|
|
chatroomId?: string | undefined;
|
|
natsClient?: Pick<NatsClient, "request"> | undefined;
|
|
userId?: string | undefined;
|
|
session?: OnboardingSession | null | undefined;
|
|
garnetClient?: GarnetClient | undefined;
|
|
roomContextService?: RoomContextService | undefined;
|
|
toolRegistry?: ToolRegistry | undefined;
|
|
}
|
|
|
|
export type ToolErrorKind =
|
|
| "args-invalid"
|
|
| "transient"
|
|
| "precondition-failed"
|
|
| "permanent";
|
|
|
|
export interface ToolExecutionFailure {
|
|
kind: ToolErrorKind;
|
|
toolName: string;
|
|
message: string;
|
|
retryable: boolean;
|
|
details?: unknown;
|
|
}
|
|
|
|
export interface Tool<A, R> {
|
|
name: string;
|
|
description: string;
|
|
argsSchema: ZodType<A>;
|
|
resultSchema: ZodType<R>;
|
|
execute(args: A, ctx: ToolContext): Promise<R>;
|
|
}
|