/** * HTTP Client Types for Humancy Cloud API * * Types for REST API request/response communication with humancy-cloud. */ import { z } from 'zod'; /** * Configuration for HumancyHttpClient */ export interface HttpClientConfig { /** Base URL for API (default: https://generacy.ai/api/humancy) */ baseUrl: string; /** API key for authentication (optional for local dev) */ apiKey?: string; /** Request timeout in milliseconds (default: 60000) */ timeout: number; /** Maximum retry attempts (default: 3) */ maxRetries: number; /** Base delay for exponential backoff in ms (default: 1000) */ retryBaseDelayMs: number; } /** * Default HTTP client configuration */ export declare const DEFAULT_HTTP_CONFIG: HttpClientConfig; /** * Decision option for API request */ export interface ApiDecisionOption { /** Unique identifier for the option */ id: string; /** Display text for the option */ label: string; /** Optional description */ description?: string; /** Optional tradeoffs analysis */ tradeoffs?: { pros?: string[]; cons?: string[]; }; } /** * Request to create a decision via REST API */ export interface CreateDecisionApiRequest { /** The decision question */ question: string; /** Available choices (2-10 options) */ options: ApiDecisionOption[]; /** Additional context for the decision */ context?: string; /** Urgency level */ urgency: 'blocking_now' | 'blocking_soon' | 'when_available'; /** Domain tags for principle matching */ domain?: string[]; /** Timeout in milliseconds for this decision */ timeout?: number; } /** * Response from creating a decision */ export interface DecisionCreatedResponse { /** Unique decision ID */ id: string; /** Current status */ status: 'pending' | 'resolved' | 'expired'; /** When the decision was created */ createdAt: string; /** When the decision will expire */ expiresAt: string; } /** * Three-layer model components in API response */ export interface ApiBaselineRecommendation { optionId: string; confidence: number; } export interface ApiProtegeRecommendation { optionId: string; reasoning: string; } export interface ApiHumanDecision { optionId: string; note?: string; } /** * Response from getting a decision */ export interface DecisionApiResponse { /** Unique decision ID */ id: string; /** Current status */ status: 'pending' | 'resolved' | 'expired'; /** The decision question */ question: string; /** Available choices */ options: ApiDecisionOption[]; /** Selected option ID (if resolved) */ selectedOption?: string; /** When the human responded (if resolved) */ respondedAt?: string; /** Baseline agent recommendation (three-layer model) */ baseline?: ApiBaselineRecommendation; /** Protege agent recommendation (three-layer model) */ protege?: ApiProtegeRecommendation; /** Human decision (three-layer model) */ human?: ApiHumanDecision; } /** * Base SSE event */ export interface BaseSSEEvent { /** Event type */ type: string; /** Event timestamp */ timestamp: string; } /** * Decision resolved event */ export interface DecisionResolvedEvent extends BaseSSEEvent { type: 'decision:resolved'; /** Selected option ID */ selectedOption: string; /** When the human responded */ respondedAt: string; /** Three-layer data if available */ baseline?: ApiBaselineRecommendation; protege?: ApiProtegeRecommendation; human?: ApiHumanDecision; } /** * Decision expired event */ export interface DecisionExpiredEvent extends BaseSSEEvent { type: 'decision:expired'; /** Reason for expiration */ reason: string; } /** * Decision created event */ export interface DecisionCreatedEvent extends BaseSSEEvent { type: 'decision:created'; /** Decision ID */ decisionId: string; } /** * Decision updated event */ export interface DecisionUpdatedEvent extends BaseSSEEvent { type: 'decision:updated'; /** Current status */ status: string; } /** * Heartbeat event for connection keep-alive */ export interface HeartbeatEvent extends BaseSSEEvent { type: 'heartbeat'; } /** * Union of all SSE event types */ export type SSEEvent = DecisionResolvedEvent | DecisionExpiredEvent | DecisionCreatedEvent | DecisionUpdatedEvent | HeartbeatEvent; /** * HTTP error with status code */ export declare class HttpError extends Error { status: number; statusText: string; body?: unknown | undefined; constructor(status: number, statusText: string, body?: unknown | undefined); /** Check if error is retriable */ get isRetryable(): boolean; /** Check if auth error */ get isAuthError(): boolean; /** Check if rate limited */ get isRateLimited(): boolean; /** Check if not found */ get isNotFound(): boolean; } /** * SSE connection error */ export declare class SSEConnectionError extends Error { reason: 'timeout' | 'network' | 'server_error' | 'max_retries'; constructor(reason: 'timeout' | 'network' | 'server_error' | 'max_retries', message: string); } /** * Decision timeout error */ export interface DecisionTimeoutError { type: 'timeout'; decisionId: string; elapsedMs: number; configuredTimeoutMs: number; suggestion: string; } /** * HTTP client config validation */ export declare const httpClientConfigSchema: z.ZodObject<{ baseUrl: z.ZodString; apiKey: z.ZodOptional; timeout: z.ZodDefault; maxRetries: z.ZodDefault; retryBaseDelayMs: z.ZodDefault; }, "strip", z.ZodTypeAny, { timeout: number; baseUrl: string; maxRetries: number; retryBaseDelayMs: number; apiKey?: string | undefined; }, { baseUrl: string; apiKey?: string | undefined; timeout?: number | undefined; maxRetries?: number | undefined; retryBaseDelayMs?: number | undefined; }>; /** * API option validation */ export declare const apiDecisionOptionSchema: z.ZodObject<{ id: z.ZodString; label: z.ZodString; description: z.ZodOptional; tradeoffs: z.ZodOptional>; cons: z.ZodOptional>; }, "strip", z.ZodTypeAny, { pros?: string[] | undefined; cons?: string[] | undefined; }, { pros?: string[] | undefined; cons?: string[] | undefined; }>>; }, "strip", z.ZodTypeAny, { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }, { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }>; /** * API request validation */ export declare const createDecisionApiRequestSchema: z.ZodObject<{ question: z.ZodString; options: z.ZodArray; tradeoffs: z.ZodOptional>; cons: z.ZodOptional>; }, "strip", z.ZodTypeAny, { pros?: string[] | undefined; cons?: string[] | undefined; }, { pros?: string[] | undefined; cons?: string[] | undefined; }>>; }, "strip", z.ZodTypeAny, { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }, { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }>, "many">; context: z.ZodOptional; urgency: z.ZodEnum<["blocking_now", "blocking_soon", "when_available"]>; domain: z.ZodOptional>; timeout: z.ZodOptional; }, "strip", z.ZodTypeAny, { options: { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }[]; question: string; urgency: "blocking_now" | "blocking_soon" | "when_available"; timeout?: number | undefined; domain?: string[] | undefined; context?: string | undefined; }, { options: { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }[]; question: string; urgency: "blocking_now" | "blocking_soon" | "when_available"; timeout?: number | undefined; domain?: string[] | undefined; context?: string | undefined; }>; /** * Decision created response validation */ export declare const decisionCreatedResponseSchema: z.ZodObject<{ id: z.ZodString; status: z.ZodEnum<["pending", "resolved", "expired"]>; createdAt: z.ZodString; expiresAt: z.ZodString; }, "strip", z.ZodTypeAny, { status: "pending" | "resolved" | "expired"; id: string; createdAt: string; expiresAt: string; }, { status: "pending" | "resolved" | "expired"; id: string; createdAt: string; expiresAt: string; }>; /** * Decision API response validation */ export declare const decisionApiResponseSchema: z.ZodObject<{ id: z.ZodString; status: z.ZodEnum<["pending", "resolved", "expired"]>; question: z.ZodString; options: z.ZodArray; tradeoffs: z.ZodOptional>; cons: z.ZodOptional>; }, "strip", z.ZodTypeAny, { pros?: string[] | undefined; cons?: string[] | undefined; }, { pros?: string[] | undefined; cons?: string[] | undefined; }>>; }, "strip", z.ZodTypeAny, { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }, { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }>, "many">; selectedOption: z.ZodOptional; respondedAt: z.ZodOptional; baseline: z.ZodOptional>; protege: z.ZodOptional>; human: z.ZodOptional; }, "strip", z.ZodTypeAny, { optionId: string; note?: string | undefined; }, { optionId: string; note?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { status: "pending" | "resolved" | "expired"; options: { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }[]; id: string; question: string; baseline?: { optionId: string; confidence: number; } | undefined; protege?: { optionId: string; reasoning: string; } | undefined; human?: { optionId: string; note?: string | undefined; } | undefined; selectedOption?: string | undefined; respondedAt?: string | undefined; }, { status: "pending" | "resolved" | "expired"; options: { id: string; label: string; description?: string | undefined; tradeoffs?: { pros?: string[] | undefined; cons?: string[] | undefined; } | undefined; }[]; id: string; question: string; baseline?: { optionId: string; confidence: number; } | undefined; protege?: { optionId: string; reasoning: string; } | undefined; human?: { optionId: string; note?: string | undefined; } | undefined; selectedOption?: string | undefined; respondedAt?: string | undefined; }>; /** * SSE event validation */ export declare const sseEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ type: z.ZodLiteral<"decision:resolved">; selectedOption: z.ZodString; respondedAt: z.ZodString; timestamp: z.ZodString; baseline: z.ZodOptional>; protege: z.ZodOptional>; human: z.ZodOptional; }, "strip", z.ZodTypeAny, { optionId: string; note?: string | undefined; }, { optionId: string; note?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { type: "decision:resolved"; timestamp: string; selectedOption: string; respondedAt: string; baseline?: { optionId: string; confidence: number; } | undefined; protege?: { optionId: string; reasoning: string; } | undefined; human?: { optionId: string; note?: string | undefined; } | undefined; }, { type: "decision:resolved"; timestamp: string; selectedOption: string; respondedAt: string; baseline?: { optionId: string; confidence: number; } | undefined; protege?: { optionId: string; reasoning: string; } | undefined; human?: { optionId: string; note?: string | undefined; } | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"decision:expired">; reason: z.ZodString; timestamp: z.ZodString; }, "strip", z.ZodTypeAny, { type: "decision:expired"; timestamp: string; reason: string; }, { type: "decision:expired"; timestamp: string; reason: string; }>, z.ZodObject<{ type: z.ZodLiteral<"decision:created">; decisionId: z.ZodString; timestamp: z.ZodString; }, "strip", z.ZodTypeAny, { type: "decision:created"; decisionId: string; timestamp: string; }, { type: "decision:created"; decisionId: string; timestamp: string; }>, z.ZodObject<{ type: z.ZodLiteral<"decision:updated">; status: z.ZodString; timestamp: z.ZodString; }, "strip", z.ZodTypeAny, { status: string; type: "decision:updated"; timestamp: string; }, { status: string; type: "decision:updated"; timestamp: string; }>, z.ZodObject<{ type: z.ZodLiteral<"heartbeat">; timestamp: z.ZodString; }, "strip", z.ZodTypeAny, { type: "heartbeat"; timestamp: string; }, { type: "heartbeat"; timestamp: string; }>]>; //# sourceMappingURL=types.d.ts.map