UNPKG

@xynehq/jaf

Version:

Juspay Agent Framework - A purely functional agent framework with immutable state and composable tools

961 lines 32 kB
import { z } from 'zod'; import { Agent, RunConfig } from '../core/types'; import { MemoryProvider } from '../memory/types'; export interface ServerConfig<Ctx> { port?: number; host?: string; cors?: boolean; maxBodySize?: number; runConfig: RunConfig<Ctx>; agentRegistry?: Map<string, Agent<Ctx, any>>; defaultMemoryProvider?: MemoryProvider; } export declare const attachmentSchema: z.ZodObject<{ kind: z.ZodEnum<["image", "document", "file"]>; mimeType: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; data: z.ZodOptional<z.ZodString>; format: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }>; export declare const httpMessageSchema: z.ZodObject<{ role: z.ZodEnum<["user", "assistant", "system"]>; content: z.ZodString; attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{ kind: z.ZodEnum<["image", "document", "file"]>; mimeType: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; data: z.ZodOptional<z.ZodString>; format: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }, { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }>; export declare const approvalMessageSchema: z.ZodObject<{ type: z.ZodLiteral<"approval">; sessionId: z.ZodString; toolCallId: z.ZodString; approved: z.ZodBoolean; additionalContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; }, "strip", z.ZodTypeAny, { type: "approval"; approved: boolean; sessionId: string; toolCallId: string; additionalContext?: Record<string, any> | undefined; }, { type: "approval"; approved: boolean; sessionId: string; toolCallId: string; additionalContext?: Record<string, any> | undefined; }>; export declare const chatRequestSchema: z.ZodObject<{ messages: z.ZodArray<z.ZodObject<{ role: z.ZodEnum<["user", "assistant", "system"]>; content: z.ZodString; attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{ kind: z.ZodEnum<["image", "document", "file"]>; mimeType: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; data: z.ZodOptional<z.ZodString>; format: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }, { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }>, "many">; agentName: z.ZodString; context: z.ZodOptional<z.ZodAny>; maxTurns: z.ZodOptional<z.ZodNumber>; stream: z.ZodDefault<z.ZodBoolean>; conversationId: z.ZodOptional<z.ZodString>; memory: z.ZodOptional<z.ZodObject<{ autoStore: z.ZodDefault<z.ZodBoolean>; maxMessages: z.ZodOptional<z.ZodNumber>; compressionThreshold: z.ZodOptional<z.ZodNumber>; storeOnCompletion: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { autoStore: boolean; storeOnCompletion?: boolean | undefined; compressionThreshold?: number | undefined; maxMessages?: number | undefined; }, { autoStore?: boolean | undefined; storeOnCompletion?: boolean | undefined; compressionThreshold?: number | undefined; maxMessages?: number | undefined; }>>; approvals: z.ZodOptional<z.ZodArray<z.ZodObject<{ type: z.ZodLiteral<"approval">; sessionId: z.ZodString; toolCallId: z.ZodString; approved: z.ZodBoolean; additionalContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; }, "strip", z.ZodTypeAny, { type: "approval"; approved: boolean; sessionId: string; toolCallId: string; additionalContext?: Record<string, any> | undefined; }, { type: "approval"; approved: boolean; sessionId: string; toolCallId: string; additionalContext?: Record<string, any> | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { messages: { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }[]; agentName: string; stream: boolean; memory?: { autoStore: boolean; storeOnCompletion?: boolean | undefined; compressionThreshold?: number | undefined; maxMessages?: number | undefined; } | undefined; context?: any; approvals?: { type: "approval"; approved: boolean; sessionId: string; toolCallId: string; additionalContext?: Record<string, any> | undefined; }[] | undefined; maxTurns?: number | undefined; conversationId?: string | undefined; }, { messages: { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }[]; agentName: string; memory?: { autoStore?: boolean | undefined; storeOnCompletion?: boolean | undefined; compressionThreshold?: number | undefined; maxMessages?: number | undefined; } | undefined; context?: any; approvals?: { type: "approval"; approved: boolean; sessionId: string; toolCallId: string; additionalContext?: Record<string, any> | undefined; }[] | undefined; maxTurns?: number | undefined; conversationId?: string | undefined; stream?: boolean | undefined; }>; export type ChatRequest = z.infer<typeof chatRequestSchema>; export type HttpMessage = z.infer<typeof httpMessageSchema>; export type ApprovalMessage = z.infer<typeof approvalMessageSchema>; export declare const fullMessageSchema: z.ZodUnion<[z.ZodObject<{ role: z.ZodEnum<["user", "assistant", "system"]>; content: z.ZodString; attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{ kind: z.ZodEnum<["image", "document", "file"]>; mimeType: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; data: z.ZodOptional<z.ZodString>; format: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }, { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }>, z.ZodObject<{ role: z.ZodLiteral<"assistant">; content: z.ZodString; tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; type: z.ZodLiteral<"function">; function: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; arguments: string; }, { name: string; arguments: string; }>; }, "strip", z.ZodTypeAny, { function: { name: string; arguments: string; }; type: "function"; id: string; }, { function: { name: string; arguments: string; }; type: "function"; id: string; }>, "many">>; }, "strip", z.ZodTypeAny, { content: string; role: "assistant"; tool_calls?: { function: { name: string; arguments: string; }; type: "function"; id: string; }[] | undefined; }, { content: string; role: "assistant"; tool_calls?: { function: { name: string; arguments: string; }; type: "function"; id: string; }[] | undefined; }>, z.ZodObject<{ role: z.ZodLiteral<"tool">; content: z.ZodString; tool_call_id: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { content: string; role: "tool"; tool_call_id?: string | undefined; }, { content: string; role: "tool"; tool_call_id?: string | undefined; }>]>; export declare const chatResponseSchema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodOptional<z.ZodObject<{ runId: z.ZodString; traceId: z.ZodString; conversationId: z.ZodOptional<z.ZodString>; messages: z.ZodArray<z.ZodUnion<[z.ZodObject<{ role: z.ZodEnum<["user", "assistant", "system"]>; content: z.ZodString; attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{ kind: z.ZodEnum<["image", "document", "file"]>; mimeType: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; data: z.ZodOptional<z.ZodString>; format: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }, { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }, { content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; }>, z.ZodObject<{ role: z.ZodLiteral<"assistant">; content: z.ZodString; tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; type: z.ZodLiteral<"function">; function: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; arguments: string; }, { name: string; arguments: string; }>; }, "strip", z.ZodTypeAny, { function: { name: string; arguments: string; }; type: "function"; id: string; }, { function: { name: string; arguments: string; }; type: "function"; id: string; }>, "many">>; }, "strip", z.ZodTypeAny, { content: string; role: "assistant"; tool_calls?: { function: { name: string; arguments: string; }; type: "function"; id: string; }[] | undefined; }, { content: string; role: "assistant"; tool_calls?: { function: { name: string; arguments: string; }; type: "function"; id: string; }[] | undefined; }>, z.ZodObject<{ role: z.ZodLiteral<"tool">; content: z.ZodString; tool_call_id: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { content: string; role: "tool"; tool_call_id?: string | undefined; }, { content: string; role: "tool"; tool_call_id?: string | undefined; }>]>, "many">; outcome: z.ZodObject<{ status: z.ZodEnum<["completed", "error", "max_turns", "interrupted"]>; output: z.ZodOptional<z.ZodString>; error: z.ZodOptional<z.ZodAny>; interruptions: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{ type: z.ZodLiteral<"tool_approval">; toolCall: z.ZodObject<{ id: z.ZodString; type: z.ZodLiteral<"function">; function: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; arguments: string; }, { name: string; arguments: string; }>; }, "strip", z.ZodTypeAny, { function: { name: string; arguments: string; }; type: "function"; id: string; }, { function: { name: string; arguments: string; }; type: "function"; id: string; }>; sessionId: z.ZodString; }, "strip", z.ZodTypeAny, { type: "tool_approval"; sessionId: string; toolCall: { function: { name: string; arguments: string; }; type: "function"; id: string; }; }, { type: "tool_approval"; sessionId: string; toolCall: { function: { name: string; arguments: string; }; type: "function"; id: string; }; }>, z.ZodObject<{ type: z.ZodLiteral<"clarification_required">; clarificationId: z.ZodString; question: z.ZodString; options: z.ZodArray<z.ZodObject<{ id: z.ZodString; label: z.ZodString; value: z.ZodOptional<z.ZodAny>; }, "strip", z.ZodTypeAny, { id: string; label: string; value?: any; }, { id: string; label: string; value?: any; }>, "many">; context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; }, "strip", z.ZodTypeAny, { type: "clarification_required"; options: { id: string; label: string; value?: any; }[]; question: string; clarificationId: string; context?: Record<string, any> | undefined; }, { type: "clarification_required"; options: { id: string; label: string; value?: any; }[]; question: string; clarificationId: string; context?: Record<string, any> | undefined; }>]>, "many">>; }, "strip", z.ZodTypeAny, { status: "completed" | "error" | "interrupted" | "max_turns"; error?: any; output?: string | undefined; interruptions?: ({ type: "tool_approval"; sessionId: string; toolCall: { function: { name: string; arguments: string; }; type: "function"; id: string; }; } | { type: "clarification_required"; options: { id: string; label: string; value?: any; }[]; question: string; clarificationId: string; context?: Record<string, any> | undefined; })[] | undefined; }, { status: "completed" | "error" | "interrupted" | "max_turns"; error?: any; output?: string | undefined; interruptions?: ({ type: "tool_approval"; sessionId: string; toolCall: { function: { name: string; arguments: string; }; type: "function"; id: string; }; } | { type: "clarification_required"; options: { id: string; label: string; value?: any; }[]; question: string; clarificationId: string; context?: Record<string, any> | undefined; })[] | undefined; }>; turnCount: z.ZodNumber; executionTimeMs: z.ZodNumber; }, "strip", z.ZodTypeAny, { traceId: string; runId: string; outcome: { status: "completed" | "error" | "interrupted" | "max_turns"; error?: any; output?: string | undefined; interruptions?: ({ type: "tool_approval"; sessionId: string; toolCall: { function: { name: string; arguments: string; }; type: "function"; id: string; }; } | { type: "clarification_required"; options: { id: string; label: string; value?: any; }[]; question: string; clarificationId: string; context?: Record<string, any> | undefined; })[] | undefined; }; messages: ({ content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; } | { content: string; role: "assistant"; tool_calls?: { function: { name: string; arguments: string; }; type: "function"; id: string; }[] | undefined; } | { content: string; role: "tool"; tool_call_id?: string | undefined; })[]; executionTimeMs: number; turnCount: number; conversationId?: string | undefined; }, { traceId: string; runId: string; outcome: { status: "completed" | "error" | "interrupted" | "max_turns"; error?: any; output?: string | undefined; interruptions?: ({ type: "tool_approval"; sessionId: string; toolCall: { function: { name: string; arguments: string; }; type: "function"; id: string; }; } | { type: "clarification_required"; options: { id: string; label: string; value?: any; }[]; question: string; clarificationId: string; context?: Record<string, any> | undefined; })[] | undefined; }; messages: ({ content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; } | { content: string; role: "assistant"; tool_calls?: { function: { name: string; arguments: string; }; type: "function"; id: string; }[] | undefined; } | { content: string; role: "tool"; tool_call_id?: string | undefined; })[]; executionTimeMs: number; turnCount: number; conversationId?: string | undefined; }>>; error: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { success: boolean; data?: { traceId: string; runId: string; outcome: { status: "completed" | "error" | "interrupted" | "max_turns"; error?: any; output?: string | undefined; interruptions?: ({ type: "tool_approval"; sessionId: string; toolCall: { function: { name: string; arguments: string; }; type: "function"; id: string; }; } | { type: "clarification_required"; options: { id: string; label: string; value?: any; }[]; question: string; clarificationId: string; context?: Record<string, any> | undefined; })[] | undefined; }; messages: ({ content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; } | { content: string; role: "assistant"; tool_calls?: { function: { name: string; arguments: string; }; type: "function"; id: string; }[] | undefined; } | { content: string; role: "tool"; tool_call_id?: string | undefined; })[]; executionTimeMs: number; turnCount: number; conversationId?: string | undefined; } | undefined; error?: string | undefined; }, { success: boolean; data?: { traceId: string; runId: string; outcome: { status: "completed" | "error" | "interrupted" | "max_turns"; error?: any; output?: string | undefined; interruptions?: ({ type: "tool_approval"; sessionId: string; toolCall: { function: { name: string; arguments: string; }; type: "function"; id: string; }; } | { type: "clarification_required"; options: { id: string; label: string; value?: any; }[]; question: string; clarificationId: string; context?: Record<string, any> | undefined; })[] | undefined; }; messages: ({ content: string; role: "user" | "assistant" | "system"; attachments?: { kind: "image" | "document" | "file"; url?: string | undefined; data?: string | undefined; format?: string | undefined; name?: string | undefined; mimeType?: string | undefined; }[] | undefined; } | { content: string; role: "assistant"; tool_calls?: { function: { name: string; arguments: string; }; type: "function"; id: string; }[] | undefined; } | { content: string; role: "tool"; tool_call_id?: string | undefined; })[]; executionTimeMs: number; turnCount: number; conversationId?: string | undefined; } | undefined; error?: string | undefined; }>; export type ChatResponse = z.infer<typeof chatResponseSchema>; export declare const agentListResponseSchema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodOptional<z.ZodObject<{ agents: z.ZodArray<z.ZodObject<{ name: z.ZodString; description: z.ZodString; tools: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { name: string; tools: string[]; description: string; }, { name: string; tools: string[]; description: string; }>, "many">; }, "strip", z.ZodTypeAny, { agents: { name: string; tools: string[]; description: string; }[]; }, { agents: { name: string; tools: string[]; description: string; }[]; }>>; error: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { success: boolean; data?: { agents: { name: string; tools: string[]; description: string; }[]; } | undefined; error?: string | undefined; }, { success: boolean; data?: { agents: { name: string; tools: string[]; description: string; }[]; } | undefined; error?: string | undefined; }>; export type AgentListResponse = z.infer<typeof agentListResponseSchema>; export declare const healthResponseSchema: z.ZodObject<{ status: z.ZodLiteral<"healthy">; timestamp: z.ZodString; version: z.ZodString; uptime: z.ZodNumber; }, "strip", z.ZodTypeAny, { status: "healthy"; timestamp: string; version: string; uptime: number; }, { status: "healthy"; timestamp: string; version: string; uptime: number; }>; export type HealthResponse = z.infer<typeof healthResponseSchema>; //# sourceMappingURL=types.d.ts.map