From 69e941758c3dce1d8adca27c2af2f1fce4552fef Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Thu, 23 Jul 2026 19:02:29 +0200 Subject: [PATCH 1/5] refactor(errors): unify five retry implementations onto one retryWithBackoff primitive Four HTTP clients and the workflow executor each hand-rolled retry with different semantics (attempt counting, backoff, timeout, classification). This makes errors/retryWithBackoff the single retry primitive and routes everything through it with behavior preserved per call site: - retryWithBackoff: explicit maxAttempts (total attempts) plus shouldRetry, computeDelay, per-attempt timeoutMs/AbortSignal, onRetry, wrapFinalError - veryfront-api-client requestWithRetry: rewritten on the primitive; spans, metrics, redacted logging, and 4xx-no-retry classification unchanged - token api-client: duplicate retry loop removed (returns Response, keeps 4xx pass-through and TOKEN_STORAGE_ERROR semantics) - github api-client: keeps rate-limit-aware delays and jitter via computeDelay; total-attempt counting preserved - fs/veryfront withRetryOnTransient: same single-retry transient policy on the primitive; isTransientError untouched - workflow executor: duplicated calculateRetryDelay, retryable-error classification, and constants extracted to executor/retry-policy.ts; copy-pasted private sleep removed in favor of #veryfront/utils sleep --- src/errors/error-handlers.test.ts | 4 +- src/errors/error-handlers.ts | 78 ++++++++++---- src/errors/index.ts | 1 + .../adapters/fs/github/github-api-client.ts | 58 +++++----- src/platform/adapters/fs/veryfront/retry.ts | 27 +++-- .../adapters/token/veryfront/api-client.ts | 101 ++++++++---------- .../veryfront-api-client/retry-handler.ts | 98 ++++++++--------- .../executor/dag/composite-node-execution.ts | 25 +---- src/workflow/executor/retry-policy.ts | 51 +++++++++ src/workflow/executor/step-executor.ts | 72 ++----------- 10 files changed, 253 insertions(+), 262 deletions(-) create mode 100644 src/workflow/executor/retry-policy.ts diff --git a/src/errors/error-handlers.test.ts b/src/errors/error-handlers.test.ts index 9a8c5c98d2..13363cd3f7 100644 --- a/src/errors/error-handlers.test.ts +++ b/src/errors/error-handlers.test.ts @@ -76,7 +76,7 @@ describe("error-handlers", () => { if (attempts < 2) throw new Error("fail"); return "success"; }, - { maxRetries: 3, initialDelay: 1 }, + { maxAttempts: 3, initialDelay: 1 }, ); assertEquals(result, "success"); @@ -94,7 +94,7 @@ describe("error-handlers", () => { attempts++; throw new Error("always fails"); }, - { maxRetries: 2, initialDelay: 1 }, + { maxAttempts: 2, initialDelay: 1 }, ), Error, "always fails", diff --git a/src/errors/error-handlers.ts b/src/errors/error-handlers.ts index b1156bc216..fffae6ea6f 100644 --- a/src/errors/error-handlers.ts +++ b/src/errors/error-handlers.ts @@ -1,4 +1,5 @@ import { serverLogger } from "#veryfront/utils/logger/logger.ts"; +import { sleep } from "#veryfront/utils/sleep.ts"; import { DEFAULT_RETRY_INITIAL_DELAY_MS, DEFAULT_RETRY_MAX_ATTEMPTS, @@ -44,41 +45,78 @@ export function handleErrorWithFallbackSync( } } +export interface RetryWithBackoffOptions { + /** Total number of attempts (first try included). */ + maxAttempts?: number; + initialDelay?: number; + maxDelay?: number; + logger?: typeof serverLogger; + /** Per-attempt timeout; aborts the attempt's signal with an AbortError. */ + timeoutMs?: number; + /** Return false to rethrow immediately without further attempts (default: always retry). */ + shouldRetry?: (error: unknown, attempt: number) => boolean; + /** Override the exponential backoff delay for the wait after `attempt` (0-based). */ + computeDelay?: (attempt: number, error: unknown) => number; + /** Called before each backoff wait; replaces the default warn log. */ + onRetry?: (info: { error: Error; attempt: number; delay: number; isTimeout: boolean }) => void; + /** Wrap the terminal error once all attempts are exhausted (default: rethrow as-is). */ + wrapFinalError?: (lastError: Error, lastAttempt: number) => Error; +} + export async function retryWithBackoff( - fn: () => Promise, - options: { - maxRetries?: number; - initialDelay?: number; - maxDelay?: number; - logger?: typeof serverLogger; - } = {}, + fn: (signal: AbortSignal | undefined, attempt: number) => Promise, + options: RetryWithBackoffOptions = {}, ): Promise { const { - maxRetries = DEFAULT_RETRY_MAX_ATTEMPTS, + maxAttempts = DEFAULT_RETRY_MAX_ATTEMPTS, initialDelay = DEFAULT_RETRY_INITIAL_DELAY_MS, maxDelay = DEFAULT_RETRY_MAX_DELAY_MS, logger: retryLogger = serverLogger, + timeoutMs, + shouldRetry, + computeDelay, + onRetry, + wrapFinalError, } = options; - let lastError: unknown; - let delay = initialDelay; + let lastError: Error | undefined; + + for (let attempt = 0; attempt < maxAttempts; attempt++) { + const controller = timeoutMs === undefined ? undefined : new AbortController(); + const timeoutId = controller === undefined + ? undefined + : setTimeout(() => controller.abort(), timeoutMs); - for (let attempt = 0; attempt < maxRetries; attempt++) { try { - return await fn(); + return await fn(controller?.signal, attempt); } catch (error) { - lastError = error; - safeLog(() => retryLogger.warn(`Attempt ${attempt + 1} failed, retrying...`, error)); + lastError = error instanceof Error ? error : new Error(String(error)); + + if (shouldRetry && !shouldRetry(error, attempt)) { + throw error; + } + + if (attempt >= maxAttempts - 1) { + break; + } + + const delay = computeDelay + ? computeDelay(attempt, error) + : Math.min(initialDelay * 2 ** attempt, maxDelay); + const isTimeout = lastError.name === "AbortError"; - if (attempt >= maxRetries - 1) { - continue; + if (onRetry) { + onRetry({ error: lastError, attempt, delay, isTimeout }); + } else { + safeLog(() => retryLogger.warn(`Attempt ${attempt + 1} failed, retrying...`, lastError)); } - // no cleanup needed: one-shot - await new Promise((resolve) => setTimeout(resolve, delay)); - delay = Math.min(delay * 2, maxDelay); + await sleep(delay); + } finally { + clearTimeout(timeoutId); } } - throw lastError; + const finalError = lastError ?? new Error("Retry failed without capturing an error"); + throw wrapFinalError ? wrapFinalError(finalError, Math.max(0, maxAttempts - 1)) : finalError; } diff --git a/src/errors/index.ts b/src/errors/index.ts index 5600f0ea47..68fba73103 100644 --- a/src/errors/index.ts +++ b/src/errors/index.ts @@ -160,6 +160,7 @@ export { handleErrorWithFallback, handleErrorWithFallbackSync, retryWithBackoff, + type RetryWithBackoffOptions, } from "./error-handlers.ts"; export { diff --git a/src/platform/adapters/fs/github/github-api-client.ts b/src/platform/adapters/fs/github/github-api-client.ts index 7df0d11490..755a0d0f58 100644 --- a/src/platform/adapters/fs/github/github-api-client.ts +++ b/src/platform/adapters/fs/github/github-api-client.ts @@ -1,4 +1,4 @@ -import { createError, toError } from "#veryfront/errors"; +import { createError, retryWithBackoff, toError } from "#veryfront/errors"; import { logger } from "#veryfront/utils"; import type { ResolvedGitHubConfig } from "./types.ts"; import { @@ -81,12 +81,11 @@ export class GitHubApiClient { return this.rateLimitInfo; } - private async request(endpoint: string): Promise { + private request(endpoint: string): Promise { const url = `${this.baseUrl}${endpoint}`; - let lastError: Error | null = null; - for (let attempt = 1; attempt <= this.config.retry.maxRetries; attempt++) { - try { + return retryWithBackoff( + async () => { const response = await fetch(url, { headers: { Authorization: `Bearer ${this.config.token}`, @@ -103,27 +102,29 @@ export class GitHubApiClient { throw this.createAPIError(response.status, errorBody, endpoint); } - return await response.json(); - } catch (error) { - lastError = error instanceof Error ? error : new Error(String(error)); - - if (this.isClientError(lastError) && !this.isRateLimitError(lastError)) { - throw lastError; - } - - if (attempt >= this.config.retry.maxRetries) break; - - const delay = this.calculateRetryDelay(attempt, lastError); - logger.warn(`${LOG_PREFIX} Request failed, retrying`, { - attempt, - delay, - error: lastError.message, - }); - await this.sleep(delay); - } - } - - throw lastError ?? new Error("Request failed after retries"); + return response.json(); + }, + { + maxAttempts: this.config.retry.maxRetries, + initialDelay: this.config.retry.initialDelay, + maxDelay: this.config.retry.maxDelay, + shouldRetry: (error) => { + const err = error instanceof Error ? error : new Error(String(error)); + return !(this.isClientError(err) && !this.isRateLimitError(err)); + }, + computeDelay: (attempt, error) => { + const err = error instanceof Error ? error : new Error(String(error)); + return this.calculateRetryDelay(attempt + 1, err); + }, + onRetry: ({ error, attempt, delay }) => { + logger.warn(`${LOG_PREFIX} Request failed, retrying`, { + attempt: attempt + 1, + delay, + error: error.message, + }); + }, + }, + ); } private updateRateLimitInfo(response: Response): void { @@ -221,9 +222,4 @@ export class GitHubApiClient { return delay + Math.random() * RETRY_JITTER_MAX_MS; } - - // no cleanup needed: one-shot - private sleep(ms: number): Promise { - return new Promise((resolve) => setTimeout(resolve, ms)); - } } diff --git a/src/platform/adapters/fs/veryfront/retry.ts b/src/platform/adapters/fs/veryfront/retry.ts index 3d2e5c9174..e28bc7de3f 100644 --- a/src/platform/adapters/fs/veryfront/retry.ts +++ b/src/platform/adapters/fs/veryfront/retry.ts @@ -8,6 +8,7 @@ */ import { logger as baseLogger } from "#veryfront/utils"; +import { retryWithBackoff } from "#veryfront/errors/error-handlers.ts"; const logger = baseLogger.component("fs-retry"); @@ -57,22 +58,18 @@ function isTransientError(error: unknown): boolean { * Execute an async function with a single retry for transient errors. * Non-transient errors (4xx, validation) are thrown immediately. */ -export async function withRetryOnTransient( +export function withRetryOnTransient( fn: () => Promise, context: string, ): Promise { - try { - return await fn(); - } catch (error) { - if (!isTransientError(error)) throw error; - - logger.warn(`${context} — transient error, retrying once`, { - error: error instanceof Error ? error.message : String(error), - }); - - // no cleanup needed: one-shot - await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS)); - - return fn(); - } + return retryWithBackoff(() => fn(), { + maxAttempts: 2, + computeDelay: () => RETRY_DELAY_MS, + shouldRetry: (error) => isTransientError(error), + onRetry: ({ error }) => { + logger.warn(`${context} — transient error, retrying once`, { + error: error.message, + }); + }, + }); } diff --git a/src/platform/adapters/token/veryfront/api-client.ts b/src/platform/adapters/token/veryfront/api-client.ts index 38fbb2e724..dde266e734 100644 --- a/src/platform/adapters/token/veryfront/api-client.ts +++ b/src/platform/adapters/token/veryfront/api-client.ts @@ -3,6 +3,7 @@ import { injectContext } from "#veryfront/observability/tracing/otlp-setup.ts"; import { type VeryfrontTokenConfig } from "./types.ts"; import { TOKEN_STORAGE_ERROR } from "#veryfront/errors/error-registry.ts"; import { VeryfrontError } from "#veryfront/errors/types.ts"; +import { retryWithBackoff } from "#veryfront/errors/error-handlers.ts"; const logger = baseLogger.component("token-storage-api-client"); @@ -190,72 +191,62 @@ export class TokenStorageApiClient { return TOKEN_STORAGE_ERROR.create({ detail: `${prefixMessage}: ${message}` }); } + private logTimedOut(url: string, timeoutMs: number, attempt: number): void { + logger.warn("Request timed out", { + url: url.replace(/token=[^&]+/, "token=***"), + timeoutMs, + attempt: attempt + 1, + }); + } + private async fetchWithRetry(url: string, init: RequestInit): Promise { const { maxRetries, initialDelay, maxDelay } = this.config.retry; const timeoutMs = this.config.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS; - let lastError: Error | undefined; - for (let attempt = 0; attempt <= maxRetries; attempt++) { - const controller = new AbortController(); - const timeoutId = setTimeout(() => controller.abort(), timeoutMs); - - try { + return retryWithBackoff( + (signal) => { const headers = new Headers(init.headers); injectContext(headers); - const response = await fetch(url, { - ...init, - headers, - signal: controller.signal, - }); - - if (response.status >= 400 && response.status < 500 && response.status !== 429) { - return response; - } - - if (!response.ok && (response.status >= 500 || response.status === 429)) { - throw TOKEN_STORAGE_ERROR.create({ - detail: `Server error: ${response.status}`, - status: response.status, - }); - } + return fetch(url, { ...init, headers, signal }).then((response) => { + if (response.status >= 400 && response.status < 500 && response.status !== 429) { + return response; + } - return response; - } catch (error) { - lastError = error instanceof Error ? error : new Error(String(error)); + if (!response.ok && (response.status >= 500 || response.status === 429)) { + throw TOKEN_STORAGE_ERROR.create({ + detail: `Server error: ${response.status}`, + status: response.status, + }); + } - const isTimeout = error instanceof Error && error.name === "AbortError"; - if (isTimeout) { - logger.warn("Request timed out", { - url: url.replace(/token=[^&]+/, "token=***"), - timeoutMs, + return response; + }); + }, + { + maxAttempts: maxRetries + 1, + initialDelay, + maxDelay, + timeoutMs, + onRetry: ({ error, attempt, delay, isTimeout }) => { + if (isTimeout) this.logTimedOut(url, timeoutMs, attempt); + + logger.warn("Request failed, retrying...", { attempt: attempt + 1, + maxRetries, + delay, + error: error.message, + timeout: isTimeout, }); - } - - if (attempt >= maxRetries) { - break; - } - - const delay = Math.min(initialDelay * Math.pow(2, attempt), maxDelay); - - logger.warn("Request failed, retrying...", { - attempt: attempt + 1, - maxRetries, - delay, - error: lastError.message, - timeout: isTimeout, - }); - - // no cleanup needed: one-shot - await new Promise((resolve) => setTimeout(resolve, delay)); - } finally { - clearTimeout(timeoutId); - } - } + }, + wrapFinalError: (lastError, lastAttempt) => { + if (lastError.name === "AbortError") this.logTimedOut(url, timeoutMs, lastAttempt); - throw TOKEN_STORAGE_ERROR.create({ - detail: `Request failed after ${maxRetries} retries: ${lastError?.message}`, - }); + return TOKEN_STORAGE_ERROR.create({ + detail: `Request failed after ${maxRetries} retries: ${lastError.message}`, + }); + }, + }, + ); } } diff --git a/src/platform/adapters/veryfront-api-client/retry-handler.ts b/src/platform/adapters/veryfront-api-client/retry-handler.ts index 0b201f60db..850b67b028 100644 --- a/src/platform/adapters/veryfront-api-client/retry-handler.ts +++ b/src/platform/adapters/veryfront-api-client/retry-handler.ts @@ -1,4 +1,5 @@ import { logger } from "#veryfront/utils"; +import { retryWithBackoff } from "#veryfront/errors/error-handlers.ts"; import { injectContext, withSpan } from "#veryfront/observability/tracing/otlp-setup.ts"; import { SpanNames } from "#veryfront/observability/tracing/span-names.ts"; import { @@ -30,6 +31,14 @@ export interface RequestOptions { /** Default timeout for API requests (30 seconds) */ const DEFAULT_REQUEST_TIMEOUT_MS = 30_000; +function logTimedOut(url: string, timeoutMs: number, attempt: number): void { + veryfrontApiClientLog.warn("Request timed out", { + url: url.replace(/token=[^&]+/, "token=***"), + timeoutMs, + attempt: attempt + 1, + }); +} + export async function requestWithRetry( url: string, apiToken: string, @@ -43,14 +52,9 @@ export async function requestWithRetry( // Note: We only trace the individual fetch attempts (HTTP_CLIENT_FETCH), // not the outer retry wrapper, to reduce span nesting and trace size. - let lastError: Error | null = null; - - for (let attempt = 0; attempt <= maxRetries; attempt++) { - const controller = new AbortController(); - const timeoutId = setTimeout(() => controller.abort(), timeoutMs); - - try { - const result = await withSpan( + const result = await retryWithBackoff( + (signal, attempt) => { + return withSpan( SpanNames.HTTP_CLIENT_FETCH, async () => { const startTime = performance.now(); @@ -66,7 +70,7 @@ export async function requestWithRetry( method: options.method ?? "GET", headers, body: options.body, - signal: controller.signal, + signal, }); const duration = performance.now() - startTime; @@ -113,53 +117,41 @@ export async function requestWithRetry( "http.retry_attempt": attempt, }, ); + }, + { + maxAttempts: maxRetries + 1, + initialDelay, + maxDelay, + timeoutMs, + shouldRetry: (error) => { + if (!(error instanceof VeryfrontError) || error.slug !== "api-client-error") return true; + const status = error.status; + return !status || status < 400 || status >= 500 || status === 429; + }, + onRetry: ({ error, attempt, delay, isTimeout }) => { + if (isTimeout) logTimedOut(url, timeoutMs, attempt); - return result.data; - } catch (error) { - lastError = error instanceof Error ? error : new Error(String(error)); + recordApiRetry(); - const isTimeout = lastError.name === "AbortError"; - if (isTimeout) { - veryfrontApiClientLog.warn("Request timed out", { - url: url.replace(/token=[^&]+/, "token=***"), - timeoutMs, + veryfrontApiClientLog.warn("Request failed, retrying...", { attempt: attempt + 1, + maxRetries, + delay, + error: error.message, + timeout: isTimeout, + }); + }, + wrapFinalError: (lastError, lastAttempt) => { + if (lastError.name === "AbortError") logTimedOut(url, timeoutMs, lastAttempt); + + return API_CLIENT_ERROR.create({ + detail: `API request failed after ${maxRetries} retries: ${lastError.message}`, + cause: lastError, + context: { details: { originalError: lastError } }, }); - } + }, + }, + ); - if (error instanceof VeryfrontError && error.slug === "api-client-error") { - const status = error.status; - if (status && status >= 400 && status < 500 && status !== 429) { - throw error; - } - } - - if (attempt >= maxRetries) { - break; - } - - const delay = Math.min(initialDelay * 2 ** attempt, maxDelay); - - recordApiRetry(); - - veryfrontApiClientLog.warn("Request failed, retrying...", { - attempt: attempt + 1, - maxRetries, - delay, - error: lastError.message, - timeout: isTimeout, - }); - - // no cleanup needed: one-shot - await new Promise((resolve) => setTimeout(resolve, delay)); - } finally { - clearTimeout(timeoutId); - } - } - - throw API_CLIENT_ERROR.create({ - detail: `API request failed after ${maxRetries} retries: ${lastError?.message}`, - cause: lastError ?? undefined, - context: { details: { originalError: lastError } }, - }); + return result.data; } diff --git a/src/workflow/executor/dag/composite-node-execution.ts b/src/workflow/executor/dag/composite-node-execution.ts index a77bc77908..88c7c02ffe 100644 --- a/src/workflow/executor/dag/composite-node-execution.ts +++ b/src/workflow/executor/dag/composite-node-execution.ts @@ -1,17 +1,13 @@ import { TIMEOUT_ERROR } from "#veryfront/errors"; -import { isVeryfrontError } from "#veryfront/errors/http-error.ts"; import { ensureError } from "#veryfront/errors/veryfront-error.ts"; import type { RetryConfig, WorkflowNode } from "../../types.ts"; import { parseDuration, validateRetryConfig } from "../../types.ts"; import type { NodeExecutionResult } from "./types.ts"; import { sleep } from "#veryfront/utils"; import { createSetContextPatch } from "./context-patch.ts"; +import { calculateRetryDelay, isRetryableWorkflowError } from "../retry-policy.ts"; -const DEFAULT_RETRY_INITIAL_DELAY_MS = 1_000; -const DEFAULT_RETRY_MAX_DELAY_MS = 30_000; const DEFAULT_CANCELLATION_GRACE_PERIOD_MS = 1_000; -const RETRYABLE_STATUSES = new Set([408, 425, 429, 500, 502, 503, 504]); -const RETRYABLE_CODE_RE = /\b(ECONNRESET|ECONNREFUSED|ETIMEDOUT|EPIPE|EAI_AGAIN|ENOTFOUND)\b/; interface CompositeNodeExecutionInput { node: WorkflowNode; @@ -168,22 +164,5 @@ function withAttempt(result: NodeExecutionResult, attempt: number): NodeExecutio function isRetryableError(error: Error, config: RetryConfig | undefined): boolean { if (nonCooperativeErrors.has(error)) return false; - if (config?.retryIf) return config.retryIf(error); - if (isVeryfrontError(error)) return RETRYABLE_STATUSES.has(error.status); - - const code = (error as { code?: unknown }).code; - const subject = typeof code === "string" ? code : error.message; - return RETRYABLE_CODE_RE.test(subject); -} - -function calculateRetryDelay(attempt: number, config: RetryConfig | undefined): number { - const initialDelay = config?.initialDelay ?? DEFAULT_RETRY_INITIAL_DELAY_MS; - const maxDelay = config?.maxDelay ?? DEFAULT_RETRY_MAX_DELAY_MS; - - let baseDelay = initialDelay; - if (config?.backoff === "exponential") baseDelay = initialDelay * Math.pow(2, attempt - 1); - else if (config?.backoff === "linear") baseDelay = initialDelay * attempt; - - const jitter = baseDelay * 0.1 * (Math.random() * 2 - 1); - return Math.floor(Math.min(baseDelay + jitter, maxDelay)); + return isRetryableWorkflowError(error, config); } diff --git a/src/workflow/executor/retry-policy.ts b/src/workflow/executor/retry-policy.ts new file mode 100644 index 0000000000..ad1377fffd --- /dev/null +++ b/src/workflow/executor/retry-policy.ts @@ -0,0 +1,51 @@ +import { isVeryfrontError } from "#veryfront/errors/http-error.ts"; +import type { RetryConfig } from "../types.ts"; + +/** Default initial delay before first retry attempt */ +export const DEFAULT_RETRY_INITIAL_DELAY_MS = 1_000; + +/** Default maximum delay between retry attempts */ +export const DEFAULT_RETRY_MAX_DELAY_MS = 30_000; + +const RETRYABLE_STATUSES = new Set([408, 425, 429, 500, 502, 503, 504]); + +/** + * Node/Deno transient network error codes. Matched as whole tokens against + * error.code (or, when a plain Error carries no code, its message). Unlike + * "429"/"503"/"timeout", these tokens are specific enough not to appear + * incidentally in unrelated error text. + */ +const RETRYABLE_CODE_RE = /\b(ECONNRESET|ECONNREFUSED|ETIMEDOUT|EPIPE|EAI_AGAIN|ENOTFOUND)\b/; + +/** + * Shared transient-error classification for workflow retries. Callers are + * responsible for non-cooperative-error bookkeeping before consulting this. + */ +export function isRetryableWorkflowError(error: Error, config: RetryConfig | undefined): boolean { + if (config?.retryIf) return config.retryIf(error); + + // Prefer structured signals over substring-matching the message: an error + // whose text merely contains "429" or "timeout" (e.g. "Found 429 items") + // must NOT be retried. VeryfrontError carries an HTTP-style status, so HTTP + // conditions (429/503/timeout) are classified by status, not text. + if (isVeryfrontError(error)) return RETRYABLE_STATUSES.has(error.status); + + // System/network errors: use the stable `code` when present, else fall back + // to the message but only for the specific code tokens above. + const code = (error as { code?: unknown }).code; + const subject = typeof code === "string" ? code : error.message; + return RETRYABLE_CODE_RE.test(subject); +} + +/** Backoff delay (fixed/linear/exponential per config) with ±10% jitter. */ +export function calculateRetryDelay(attempt: number, config: RetryConfig | undefined): number { + const initialDelay = config?.initialDelay ?? DEFAULT_RETRY_INITIAL_DELAY_MS; + const maxDelay = config?.maxDelay ?? DEFAULT_RETRY_MAX_DELAY_MS; + + let baseDelay = initialDelay; + if (config?.backoff === "exponential") baseDelay = initialDelay * Math.pow(2, attempt - 1); + else if (config?.backoff === "linear") baseDelay = initialDelay * attempt; + + const jitter = baseDelay * 0.1 * (Math.random() * 2 - 1); + return Math.floor(Math.min(baseDelay + jitter, maxDelay)); +} diff --git a/src/workflow/executor/step-executor.ts b/src/workflow/executor/step-executor.ts index 06f1744396..7eafc929fd 100644 --- a/src/workflow/executor/step-executor.ts +++ b/src/workflow/executor/step-executor.ts @@ -12,11 +12,17 @@ import { ensureError, INITIALIZATION_ERROR, INVALID_ARGUMENT, - isVeryfrontError, ORCHESTRATION_ERROR, RESOURCE_NOT_FOUND, TIMEOUT_ERROR, } from "#veryfront/errors"; +import { sleep } from "#veryfront/utils"; +import { + calculateRetryDelay, + DEFAULT_RETRY_INITIAL_DELAY_MS, + DEFAULT_RETRY_MAX_DELAY_MS, + isRetryableWorkflowError, +} from "./retry-policy.ts"; import type { CapturedTenantContext, NodeState, @@ -96,12 +102,6 @@ export function runWithWorkflowTenant( ); } -/** Default initial delay before first retry attempt */ -const DEFAULT_RETRY_INITIAL_DELAY_MS = 1_000; - -/** Default maximum delay between retry attempts */ -const DEFAULT_RETRY_MAX_DELAY_MS = 30_000; - const DEFAULT_RETRY: RetryConfig = { maxAttempts: 1, backoff: "exponential", @@ -212,7 +212,7 @@ export class StepExecutor { lastError = ensureError(error); if (attempt < maxAttempts && this.isRetryableError(lastError, retryConfig)) { - await this.sleep(this.calculateRetryDelay(attempt, retryConfig), abortSignal); + await sleep(calculateRetryDelay(attempt, retryConfig), abortSignal); continue; } @@ -234,65 +234,11 @@ export class StepExecutor { } /** HTTP-style statuses worth retrying: timeout, rate limit, and transient 5xx. */ - private static readonly RETRYABLE_STATUSES = new Set([408, 425, 429, 500, 502, 503, 504]); - - /** - * Node/Deno transient network error codes. Matched as whole tokens against - * error.code (or, when a plain Error carries no code, its message). Unlike - * "429"/"503"/"timeout", these tokens are specific enough not to appear - * incidentally in unrelated error text. - */ - private static readonly RETRYABLE_CODE_RE = - /\b(ECONNRESET|ECONNREFUSED|ETIMEDOUT|EPIPE|EAI_AGAIN|ENOTFOUND)\b/; - private isRetryableError(error: Error, config: RetryConfig): boolean { // Starting another attempt while the timed-out operation is still active // would violate step isolation and allow concurrent external side effects. if (this.nonCooperativeErrors.has(error)) return false; - if (config.retryIf) return config.retryIf(error); - - // Prefer structured signals over substring-matching the message: an error - // whose text merely contains "429" or "timeout" (e.g. "Found 429 items") - // must NOT be retried. VeryfrontError carries an HTTP-style status, so HTTP - // conditions (429/503/timeout) are classified by status, not text. - if (isVeryfrontError(error)) { - return StepExecutor.RETRYABLE_STATUSES.has(error.status); - } - - // System/network errors: use the stable `code` when present, else fall back - // to the message but only for the specific code tokens above. - const code = (error as { code?: unknown }).code; - const subject = typeof code === "string" ? code : error.message; - return StepExecutor.RETRYABLE_CODE_RE.test(subject); - } - - private calculateRetryDelay(attempt: number, config: RetryConfig): number { - const initialDelay = config.initialDelay ?? DEFAULT_RETRY_INITIAL_DELAY_MS; - const maxDelay = config.maxDelay ?? DEFAULT_RETRY_MAX_DELAY_MS; - - let baseDelay = initialDelay; - if (config.backoff === "exponential") baseDelay = initialDelay * Math.pow(2, attempt - 1); - else if (config.backoff === "linear") baseDelay = initialDelay * attempt; - - const jitter = baseDelay * 0.1 * (Math.random() * 2 - 1); - return Math.floor(Math.min(baseDelay + jitter, maxDelay)); - } - - private sleep(ms: number, abortSignal?: AbortSignal): Promise { - abortSignal?.throwIfAborted(); - return new Promise((resolve, reject) => { - const timeoutId = setTimeout(() => { - abortSignal?.removeEventListener("abort", onAbort); - resolve(); - }, ms); - const onAbort = () => { - clearTimeout(timeoutId); - abortSignal?.removeEventListener("abort", onAbort); - reject(abortSignal?.reason); - }; - abortSignal?.addEventListener("abort", onAbort, { once: true }); - if (abortSignal?.aborted) onAbort(); - }); + return isRetryableWorkflowError(error, config); } private async resolveInput( From 0d341469905b136dd0ed972c5ff9400386258d8e Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Thu, 23 Jul 2026 19:36:51 +0200 Subject: [PATCH 2/5] test(errors): cover retryWithBackoff hook behaviors Adds focused tests for shouldRetry short-circuit (original error rethrown, single attempt), per-attempt timeoutMs abort (AbortError + isTimeout in onRetry), computeDelay (0-based attempt, thrown error, override used), and wrapFinalError (wraps terminal error, receives last attempt index). --- src/errors/error-handlers.test.ts | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/errors/error-handlers.test.ts b/src/errors/error-handlers.test.ts index 13363cd3f7..fcc0867412 100644 --- a/src/errors/error-handlers.test.ts +++ b/src/errors/error-handlers.test.ts @@ -102,5 +102,84 @@ describe("error-handlers", () => { assertEquals(attempts, 2); }); + + it("should rethrow the original error immediately when shouldRetry returns false", async () => { + let attempts = 0; + const original = new Error("fatal"); + + const thrown = await assertRejects(() => + retryWithBackoff(async () => { + await Promise.resolve(); + attempts++; + throw original; + }, { maxAttempts: 3, initialDelay: 1, shouldRetry: () => false }) + ); + + assertEquals(thrown, original); + assertEquals(attempts, 1); + }); + + it("should abort each attempt after timeoutMs and report isTimeout to onRetry", async () => { + const retryErrorNames: string[] = []; + const timeoutFlags: boolean[] = []; + + await assertRejects(() => + retryWithBackoff( + (signal) => + new Promise((_, reject) => { + signal?.addEventListener("abort", () => reject(signal.reason), { once: true }); + }), + { + maxAttempts: 2, + initialDelay: 1, + timeoutMs: 5, + onRetry: ({ error, isTimeout }) => { + retryErrorNames.push(error.name); + timeoutFlags.push(isTimeout); + }, + }, + ) + ); + + assertEquals(retryErrorNames, ["AbortError"]); + assertEquals(timeoutFlags, [true]); + }); + + it("should use computeDelay with 0-based attempt and the thrown error", async () => { + const observed: Array<[number, string]> = []; + let attempts = 0; + + const result = await retryWithBackoff(async () => { + await Promise.resolve(); + attempts++; + if (attempts < 3) throw new Error(`fail ${attempts}`); + return "ok"; + }, { + maxAttempts: 3, + computeDelay: (attempt, error) => { + observed.push([attempt, (error as Error).message]); + return 1; + }, + }); + + assertEquals(result, "ok"); + assertEquals(observed, [[0, "fail 1"], [1, "fail 2"]]); + }); + + it("should wrap the terminal error with wrapFinalError and pass the last attempt", async () => { + const thrown = await assertRejects(() => + retryWithBackoff(async () => { + await Promise.resolve(); + throw new Error("boom"); + }, { + maxAttempts: 2, + initialDelay: 1, + wrapFinalError: (lastError, lastAttempt) => + new Error(`wrapped:${lastError.message}:${lastAttempt}`), + }) + ); + + assertEquals((thrown as Error).message, "wrapped:boom:1"); + }); }); }); From 5ecedaf87cf3358fcaefca37a6a351020aaba2e8 Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Thu, 23 Jul 2026 19:39:29 +0200 Subject: [PATCH 3/5] fix(errors): reject invalid maxAttempts in retryWithBackoff with a clear RangeError --- src/errors/error-handlers.test.ts | 8 ++++++++ src/errors/error-handlers.ts | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/errors/error-handlers.test.ts b/src/errors/error-handlers.test.ts index fcc0867412..ed849cf0e2 100644 --- a/src/errors/error-handlers.test.ts +++ b/src/errors/error-handlers.test.ts @@ -103,6 +103,14 @@ describe("error-handlers", () => { assertEquals(attempts, 2); }); + it("should reject invalid maxAttempts with a RangeError", async () => { + await assertRejects( + () => retryWithBackoff(() => Promise.resolve("never"), { maxAttempts: 0 }), + RangeError, + "maxAttempts", + ); + }); + it("should rethrow the original error immediately when shouldRetry returns false", async () => { let attempts = 0; const original = new Error("fatal"); diff --git a/src/errors/error-handlers.ts b/src/errors/error-handlers.ts index fffae6ea6f..06f08d9a93 100644 --- a/src/errors/error-handlers.ts +++ b/src/errors/error-handlers.ts @@ -79,6 +79,12 @@ export async function retryWithBackoff( wrapFinalError, } = options; + if (!Number.isInteger(maxAttempts) || maxAttempts < 1) { + throw new RangeError( + `retryWithBackoff requires an integer maxAttempts >= 1, got ${maxAttempts}`, + ); + } + let lastError: Error | undefined; for (let attempt = 0; attempt < maxAttempts; attempt++) { From 4aeb44a3696c5f07a5c3a809d1a18fc3ecba4f05 Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Thu, 23 Jul 2026 19:48:29 +0200 Subject: [PATCH 4/5] docs(errors): clarify 0-based attempt indexing and github maxRetries semantics --- src/errors/error-handlers.ts | 7 ++++++- src/platform/adapters/fs/github/github-api-client.ts | 3 +++ src/server/services/rsc/endpoints/rsc-bundles.generated.ts | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/errors/error-handlers.ts b/src/errors/error-handlers.ts index 06f08d9a93..1cf2616a18 100644 --- a/src/errors/error-handlers.ts +++ b/src/errors/error-handlers.ts @@ -45,6 +45,11 @@ export function handleErrorWithFallbackSync( } } +/** + * Options for {@link retryWithBackoff}. Every `attempt` value passed to `fn` + * and the hooks below is 0-based (first try = 0), including + * `wrapFinalError`'s `lastAttempt`. + */ export interface RetryWithBackoffOptions { /** Total number of attempts (first try included). */ maxAttempts?: number; @@ -55,7 +60,7 @@ export interface RetryWithBackoffOptions { timeoutMs?: number; /** Return false to rethrow immediately without further attempts (default: always retry). */ shouldRetry?: (error: unknown, attempt: number) => boolean; - /** Override the exponential backoff delay for the wait after `attempt` (0-based). */ + /** Override the exponential backoff delay for the wait after `attempt`. */ computeDelay?: (attempt: number, error: unknown) => number; /** Called before each backoff wait; replaces the default warn log. */ onRetry?: (info: { error: Error; attempt: number; delay: number; isTimeout: boolean }) => void; diff --git a/src/platform/adapters/fs/github/github-api-client.ts b/src/platform/adapters/fs/github/github-api-client.ts index 755a0d0f58..155e38a097 100644 --- a/src/platform/adapters/fs/github/github-api-client.ts +++ b/src/platform/adapters/fs/github/github-api-client.ts @@ -105,6 +105,9 @@ export class GitHubApiClient { return response.json(); }, { + // This client's config.retry.maxRetries has always meant TOTAL attempts + // (the old loop ran `attempt = 1..maxRetries`), unlike the veryfront-api + // clients where maxRetries means retries after the first try. maxAttempts: this.config.retry.maxRetries, initialDelay: this.config.retry.initialDelay, maxDelay: this.config.retry.maxDelay, diff --git a/src/server/services/rsc/endpoints/rsc-bundles.generated.ts b/src/server/services/rsc/endpoints/rsc-bundles.generated.ts index 95c9fabc81..108322f78f 100644 --- a/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +++ b/src/server/services/rsc/endpoints/rsc-bundles.generated.ts @@ -7,7 +7,7 @@ */ export const CLIENT_BOOT_BUNDLE: string = - 'var It=Object.defineProperty;var St=(t,e,r)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>St(t,typeof e!="symbol"?e+"":e,r);var Ot="3.2.3";function Nt(t,e,r,n){let s=[];if(n?.external?.length&&s.push(`external=${n.external.join(",")}`),s.push(`target=${n?.target??"es2022"}`),n?.deps){let a=Object.entries(n.deps).map(([d,f])=>`${d}@${f}`).join(",");s.push(`deps=${a}`)}let u=e?`@${e}`:"",c=r??"",g=s.length?`?${s.join("&")}`:"";return`https://esm.sh/${t}${u}${c}${g}`}function m(t,e,r,n=!1){return Nt(t,e,r,{external:n?["react"]:void 0,deps:{csstype:Ot}})}var Dt="19.2.4",_=Dt;function z(t=_){return{react:m("react",t),"react-dom":m("react-dom",t,void 0,!0),"react-dom/client":m("react-dom",t,"/client",!0),"react-dom/server":m("react-dom",t,"/server",!0),"react/jsx-runtime":m("react",t,"/jsx-runtime",!0),"react/jsx-dev-runtime":m("react",t,"/jsx-dev-runtime",!0)}}function J(t=_){return z(t).react}function X(t=_){return z(t)["react-dom/client"]}function vt(t){return t.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function bt(t){if(typeof globalThis.btoa=="function")try{return globalThis.btoa(t)}catch{let n=new TextEncoder().encode(t),s="";for(let u of n)s+=String.fromCharCode(u);return globalThis.btoa(s)}let e=globalThis.Buffer;if(e)return e.from(t,"utf8").toString("base64");throw new Error("Base64 encoding is not supported in this runtime")}function H(t){return vt(bt(t))}var so=Object.freeze({react:"","react-dom":"","react-dom/client":"","react-dom/server":"","react/jsx-runtime":"","react/jsx-dev-runtime":""});function O(t,e){if(!e)return!1;if(Object.prototype.hasOwnProperty.call(e,t))return!0;for(let r of Object.keys(e))if(r.endsWith("/")&&t.startsWith(r))return!0;return!1}function Mt(t){try{return JSON.parse(t)?.imports??{}}catch(e){return console.warn("Failed to parse import map JSON; treating as empty",{errorName:e instanceof Error?e.name:typeof e,inputLength:t.length}),{}}}function V(t=document){let e=t.querySelector(\'script[type="importmap"]\');return e?.textContent?Mt(e.textContent):{}}var l="/_veryfront",F={RSC:`${l}/rsc/`,FS:`${l}/fs/`,MODULES:`${l}/modules/`,PAGES:`${l}/pages/`,DATA:`${l}/data/`,LIB:`${l}/lib/`,CHUNKS:`${l}/chunks/`,CLIENT:`${l}/client/`},K={HMR_RUNTIME:`${l}/hmr-runtime.js`,HMR:`${l}/hmr.js`,ERROR_OVERLAY:`${l}/error-overlay.js`,DEV_LOADER:`${l}/dev-loader.js`,CLIENT_LOG:`${l}/log`,CLIENT_JS:`${l}/client.js`,ROUTER_JS:`${l}/router.js`,PREFETCH_JS:`${l}/prefetch.js`,MANIFEST_JSON:`${l}/manifest.json`,APP_JS:`${l}/app.js`,RSC_CLIENT:`${l}/rsc/client.js`,RSC_MANIFEST:`${l}/rsc/manifest`,RSC_STREAM:`${l}/rsc/stream`,RSC_PAYLOAD:`${l}/rsc/payload`,RSC_RENDER:`${l}/rsc/render`,RSC_PAGE:`${l}/rsc/page`,RSC_MODULE:`${l}/rsc/module`,RSC_DOM:`${l}/rsc/dom.js`,LIB_CHAT_REACT:`${l}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${l}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${l}/lib/chat/primitives.js`};var wt={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},uo=wt.CACHE;var go={HMR_RUNTIME:K.HMR_RUNTIME,ERROR_OVERLAY:K.ERROR_OVERLAY};var h=F.RSC,Z=F.FS,Q="veryfront-hydration-data",C="rsc-root";var R=class{constructor(e,r){p(this,"prefix",e);p(this,"level",r)}log(e,r,n,...s){this.level>e||r?.(n,...s)}debug(e,...r){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${e}`,...r)}info(e,...r){this.log(1,console.log,`[${this.prefix}] ${e}`,...r)}warn(e,...r){this.log(2,console.warn,`[${this.prefix}] WARN: ${e}`,...r)}error(e,...r){this.log(3,console.error,`[${this.prefix}] ERROR: ${e}`,...r)}};function Ut(){if(typeof window>"u")return 2;let t=globalThis;return t.__VERYFRONT_DEV__||t.__RSC_DEV__?t.__VERYFRONT_DEBUG__||t.__RSC_DEBUG__?0:1:2}var N=Ut(),i=new R("RSC",N),Eo=new R("PREFETCH",N),yo=new R("HYDRATE",N),_o=new R("VERYFRONT",N);function E(t=document){try{let e=t.getElementById(Q);return e?JSON.parse(e.textContent||"{}"):null}catch(e){return i.debug("hydration data parse failed",e),null}}function A(t){return t?.clientModuleStrategy?t.clientModuleStrategy:t?.dev?"fs":"rsc-module"}function Pt(t,e){if(!e)return t;let r=t.includes("?")?"&":"?";return`${t}${r}v=${encodeURIComponent(e)}`}function Ht(t,e){return Pt(`${Z}${H(t)}.js`,e)}function Vt(t,e){let r=e?`&v=${encodeURIComponent(e)}`:"";return`${h}module?rel=${encodeURIComponent(t)}${r}`}function D(t){if(t.strategy==="fs"){let e=t.absPath??t.rel;return e?Ht(e,t.version):null}return Vt(t.rel,t.version)}function v(t=document,e=_){let r=V(t);return{react:O("react",r)?"react":J(e),reactDomClient:O("react-dom/client",r)?"react-dom/client":X(e)}}function tt(t=document){let e=V(t);return O("veryfront/router",e)?"veryfront/router":null}function o(t){return{...t,create(e){return new k(e?.message||e?.detail||t.title,{slug:t.slug,category:t.category,status:e?.status??t.status,title:t.title,suggestion:t.suggestion,detail:e?.detail,cause:e?.cause,instance:e?.instance,context:e?.context})}}}var k=class extends Error{constructor(r,n){super(r);p(this,"slug");p(this,"category");p(this,"status");p(this,"title");p(this,"suggestion");p(this,"detail");p(this,"cause");p(this,"instance");p(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var Ft=o({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),kt=o({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),Gt=o({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),$t=o({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),Bt=o({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),Yt=o({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),jt=o({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),Wt=o({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),qt=o({slug:"webhook-config-invalid",category:"CONFIG",status:400,title:"Invalid webhook configuration",suggestion:"Check webhook definition fields, target settings, and eventFilter conditions"}),zt=o({slug:"schedule-config-invalid",category:"CONFIG",status:400,title:"Invalid schedule configuration",suggestion:"Check schedule definition fields, cron expression, target settings, and positive-integer limits"}),Jt=o({slug:"trigger-config-invalid",category:"CONFIG",status:400,title:"Invalid trigger configuration",suggestion:"Check trigger ID format (lowercase, alphanumeric, dots/slashes/hyphens) and ensure all input values are JSON-serializable"}),et={"config-not-found":Ft,"config-invalid":kt,"config-parse-error":Gt,"config-validation-error":$t,"config-type-error":Bt,"import-map-invalid":Yt,"cors-config-invalid":jt,"config-validation-failed":Wt,"webhook-config-invalid":qt,"schedule-config-invalid":zt,"trigger-config-invalid":Jt};var Xt=o({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),Kt=o({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),Zt=o({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),Qt=o({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),te=o({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),ee=o({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),re=o({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),oe=o({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),rt={"build-failed":Xt,"bundle-error":Kt,"typescript-error":Zt,"mdx-compile-error":Qt,"asset-optimization-error":te,"ssg-generation-error":ee,"sourcemap-error":re,"compilation-error":oe};var ne=o({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),se=o({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ie=o({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),ae=o({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),ce=o({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),le=o({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),ue=o({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),de=o({slug:"trigger-target-not-found",category:"RUNTIME",status:404,title:"Trigger target not found",suggestion:"Ensure the referenced task or workflow ID is registered in the project"}),ge=o({slug:"trigger-execution-failed",category:"RUNTIME",status:500,title:"Trigger target execution failed",suggestion:"Check the task or workflow for errors and review the trigger input"}),pe=o({slug:"trigger-not-supported",category:"RUNTIME",status:501,title:"Trigger target type not supported in local runtime",suggestion:"Use a workflow or task target for local trigger runs; agent targets require the Cloud runtime"}),ot={"hydration-mismatch":ne,"render-error":se,"component-error":ie,"layout-not-found":ae,"page-not-found":ce,"api-error":le,"middleware-error":ue,"trigger-target-not-found":de,"trigger-execution-failed":ge,"trigger-not-supported":pe};var fe=o({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),me=o({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),Re=o({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),Ee=o({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),ye=o({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),_e=o({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),nt={"route-conflict":fe,"invalid-route-file":me,"route-handler-invalid":Re,"dynamic-route-error":Ee,"route-params-error":ye,"api-route-error":_e};var he=o({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),Ce=o({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),Te=o({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),xe=o({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Ie=o({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Se=o({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),st={"module-not-found":he,"import-resolution-error":Ce,"circular-dependency":Te,"invalid-import":xe,"dependency-missing":Ie,"version-mismatch":Se};var Oe=o({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),Ne=o({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Ae=o({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),De=o({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),ve=o({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),be=o({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Me=o({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),Le=o({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),we=o({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Ue=o({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),Pe=o({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),He=o({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),Ve=o({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),Fe=o({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),ke=o({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),it={"port-in-use":Oe,"server-start-error":Ne,"cache-error":Ae,"file-watch-error":De,"request-error":ve,"service-overloaded":be,"semaphore-timeout":Me,"circuit-breaker-open":Le,"cache-path-mismatch":we,"network-error":Ue,"api-client-error":Pe,"token-storage-error":He,"cache-invariant-violation":Ve,"release-not-found":Fe,"fallback-exhausted":ke};var Ge=o({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),$e=o({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),Be=o({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),Ye=o({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),je=o({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),We=o({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),at={"client-boundary-violation":Ge,"server-only-in-client":$e,"client-only-in-server":Be,"invalid-use-client":Ye,"invalid-use-server":je,"rsc-payload-error":We};var qe=o({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),ze=o({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Je=o({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),Xe=o({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Ke=o({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),ct={"hmr-error":qe,"dev-server-error":ze,"fast-refresh-error":Je,"error-overlay-error":Xe,"source-map-error":Ke};var Ze=o({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),Qe=o({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),tr=o({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),er=o({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),lt={"deployment-error":Ze,"platform-error":Qe,"env-var-missing":tr,"production-build-required":er};var rr=o({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),or=o({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),nr=o({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),sr=o({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),ir=o({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),ar=o({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),cr=o({slug:"tool-id-conflict",category:"AGENT",status:409,title:"Tool ID conflict",suggestion:"Use a unique tool ID or rename one of the conflicting tools"}),ut={"agent-error":rr,"agent-not-found":or,"agent-timeout":nr,"agent-intent-error":sr,"orchestration-error":ir,"cost-limit-exceeded":ar,"tool-id-conflict":cr};var lr=o({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),ur=o({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),dr=o({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),gr=o({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),pr=o({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),fr=o({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),mr=o({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Rr=o({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),G=o({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),Er=o({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),dt={"unknown-error":lr,"permission-denied":ur,"file-not-found":dr,"resource-not-found":gr,"invalid-argument":pr,"timeout-error":fr,"initialization-error":mr,"not-supported":Rr,"security-violation":G,"input-validation-failed":Er};var Rn={...et,...rt,...ot,...nt,...st,...it,...at,...ct,...lt,...ut,...dt};var yr=[{source:String.raw`]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function _r(){return yr.map(({source:t,flags:e,name:r})=>({pattern:new RegExp(t,e),name:r}))}function hr(){let t=globalThis;return t.__VERYFRONT_DEV__===!0||t.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function T(t,e={}){let{allowInlineScripts:r=!1,strict:n=!1,warn:s=!0}=e;for(let{pattern:u,name:c}of _r())if(!(r&&c==="inline script")&&(u.lastIndex=0,!!u.test(t)&&(s&&console.warn(`[Security] Suspicious ${c} detected in server HTML`),n||!hr())))throw G.create({detail:`Potentially unsafe HTML: ${c} detected`});return t}function x(t,e){let r=e==="root"?C:`rsc-slot-${e}`,n=t.getElementById(r);if(n)return n;let s=t.createElement("div");return s.id=r,t.body.appendChild(s),s}function Cr(t,e){if(e.type!=="slot")return;let r=x(t,e.id);r.innerHTML=T(String(e.html??""))}function gt(t,e){let r=e.split(`\n`),n=r.pop()??"";for(let s of r){let u=s.trim();if(!u)continue;let c;try{c=JSON.parse(u)}catch(a){i.debug("[client-dom] malformed NDJSON line",{line:u,error:a instanceof Error?a.message:String(a)});continue}if(!c||typeof c!="object")continue;let g=c;if(g.type==="slot"){Cr(t,g);try{Ir(t,g.id||"root")}catch(a){i.debug("[client-dom] hydration optional failed",a)}}}return n}function Tr(t){return new Promise((e,r)=>{let n=()=>r(new DOMException("aborted","AbortError"));if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0})})}async function pt(t,e=document,r){let n="body"in t?t:null,s=n?.body??t;if(!s)return;let u=s.getReader(),c=new TextDecoder,g="",a=!1;try{for(;;){if(r?.aborted)throw new DOMException("aborted","AbortError");let d=u.read(),{done:f,value:y}=r?await Promise.race([d,Tr(r)]):await d;if(f){a=!0;break}g+=c.decode(y,{stream:!0}),g=gt(e,g)}g&>(e,`${g}\n`)}catch(d){throw d instanceof Error&&d.name==="AbortError"||i.debug("[client-dom] consumeNdjsonStream error",d),d}finally{try{await u.cancel()}catch(d){a||i.debug("[client-dom] reader.cancel failed",d)}try{u.releaseLock()}catch(d){i.debug("[client-dom] reader.releaseLock failed",d)}if(typeof s.cancel=="function")try{await s.cancel()}catch(d){i.debug("[client-dom] stream.cancel failed",d)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(d){i.debug("[client-dom] response.body.cancel failed",d)}}}function xr(t,e){let r=x(t,e),n=[],s=u=>{let c=u;c.dataset?.clientRef&&n.push(c);for(let g of u.children)s(g)};return s(r),n}function Ir(t,e){let r=xr(t,e);for(let n of r){let s=n.dataset?.clientRef;s&&(n.dataset.hydrated="true",i.debug("[client-dom] marked for hydration",s))}}var Sr=new Set(["server","client","html","fragment"]);function ft(t){if(!t)return[];try{let e=JSON.parse(t);return Nr(e)?e.nodes:[]}catch{return[]}}async function B(t,e,r){return await Promise.all(t.map(n=>Or(n,e,r)))}async function Or(t,e,r){if(t.type==="html")return t.text??t.html??"";let n=await B(t.children??[],e,r);if(t.type==="fragment"||t.type==="server"&&!t.component)return e.createElement(e.Fragment,{},...n);if(t.type==="server")return e.createElement(t.component,t.props??{},...n);let s=await r(t.component);return s?e.createElement(s,t.props??{},...n):null}function Nr(t){return!$(t)||t.version!==1||!Array.isArray(t.nodes)?!1:t.nodes.every(e=>mt(e,0))}function mt(t,e){return e>100||!$(t)||!Sr.has(t.type)||t.type==="html"&&typeof t.html!="string"&&typeof t.text!="string"||t.type==="client"&&typeof t.component!="string"||t.type==="server"&&t.component!==void 0&&typeof t.component!="string"||t.props!==void 0&&!$(t.props)?!1:t.children===void 0?!0:Array.isArray(t.children)&&t.children.every(r=>mt(r,e+1))}function $(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ar(t){if(!t)return{};let e={};for(let[r,n]of Object.entries(t))e[r]=Array.isArray(n)?n.join("/"):n;return e}async function b(t,e,r=document){try{let n=tt(r);if(!n)return t;let u=(await import(n)).wrapForHydration;return typeof u!="function"?t:u(t,{params:Ar(e?.params),frontmatter:e?.frontmatter??{}})}catch(n){return i.debug("router provider wrap failed",n),t}}var Dr=100;function vr(t,e){if(globalThis.__VF_CLIENT_MOD_CACHE??(globalThis.__VF_CLIENT_MOD_CACHE=new Map),globalThis.__VF_CLIENT_MOD_CACHE.size>=Dr){let r=globalThis.__VF_CLIENT_MOD_CACHE.keys().next().value;r&&globalThis.__VF_CLIENT_MOD_CACHE.delete(r)}globalThis.__VF_CLIENT_MOD_CACHE.set(t,e)}function Rt(t){let e=t.match(/^\\/app\\/(.+)#([\\w$.-]+)$/);if(e)return{rel:`/${e[1]||""}`,exportName:e[2]||"default"};let r=t.match(/^(\\/_veryfront\\/[^#]+)#([\\w$.-]+)$/);return r?{moduleUrl:r[1],exportName:r[2]||"default"}:(i.debug("hydrate: unrecognised client ref format, skipping",{ref:t}),null)}function br(t){let e=t.dataset?.rscProps;if(!e)return{};try{let r=JSON.parse(e);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch(r){return i.debug("hydrate: invalid client boundary props, using empty props",r),{}}}function Mr(t){return ft(t.dataset?.rscChildren)}async function Lr(){try{let t=await fetch("/_veryfront/rsc/manifest");return t.ok?await t.json():null}catch{return null}}async function Et(t,e,r){let n=wr(t,e,r),s=e.moduleUrl??e.rel;if(!s)return null;let u=`${s}#${t.hash??""}`;try{let c=globalThis.__VF_CLIENT_MOD_CACHE?.get(u);if(c)return c}catch(c){i.debug("hydrate: cache get failed",c)}if(!n)return null;try{let c=await import(n);try{vr(u,c)}catch(g){i.debug("hydrate: cache set failed",g)}return c}catch(c){return i.debug("hydrate: failed to import module",{moduleUrl:n,error:c}),null}}function wr(t,e,r){if(e.moduleUrl)return e.moduleUrl;if(!e.rel)return null;let n=t.graphIds?.client.find(s=>s.rel===e.rel)?.path;return D({strategy:r,rel:e.rel,absPath:n,version:t.hash})}function Ur(t){let e=Array.from(t.querySelectorAll("[data-client-ref]")),r=new Set(e);return e.filter(n=>{let s=n.parentElement;for(;s;){if(r.has(s))return!1;s=s.parentElement}return!0})}async function yt(t=document){let e=null;try{e=await Lr()}catch(a){i.debug("hydrate: fetch manifest failed",a)}if(!e){i.debug("hydrate: no manifest");return}let r=Ur(t);try{let a=globalThis.__VF_MANIFEST_HASH;if(!r.some(f=>f.dataset?.hydrated!=="true")&&a&&e.hash&&a===e.hash)return}catch(a){i.debug("hydrate: hmr hash read failed",a)}if(r.length===0){try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(a){i.debug("hydrate: set hash failed",a)}return}let n=E(t),s=A(n);try{if(globalThis.__VF_TEST_MODE__){globalThis.__VF_HYDRATE_CALLED=!0,globalThis.__VF_MANIFEST_HASH=e.hash??"";return}}catch(a){i.debug("hydrate: test mode flags failed",a)}let u=v(t,n?.reactVersion),[{default:c},{createRoot:g}]=await Promise.all([import(u.react),import(u.reactDomClient)]);for(let a of r){let d=a.dataset?.clientRef??"";if(!d||a.dataset?.hydrated==="true")continue;let f=Rt(d);if(!f)continue;let y=await Et(e,f,s);if(!y)continue;let j=y[f.exportName]??y.default;if(typeof j=="function")try{let L=g(a),_t=br(a),ht=Mr(a),Ct=await B(ht,{Fragment:c.Fragment,createElement(I,w,...S){return c.createElement(I,w,...S)}},async I=>{let w=e.modules.find(xt=>xt.id===I),S=e.components?.[I],W=w?.clientRef??(S?`${S}#default`:void 0);if(!W)return null;let U=Rt(W);if(!U)return null;let P=await Et(e,U,s);if(!P)return null;let q=P[U.exportName]??P.default;return typeof q=="function"?q:null}),Tt=await b(c.createElement(j,_t,...Ct),n,t);L.render(Tt),a.dataset.hydrated="true"}catch(L){i.warn("hydrate: render failed",L)}}try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(a){i.debug("hydrate: set hash failed (post)",a)}}async function Pr(){let t=E(document),e=v(document,t?.reactVersion),[r,n]=await Promise.all([import(e.react),import(e.reactDomClient)]);return{React:r,ReactDOM:n}}var Hr=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE"]);function Y(t){let e=t.getAttribute("style")??"";return t.hasAttribute("data-veryfront-head")||t.hasAttribute("hidden")||/(?:^|;)\\s*display\\s*:\\s*none(?:\\s*;|$)/i.test(e)||Hr.has(t.tagName.toUpperCase())}function Vr(t,e){return t.find(r=>r.tagName.toUpperCase()==="DIV"&&!!r.getAttribute("class")?.trim()&&!Y(r))??e}function Fr(t,e){return t===e}function kr(t,e){let r=document.createElement("div");r.setAttribute("data-veryfront-hydration-root","page");let n=t.find(s=>!Y(s));n?.parentNode===e?e.insertBefore(r,n):e.appendChild(r);for(let s of t)!Y(s)&&s.parentNode===e&&r.appendChild(s);return r}function Gr(t,e,r=document){return!!e?.pagePath&&typeof t?.__veryfrontRenderPage=="function"&&!!r.getElementById("root")}function $r(t,e){return e?.pagePath?!1:!!t.getElementById(C)}function Br(t=import.meta.url){try{return new URL(t,"http://veryfront.local").searchParams.get("hydrate")==="1"}catch{return!1}}function Yr(t){return t==="rsc-module"}async function jr(t){try{let e=await fetch(h+"stream"+t);if(!e.ok||!e.body)return!1;let r=new AbortController;return addEventListener("pagehide",()=>r.abort(),{once:!0}),await pt(e,document,r.signal),!0}catch(e){return i.debug("tryStream failed",e),!1}}async function M(){try{await yt(document)}catch(t){i.debug("hydration failed",t)}}async function Wr(t,e){try{let{React:r,ReactDOM:n}=await Pr(),s=D({strategy:e,rel:t});if(!s)return!1;i.debug("Loading component from:",s);let c=(await import(s)).default;if(typeof c!="function")return i.debug("Page component is not a function"),!1;let g=Array.from(document.body.children),a=Vr(g,document.body),d=Fr(a,document.body)?kr(g,document.body):a,f=await b(r.createElement(c,{}),E(document));return Yr(e)?n.createRoot(d).render(f):n.hydrateRoot(d,f,{identifierPrefix:"vf",onRecoverableError:()=>{}}),i.debug("Page component hydrated successfully"),!0}catch(r){return i.error("Page hydration failed",r),!1}}async function qr(t){try{let e=await fetch(h+"payload"+t);if(!e.ok)return!1;let r=await e.json();if(r?.slots){for(let[n,s]of Object.entries(r.slots))x(document,n).innerHTML=T(String(s||""));return!0}return x(document,C).innerHTML=T(String(r?.html||"")),!0}catch(e){return i.debug("payload fetch failed",e),!1}}async function zr(){try{let t=globalThis.window?.location.search??"",e=E(document);if(Br()){await M();return}let r=e?.pagePath,n=A(e);if(r){if(Gr(globalThis.window,e,document)){i.debug("Page renderer owns hydration");return}i.debug("Found page component in hydration data:",r),await Wr(r,n)&&i.debug("Client component hydrated successfully");return}if(!$r(document,e))return;if(await jr(t)){await M();return}if(await qr(t)){await M();return}await M()}catch(t){i.error("boot failed",t)}}if(typeof document<"u"){let t=()=>{zr()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{zr as boot,Vr as selectHydrationRoot,$r as shouldAttemptRSCTransport,Br as shouldHydrateOnly,Yr as shouldRenderPageComponent,Gr as shouldUsePageRendererHydration,Fr as shouldWrapPageHydrationRoot};\n'; + 'var It=Object.defineProperty;var St=(t,e,r)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>St(t,typeof e!="symbol"?e+"":e,r);var Ot="3.2.3";function Nt(t,e,r,n){let s=[];if(n?.external?.length&&s.push(`external=${n.external.join(",")}`),s.push(`target=${n?.target??"es2022"}`),n?.deps){let a=Object.entries(n.deps).map(([d,f])=>`${d}@${f}`).join(",");s.push(`deps=${a}`)}let u=e?`@${e}`:"",c=r??"",g=s.length?`?${s.join("&")}`:"";return`https://esm.sh/${t}${u}${c}${g}`}function m(t,e,r,n=!1){return Nt(t,e,r,{external:n?["react"]:void 0,deps:{csstype:Ot}})}var Dt="19.2.4",_=Dt;function z(t=_){return{react:m("react",t),"react-dom":m("react-dom",t,void 0,!0),"react-dom/client":m("react-dom",t,"/client",!0),"react-dom/server":m("react-dom",t,"/server",!0),"react/jsx-runtime":m("react",t,"/jsx-runtime",!0),"react/jsx-dev-runtime":m("react",t,"/jsx-dev-runtime",!0)}}function J(t=_){return z(t).react}function X(t=_){return z(t)["react-dom/client"]}function vt(t){return t.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function bt(t){if(typeof globalThis.btoa=="function")try{return globalThis.btoa(t)}catch{return Mt(new TextEncoder().encode(t))}let e=globalThis.Buffer;if(e)return e.from(t,"utf8").toString("base64");throw new Error("Base64 encoding is not supported in this runtime")}function Mt(t){let e=globalThis.Buffer;if(e)return e.from(t).toString("base64");if(typeof globalThis.btoa=="function"){let r="";for(let n of t)r+=String.fromCharCode(n);return globalThis.btoa(r)}throw new Error("Base64 encoding is not supported in this runtime")}function H(t){return vt(bt(t))}var io=Object.freeze({react:"","react-dom":"","react-dom/client":"","react-dom/server":"","react/jsx-runtime":"","react/jsx-dev-runtime":""});function O(t,e){if(!e)return!1;if(Object.prototype.hasOwnProperty.call(e,t))return!0;for(let r of Object.keys(e))if(r.endsWith("/")&&t.startsWith(r))return!0;return!1}function Lt(t){try{return JSON.parse(t)?.imports??{}}catch(e){return console.warn("Failed to parse import map JSON; treating as empty",{errorName:e instanceof Error?e.name:typeof e,inputLength:t.length}),{}}}function V(t=document){let e=t.querySelector(\'script[type="importmap"]\');return e?.textContent?Lt(e.textContent):{}}var l="/_veryfront",F={RSC:`${l}/rsc/`,FS:`${l}/fs/`,MODULES:`${l}/modules/`,PAGES:`${l}/pages/`,DATA:`${l}/data/`,LIB:`${l}/lib/`,CHUNKS:`${l}/chunks/`,CLIENT:`${l}/client/`},K={HMR_RUNTIME:`${l}/hmr-runtime.js`,HMR:`${l}/hmr.js`,ERROR_OVERLAY:`${l}/error-overlay.js`,DEV_LOADER:`${l}/dev-loader.js`,CLIENT_LOG:`${l}/log`,CLIENT_JS:`${l}/client.js`,ROUTER_JS:`${l}/router.js`,PREFETCH_JS:`${l}/prefetch.js`,MANIFEST_JSON:`${l}/manifest.json`,APP_JS:`${l}/app.js`,RSC_CLIENT:`${l}/rsc/client.js`,RSC_MANIFEST:`${l}/rsc/manifest`,RSC_STREAM:`${l}/rsc/stream`,RSC_PAYLOAD:`${l}/rsc/payload`,RSC_RENDER:`${l}/rsc/render`,RSC_PAGE:`${l}/rsc/page`,RSC_MODULE:`${l}/rsc/module`,RSC_DOM:`${l}/rsc/dom.js`,LIB_CHAT_REACT:`${l}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${l}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${l}/lib/chat/primitives.js`};var Ut={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},go=Ut.CACHE;var po={HMR_RUNTIME:K.HMR_RUNTIME,ERROR_OVERLAY:K.ERROR_OVERLAY};var h=F.RSC,Z=F.FS,Q="veryfront-hydration-data",C="rsc-root";var R=class{constructor(e,r){p(this,"prefix",e);p(this,"level",r)}log(e,r,n,...s){this.level>e||r?.(n,...s)}debug(e,...r){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${e}`,...r)}info(e,...r){this.log(1,console.log,`[${this.prefix}] ${e}`,...r)}warn(e,...r){this.log(2,console.warn,`[${this.prefix}] WARN: ${e}`,...r)}error(e,...r){this.log(3,console.error,`[${this.prefix}] ERROR: ${e}`,...r)}};function Pt(){if(typeof window>"u")return 2;let t=globalThis;return t.__VERYFRONT_DEV__||t.__RSC_DEV__?t.__VERYFRONT_DEBUG__||t.__RSC_DEBUG__?0:1:2}var N=Pt(),i=new R("RSC",N),yo=new R("PREFETCH",N),_o=new R("HYDRATE",N),ho=new R("VERYFRONT",N);function E(t=document){try{let e=t.getElementById(Q);return e?JSON.parse(e.textContent||"{}"):null}catch(e){return i.debug("hydration data parse failed",e),null}}function A(t){return t?.clientModuleStrategy?t.clientModuleStrategy:t?.dev?"fs":"rsc-module"}function Ht(t,e){if(!e)return t;let r=t.includes("?")?"&":"?";return`${t}${r}v=${encodeURIComponent(e)}`}function Vt(t,e){return Ht(`${Z}${H(t)}.js`,e)}function Ft(t,e){let r=e?`&v=${encodeURIComponent(e)}`:"";return`${h}module?rel=${encodeURIComponent(t)}${r}`}function D(t){if(t.strategy==="fs"){let e=t.absPath??t.rel;return e?Vt(e,t.version):null}return Ft(t.rel,t.version)}function v(t=document,e=_){let r=V(t);return{react:O("react",r)?"react":J(e),reactDomClient:O("react-dom/client",r)?"react-dom/client":X(e)}}function tt(t=document){let e=V(t);return O("veryfront/router",e)?"veryfront/router":null}function o(t){return{...t,create(e){return new k(e?.message||e?.detail||t.title,{slug:t.slug,category:t.category,status:e?.status??t.status,title:t.title,suggestion:t.suggestion,detail:e?.detail,cause:e?.cause,instance:e?.instance,context:e?.context})}}}var k=class extends Error{constructor(r,n){super(r);p(this,"slug");p(this,"category");p(this,"status");p(this,"title");p(this,"suggestion");p(this,"detail");p(this,"cause");p(this,"instance");p(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var kt=o({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),Gt=o({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),$t=o({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),Bt=o({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),Yt=o({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),jt=o({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),Wt=o({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),qt=o({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),zt=o({slug:"webhook-config-invalid",category:"CONFIG",status:400,title:"Invalid webhook configuration",suggestion:"Check webhook definition fields, target settings, and eventFilter conditions"}),Jt=o({slug:"schedule-config-invalid",category:"CONFIG",status:400,title:"Invalid schedule configuration",suggestion:"Check schedule definition fields, cron expression, target settings, and positive-integer limits"}),Xt=o({slug:"trigger-config-invalid",category:"CONFIG",status:400,title:"Invalid trigger configuration",suggestion:"Check trigger ID format (lowercase, alphanumeric, dots/slashes/hyphens) and ensure all input values are JSON-serializable"}),et={"config-not-found":kt,"config-invalid":Gt,"config-parse-error":$t,"config-validation-error":Bt,"config-type-error":Yt,"import-map-invalid":jt,"cors-config-invalid":Wt,"config-validation-failed":qt,"webhook-config-invalid":zt,"schedule-config-invalid":Jt,"trigger-config-invalid":Xt};var Kt=o({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),Zt=o({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),Qt=o({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),te=o({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),ee=o({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),re=o({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),oe=o({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),ne=o({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),rt={"build-failed":Kt,"bundle-error":Zt,"typescript-error":Qt,"mdx-compile-error":te,"asset-optimization-error":ee,"ssg-generation-error":re,"sourcemap-error":oe,"compilation-error":ne};var se=o({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),ie=o({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ae=o({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),ce=o({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),le=o({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),ue=o({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),de=o({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),ge=o({slug:"trigger-target-not-found",category:"RUNTIME",status:404,title:"Trigger target not found",suggestion:"Ensure the referenced task or workflow ID is registered in the project"}),pe=o({slug:"trigger-execution-failed",category:"RUNTIME",status:500,title:"Trigger target execution failed",suggestion:"Check the task or workflow for errors and review the trigger input"}),fe=o({slug:"trigger-not-supported",category:"RUNTIME",status:501,title:"Trigger target type not supported in local runtime",suggestion:"Use a workflow or task target for local trigger runs; agent targets require the Cloud runtime"}),ot={"hydration-mismatch":se,"render-error":ie,"component-error":ae,"layout-not-found":ce,"page-not-found":le,"api-error":ue,"middleware-error":de,"trigger-target-not-found":ge,"trigger-execution-failed":pe,"trigger-not-supported":fe};var me=o({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),Re=o({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),Ee=o({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),ye=o({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),_e=o({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),he=o({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),nt={"route-conflict":me,"invalid-route-file":Re,"route-handler-invalid":Ee,"dynamic-route-error":ye,"route-params-error":_e,"api-route-error":he};var Ce=o({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),Te=o({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),xe=o({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),Ie=o({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Se=o({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Oe=o({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),st={"module-not-found":Ce,"import-resolution-error":Te,"circular-dependency":xe,"invalid-import":Ie,"dependency-missing":Se,"version-mismatch":Oe};var Ne=o({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),Ae=o({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),De=o({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),ve=o({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),be=o({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Me=o({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Le=o({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),we=o({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),Ue=o({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Pe=o({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),He=o({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Ve=o({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),Fe=o({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),ke=o({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),Ge=o({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),it={"port-in-use":Ne,"server-start-error":Ae,"cache-error":De,"file-watch-error":ve,"request-error":be,"service-overloaded":Me,"semaphore-timeout":Le,"circuit-breaker-open":we,"cache-path-mismatch":Ue,"network-error":Pe,"api-client-error":He,"token-storage-error":Ve,"cache-invariant-violation":Fe,"release-not-found":ke,"fallback-exhausted":Ge};var $e=o({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),Be=o({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),Ye=o({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),je=o({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),We=o({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),qe=o({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),at={"client-boundary-violation":$e,"server-only-in-client":Be,"client-only-in-server":Ye,"invalid-use-client":je,"invalid-use-server":We,"rsc-payload-error":qe};var ze=o({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),Je=o({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Xe=o({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),Ke=o({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Ze=o({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),ct={"hmr-error":ze,"dev-server-error":Je,"fast-refresh-error":Xe,"error-overlay-error":Ke,"source-map-error":Ze};var Qe=o({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),tr=o({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),er=o({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),rr=o({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),lt={"deployment-error":Qe,"platform-error":tr,"env-var-missing":er,"production-build-required":rr};var or=o({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),nr=o({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),sr=o({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),ir=o({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),ar=o({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),cr=o({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),lr=o({slug:"tool-id-conflict",category:"AGENT",status:409,title:"Tool ID conflict",suggestion:"Use a unique tool ID or rename one of the conflicting tools"}),ut={"agent-error":or,"agent-not-found":nr,"agent-timeout":sr,"agent-intent-error":ir,"orchestration-error":ar,"cost-limit-exceeded":cr,"tool-id-conflict":lr};var ur=o({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),dr=o({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),gr=o({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),pr=o({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),fr=o({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),mr=o({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),Rr=o({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Er=o({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),G=o({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),yr=o({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),dt={"unknown-error":ur,"permission-denied":dr,"file-not-found":gr,"resource-not-found":pr,"invalid-argument":fr,"timeout-error":mr,"initialization-error":Rr,"not-supported":Er,"security-violation":G,"input-validation-failed":yr};var En={...et,...rt,...ot,...nt,...st,...it,...at,...ct,...lt,...ut,...dt};var _r=[{source:String.raw`]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function hr(){return _r.map(({source:t,flags:e,name:r})=>({pattern:new RegExp(t,e),name:r}))}function Cr(){let t=globalThis;return t.__VERYFRONT_DEV__===!0||t.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function T(t,e={}){let{allowInlineScripts:r=!1,strict:n=!1,warn:s=!0}=e;for(let{pattern:u,name:c}of hr())if(!(r&&c==="inline script")&&(u.lastIndex=0,!!u.test(t)&&(s&&console.warn(`[Security] Suspicious ${c} detected in server HTML`),n||!Cr())))throw G.create({detail:`Potentially unsafe HTML: ${c} detected`});return t}function x(t,e){let r=e==="root"?C:`rsc-slot-${e}`,n=t.getElementById(r);if(n)return n;let s=t.createElement("div");return s.id=r,t.body.appendChild(s),s}function Tr(t,e){if(e.type!=="slot")return;let r=x(t,e.id);r.innerHTML=T(String(e.html??""))}function gt(t,e){let r=e.split(`\n`),n=r.pop()??"";for(let s of r){let u=s.trim();if(!u)continue;let c;try{c=JSON.parse(u)}catch(a){i.debug("[client-dom] malformed NDJSON line",{line:u,error:a instanceof Error?a.message:String(a)});continue}if(!c||typeof c!="object")continue;let g=c;if(g.type==="slot"){Tr(t,g);try{Sr(t,g.id||"root")}catch(a){i.debug("[client-dom] hydration optional failed",a)}}}return n}function xr(t){return new Promise((e,r)=>{let n=()=>r(new DOMException("aborted","AbortError"));if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0})})}async function pt(t,e=document,r){let n="body"in t?t:null,s=n?.body??t;if(!s)return;let u=s.getReader(),c=new TextDecoder,g="",a=!1;try{for(;;){if(r?.aborted)throw new DOMException("aborted","AbortError");let d=u.read(),{done:f,value:y}=r?await Promise.race([d,xr(r)]):await d;if(f){a=!0;break}g+=c.decode(y,{stream:!0}),g=gt(e,g)}g&>(e,`${g}\n`)}catch(d){throw d instanceof Error&&d.name==="AbortError"||i.debug("[client-dom] consumeNdjsonStream error",d),d}finally{try{await u.cancel()}catch(d){a||i.debug("[client-dom] reader.cancel failed",d)}try{u.releaseLock()}catch(d){i.debug("[client-dom] reader.releaseLock failed",d)}if(typeof s.cancel=="function")try{await s.cancel()}catch(d){i.debug("[client-dom] stream.cancel failed",d)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(d){i.debug("[client-dom] response.body.cancel failed",d)}}}function Ir(t,e){let r=x(t,e),n=[],s=u=>{let c=u;c.dataset?.clientRef&&n.push(c);for(let g of u.children)s(g)};return s(r),n}function Sr(t,e){let r=Ir(t,e);for(let n of r){let s=n.dataset?.clientRef;s&&(n.dataset.hydrated="true",i.debug("[client-dom] marked for hydration",s))}}var Or=new Set(["server","client","html","fragment"]);function ft(t){if(!t)return[];try{let e=JSON.parse(t);return Ar(e)?e.nodes:[]}catch{return[]}}async function B(t,e,r){return await Promise.all(t.map(n=>Nr(n,e,r)))}async function Nr(t,e,r){if(t.type==="html")return t.text??t.html??"";let n=await B(t.children??[],e,r);if(t.type==="fragment"||t.type==="server"&&!t.component)return e.createElement(e.Fragment,{},...n);if(t.type==="server")return e.createElement(t.component,t.props??{},...n);let s=await r(t.component);return s?e.createElement(s,t.props??{},...n):null}function Ar(t){return!$(t)||t.version!==1||!Array.isArray(t.nodes)?!1:t.nodes.every(e=>mt(e,0))}function mt(t,e){return e>100||!$(t)||!Or.has(t.type)||t.type==="html"&&typeof t.html!="string"&&typeof t.text!="string"||t.type==="client"&&typeof t.component!="string"||t.type==="server"&&t.component!==void 0&&typeof t.component!="string"||t.props!==void 0&&!$(t.props)?!1:t.children===void 0?!0:Array.isArray(t.children)&&t.children.every(r=>mt(r,e+1))}function $(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Dr(t){if(!t)return{};let e={};for(let[r,n]of Object.entries(t))e[r]=Array.isArray(n)?n.join("/"):n;return e}async function b(t,e,r=document){try{let n=tt(r);if(!n)return t;let u=(await import(n)).wrapForHydration;return typeof u!="function"?t:u(t,{params:Dr(e?.params),frontmatter:e?.frontmatter??{}})}catch(n){return i.debug("router provider wrap failed",n),t}}var vr=100;function br(t,e){if(globalThis.__VF_CLIENT_MOD_CACHE??(globalThis.__VF_CLIENT_MOD_CACHE=new Map),globalThis.__VF_CLIENT_MOD_CACHE.size>=vr){let r=globalThis.__VF_CLIENT_MOD_CACHE.keys().next().value;r&&globalThis.__VF_CLIENT_MOD_CACHE.delete(r)}globalThis.__VF_CLIENT_MOD_CACHE.set(t,e)}function Rt(t){let e=t.match(/^\\/app\\/(.+)#([\\w$.-]+)$/);if(e)return{rel:`/${e[1]||""}`,exportName:e[2]||"default"};let r=t.match(/^(\\/_veryfront\\/[^#]+)#([\\w$.-]+)$/);return r?{moduleUrl:r[1],exportName:r[2]||"default"}:(i.debug("hydrate: unrecognised client ref format, skipping",{ref:t}),null)}function Mr(t){let e=t.dataset?.rscProps;if(!e)return{};try{let r=JSON.parse(e);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch(r){return i.debug("hydrate: invalid client boundary props, using empty props",r),{}}}function Lr(t){return ft(t.dataset?.rscChildren)}async function wr(){try{let t=await fetch("/_veryfront/rsc/manifest");return t.ok?await t.json():null}catch{return null}}async function Et(t,e,r){let n=Ur(t,e,r),s=e.moduleUrl??e.rel;if(!s)return null;let u=`${s}#${t.hash??""}`;try{let c=globalThis.__VF_CLIENT_MOD_CACHE?.get(u);if(c)return c}catch(c){i.debug("hydrate: cache get failed",c)}if(!n)return null;try{let c=await import(n);try{br(u,c)}catch(g){i.debug("hydrate: cache set failed",g)}return c}catch(c){return i.debug("hydrate: failed to import module",{moduleUrl:n,error:c}),null}}function Ur(t,e,r){if(e.moduleUrl)return e.moduleUrl;if(!e.rel)return null;let n=t.graphIds?.client.find(s=>s.rel===e.rel)?.path;return D({strategy:r,rel:e.rel,absPath:n,version:t.hash})}function Pr(t){let e=Array.from(t.querySelectorAll("[data-client-ref]")),r=new Set(e);return e.filter(n=>{let s=n.parentElement;for(;s;){if(r.has(s))return!1;s=s.parentElement}return!0})}async function yt(t=document){let e=null;try{e=await wr()}catch(a){i.debug("hydrate: fetch manifest failed",a)}if(!e){i.debug("hydrate: no manifest");return}let r=Pr(t);try{let a=globalThis.__VF_MANIFEST_HASH;if(!r.some(f=>f.dataset?.hydrated!=="true")&&a&&e.hash&&a===e.hash)return}catch(a){i.debug("hydrate: hmr hash read failed",a)}if(r.length===0){try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(a){i.debug("hydrate: set hash failed",a)}return}let n=E(t),s=A(n);try{if(globalThis.__VF_TEST_MODE__){globalThis.__VF_HYDRATE_CALLED=!0,globalThis.__VF_MANIFEST_HASH=e.hash??"";return}}catch(a){i.debug("hydrate: test mode flags failed",a)}let u=v(t,n?.reactVersion),[{default:c},{createRoot:g}]=await Promise.all([import(u.react),import(u.reactDomClient)]);for(let a of r){let d=a.dataset?.clientRef??"";if(!d||a.dataset?.hydrated==="true")continue;let f=Rt(d);if(!f)continue;let y=await Et(e,f,s);if(!y)continue;let j=y[f.exportName]??y.default;if(typeof j=="function")try{let L=g(a),_t=Mr(a),ht=Lr(a),Ct=await B(ht,{Fragment:c.Fragment,createElement(I,w,...S){return c.createElement(I,w,...S)}},async I=>{let w=e.modules.find(xt=>xt.id===I),S=e.components?.[I],W=w?.clientRef??(S?`${S}#default`:void 0);if(!W)return null;let U=Rt(W);if(!U)return null;let P=await Et(e,U,s);if(!P)return null;let q=P[U.exportName]??P.default;return typeof q=="function"?q:null}),Tt=await b(c.createElement(j,_t,...Ct),n,t);L.render(Tt),a.dataset.hydrated="true"}catch(L){i.warn("hydrate: render failed",L)}}try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(a){i.debug("hydrate: set hash failed (post)",a)}}async function Hr(){let t=E(document),e=v(document,t?.reactVersion),[r,n]=await Promise.all([import(e.react),import(e.reactDomClient)]);return{React:r,ReactDOM:n}}var Vr=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE"]);function Y(t){let e=t.getAttribute("style")??"";return t.hasAttribute("data-veryfront-head")||t.hasAttribute("hidden")||/(?:^|;)\\s*display\\s*:\\s*none(?:\\s*;|$)/i.test(e)||Vr.has(t.tagName.toUpperCase())}function Fr(t,e){return t.find(r=>r.tagName.toUpperCase()==="DIV"&&!!r.getAttribute("class")?.trim()&&!Y(r))??e}function kr(t,e){return t===e}function Gr(t,e){let r=document.createElement("div");r.setAttribute("data-veryfront-hydration-root","page");let n=t.find(s=>!Y(s));n?.parentNode===e?e.insertBefore(r,n):e.appendChild(r);for(let s of t)!Y(s)&&s.parentNode===e&&r.appendChild(s);return r}function $r(t,e,r=document){return!!e?.pagePath&&typeof t?.__veryfrontRenderPage=="function"&&!!r.getElementById("root")}function Br(t,e){return e?.pagePath?!1:!!t.getElementById(C)}function Yr(t=import.meta.url){try{return new URL(t,"http://veryfront.local").searchParams.get("hydrate")==="1"}catch{return!1}}function jr(t){return t==="rsc-module"}async function Wr(t){try{let e=await fetch(h+"stream"+t);if(!e.ok||!e.body)return!1;let r=new AbortController;return addEventListener("pagehide",()=>r.abort(),{once:!0}),await pt(e,document,r.signal),!0}catch(e){return i.debug("tryStream failed",e),!1}}async function M(){try{await yt(document)}catch(t){i.debug("hydration failed",t)}}async function qr(t,e){try{let{React:r,ReactDOM:n}=await Hr(),s=D({strategy:e,rel:t});if(!s)return!1;i.debug("Loading component from:",s);let c=(await import(s)).default;if(typeof c!="function")return i.debug("Page component is not a function"),!1;let g=Array.from(document.body.children),a=Fr(g,document.body),d=kr(a,document.body)?Gr(g,document.body):a,f=await b(r.createElement(c,{}),E(document));return jr(e)?n.createRoot(d).render(f):n.hydrateRoot(d,f,{identifierPrefix:"vf",onRecoverableError:()=>{}}),i.debug("Page component hydrated successfully"),!0}catch(r){return i.error("Page hydration failed",r),!1}}async function zr(t){try{let e=await fetch(h+"payload"+t);if(!e.ok)return!1;let r=await e.json();if(r?.slots){for(let[n,s]of Object.entries(r.slots))x(document,n).innerHTML=T(String(s||""));return!0}return x(document,C).innerHTML=T(String(r?.html||"")),!0}catch(e){return i.debug("payload fetch failed",e),!1}}async function Jr(){try{let t=globalThis.window?.location.search??"",e=E(document);if(Yr()){await M();return}let r=e?.pagePath,n=A(e);if(r){if($r(globalThis.window,e,document)){i.debug("Page renderer owns hydration");return}i.debug("Found page component in hydration data:",r),await qr(r,n)&&i.debug("Client component hydrated successfully");return}if(!Br(document,e))return;if(await Wr(t)){await M();return}if(await zr(t)){await M();return}await M()}catch(t){i.error("boot failed",t)}}if(typeof document<"u"){let t=()=>{Jr()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{Jr as boot,Fr as selectHydrationRoot,Br as shouldAttemptRSCTransport,Yr as shouldHydrateOnly,jr as shouldRenderPageComponent,$r as shouldUsePageRendererHydration,kr as shouldWrapPageHydrationRoot};\n'; export const CLIENT_DOM_BUNDLE: string = 'var V=Object.defineProperty;var k=(r,t,o)=>t in r?V(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var l=(r,t,o)=>k(r,typeof t!="symbol"?t+"":t,o);function e(r){return{...r,create(t){return new f(t?.message||t?.detail||r.title,{slug:r.slug,category:r.category,status:t?.status??r.status,title:r.title,suggestion:r.suggestion,detail:t?.detail,cause:t?.cause,instance:t?.instance,context:t?.context})}}}var f=class extends Error{constructor(o,n){super(o);l(this,"slug");l(this,"category");l(this,"status");l(this,"title");l(this,"suggestion");l(this,"detail");l(this,"cause");l(this,"instance");l(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var w=e({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),F=e({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),H=e({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),Y=e({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),B=e({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),$=e({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),j=e({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),q=e({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),z=e({slug:"webhook-config-invalid",category:"CONFIG",status:400,title:"Invalid webhook configuration",suggestion:"Check webhook definition fields, target settings, and eventFilter conditions"}),W=e({slug:"schedule-config-invalid",category:"CONFIG",status:400,title:"Invalid schedule configuration",suggestion:"Check schedule definition fields, cron expression, target settings, and positive-integer limits"}),J=e({slug:"trigger-config-invalid",category:"CONFIG",status:400,title:"Invalid trigger configuration",suggestion:"Check trigger ID format (lowercase, alphanumeric, dots/slashes/hyphens) and ensure all input values are JSON-serializable"}),y={"config-not-found":w,"config-invalid":F,"config-parse-error":H,"config-validation-error":Y,"config-type-error":B,"import-map-invalid":$,"cors-config-invalid":j,"config-validation-failed":q,"webhook-config-invalid":z,"schedule-config-invalid":W,"trigger-config-invalid":J};var X=e({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),K=e({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),Z=e({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),Q=e({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),ee=e({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),te=e({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),re=e({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),oe=e({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),I={"build-failed":X,"bundle-error":K,"typescript-error":Z,"mdx-compile-error":Q,"asset-optimization-error":ee,"ssg-generation-error":te,"sourcemap-error":re,"compilation-error":oe};var ne=e({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),se=e({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ie=e({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),ae=e({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),ce=e({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),ue=e({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),le=e({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),ge=e({slug:"trigger-target-not-found",category:"RUNTIME",status:404,title:"Trigger target not found",suggestion:"Ensure the referenced task or workflow ID is registered in the project"}),pe=e({slug:"trigger-execution-failed",category:"RUNTIME",status:500,title:"Trigger target execution failed",suggestion:"Check the task or workflow for errors and review the trigger input"}),de=e({slug:"trigger-not-supported",category:"RUNTIME",status:501,title:"Trigger target type not supported in local runtime",suggestion:"Use a workflow or task target for local trigger runs; agent targets require the Cloud runtime"}),O={"hydration-mismatch":ne,"render-error":se,"component-error":ie,"layout-not-found":ae,"page-not-found":ce,"api-error":ue,"middleware-error":le,"trigger-target-not-found":ge,"trigger-execution-failed":pe,"trigger-not-supported":de};var Ee=e({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),Re=e({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),fe=e({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),me=e({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),_e=e({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),ye=e({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),T={"route-conflict":Ee,"invalid-route-file":Re,"route-handler-invalid":fe,"dynamic-route-error":me,"route-params-error":_e,"api-route-error":ye};var Ie=e({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),Oe=e({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),Te=e({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),he=e({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),xe=e({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Se=e({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),h={"module-not-found":Ie,"import-resolution-error":Oe,"circular-dependency":Te,"invalid-import":he,"dependency-missing":xe,"version-mismatch":Se};var Ne=e({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),ve=e({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Ce=e({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),Ae=e({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),De=e({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Le=e({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Ue=e({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),be=e({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),Me=e({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Ge=e({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),Pe=e({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Ve=e({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),ke=e({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),we=e({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),Fe=e({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),x={"port-in-use":Ne,"server-start-error":ve,"cache-error":Ce,"file-watch-error":Ae,"request-error":De,"service-overloaded":Le,"semaphore-timeout":Ue,"circuit-breaker-open":be,"cache-path-mismatch":Me,"network-error":Ge,"api-client-error":Pe,"token-storage-error":Ve,"cache-invariant-violation":ke,"release-not-found":we,"fallback-exhausted":Fe};var He=e({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),Ye=e({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),Be=e({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),$e=e({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),je=e({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),qe=e({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),S={"client-boundary-violation":He,"server-only-in-client":Ye,"client-only-in-server":Be,"invalid-use-client":$e,"invalid-use-server":je,"rsc-payload-error":qe};var ze=e({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),We=e({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Je=e({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),Xe=e({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Ke=e({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),N={"hmr-error":ze,"dev-server-error":We,"fast-refresh-error":Je,"error-overlay-error":Xe,"source-map-error":Ke};var Ze=e({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),Qe=e({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),et=e({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),tt=e({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),v={"deployment-error":Ze,"platform-error":Qe,"env-var-missing":et,"production-build-required":tt};var rt=e({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),ot=e({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),nt=e({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),st=e({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),it=e({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),at=e({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),ct=e({slug:"tool-id-conflict",category:"AGENT",status:409,title:"Tool ID conflict",suggestion:"Use a unique tool ID or rename one of the conflicting tools"}),C={"agent-error":rt,"agent-not-found":ot,"agent-timeout":nt,"agent-intent-error":st,"orchestration-error":it,"cost-limit-exceeded":at,"tool-id-conflict":ct};var ut=e({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),lt=e({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),gt=e({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),pt=e({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),dt=e({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),Et=e({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),Rt=e({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),ft=e({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),m=e({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),mt=e({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),A={"unknown-error":ut,"permission-denied":lt,"file-not-found":gt,"resource-not-found":pt,"invalid-argument":dt,"timeout-error":Et,"initialization-error":Rt,"not-supported":ft,"security-violation":m,"input-validation-failed":mt};var fr={...y,...I,...O,...T,...h,...x,...S,...N,...v,...C,...A};var _t=[{source:String.raw`]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function yt(){return _t.map(({source:r,flags:t,name:o})=>({pattern:new RegExp(r,t),name:o}))}function It(){let r=globalThis;return r.__VERYFRONT_DEV__===!0||r.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function D(r,t={}){let{allowInlineScripts:o=!1,strict:n=!1,warn:i=!0}=t;for(let{pattern:c,name:u}of yt())if(!(o&&u==="inline script")&&(c.lastIndex=0,!!c.test(r)&&(i&&console.warn(`[Security] Suspicious ${u} detected in server HTML`),n||!It())))throw m.create({detail:`Potentially unsafe HTML: ${u} detected`});return r}var E=class{constructor(t,o){l(this,"prefix",t);l(this,"level",o)}log(t,o,n,...i){this.level>t||o?.(n,...i)}debug(t,...o){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${t}`,...o)}info(t,...o){this.log(1,console.log,`[${this.prefix}] ${t}`,...o)}warn(t,...o){this.log(2,console.warn,`[${this.prefix}] WARN: ${t}`,...o)}error(t,...o){this.log(3,console.error,`[${this.prefix}] ERROR: ${t}`,...o)}};function Ot(){if(typeof window>"u")return 2;let r=globalThis;return r.__VERYFRONT_DEV__||r.__RSC_DEV__?r.__VERYFRONT_DEBUG__||r.__RSC_DEBUG__?0:1:2}var R=Ot(),p=new E("RSC",R),br=new E("PREFETCH",R),Mr=new E("HYDRATE",R),Gr=new E("VERYFRONT",R);var s="/_veryfront",_={RSC:`${s}/rsc/`,FS:`${s}/fs/`,MODULES:`${s}/modules/`,PAGES:`${s}/pages/`,DATA:`${s}/data/`,LIB:`${s}/lib/`,CHUNKS:`${s}/chunks/`,CLIENT:`${s}/client/`},L={HMR_RUNTIME:`${s}/hmr-runtime.js`,HMR:`${s}/hmr.js`,ERROR_OVERLAY:`${s}/error-overlay.js`,DEV_LOADER:`${s}/dev-loader.js`,CLIENT_LOG:`${s}/log`,CLIENT_JS:`${s}/client.js`,ROUTER_JS:`${s}/router.js`,PREFETCH_JS:`${s}/prefetch.js`,MANIFEST_JSON:`${s}/manifest.json`,APP_JS:`${s}/app.js`,RSC_CLIENT:`${s}/rsc/client.js`,RSC_MANIFEST:`${s}/rsc/manifest`,RSC_STREAM:`${s}/rsc/stream`,RSC_PAYLOAD:`${s}/rsc/payload`,RSC_RENDER:`${s}/rsc/render`,RSC_PAGE:`${s}/rsc/page`,RSC_MODULE:`${s}/rsc/module`,RSC_DOM:`${s}/rsc/dom.js`,LIB_CHAT_REACT:`${s}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${s}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${s}/lib/chat/primitives.js`};var ht={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},Hr=ht.CACHE;var Yr={HMR_RUNTIME:L.HMR_RUNTIME,ERROR_OVERLAY:L.ERROR_OVERLAY};var qr=_.RSC,zr=_.FS;var U="rsc-root";function M(r,t){let o=t==="root"?U:`rsc-slot-${t}`,n=r.getElementById(o);if(n)return n;let i=r.createElement("div");return i.id=o,r.body.appendChild(i),i}function xt(r,t){if(t.type!=="slot")return;let o=M(r,t.id);o.innerHTML=D(String(t.html??""))}function b(r,t){let o=t.split(`\n`),n=o.pop()??"";for(let i of o){let c=i.trim();if(!c)continue;let u;try{u=JSON.parse(c)}catch(d){p.debug("[client-dom] malformed NDJSON line",{line:c,error:d instanceof Error?d.message:String(d)});continue}if(!u||typeof u!="object")continue;let g=u;if(g.type==="slot"){xt(r,g);try{vt(r,g.id||"root")}catch(d){p.debug("[client-dom] hydration optional failed",d)}}}return n}function St(r){return new Promise((t,o)=>{let n=()=>o(new DOMException("aborted","AbortError"));if(r.aborted){n();return}r.addEventListener("abort",n,{once:!0})})}async function Zr(r,t=document,o){let n="body"in r?r:null,i=n?.body??r;if(!i)return;let c=i.getReader(),u=new TextDecoder,g="",d=!1;try{for(;;){if(o?.aborted)throw new DOMException("aborted","AbortError");let a=c.read(),{done:G,value:P}=o?await Promise.race([a,St(o)]):await a;if(G){d=!0;break}g+=u.decode(P,{stream:!0}),g=b(t,g)}g&&b(t,`${g}\n`)}catch(a){throw a instanceof Error&&a.name==="AbortError"||p.debug("[client-dom] consumeNdjsonStream error",a),a}finally{try{await c.cancel()}catch(a){d||p.debug("[client-dom] reader.cancel failed",a)}try{c.releaseLock()}catch(a){p.debug("[client-dom] reader.releaseLock failed",a)}if(typeof i.cancel=="function")try{await i.cancel()}catch(a){p.debug("[client-dom] stream.cancel failed",a)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(a){p.debug("[client-dom] response.body.cancel failed",a)}}}function Nt(r,t){let o=M(r,t),n=[],i=c=>{let u=c;u.dataset?.clientRef&&n.push(u);for(let g of c.children)i(g)};return i(o),n}function vt(r,t){let o=Nt(r,t);for(let n of o){let i=n.dataset?.clientRef;i&&(n.dataset.hydrated="true",p.debug("[client-dom] marked for hydration",i))}}export{Zr as consumeNdjsonStream,M as getContainer};\n'; From b6a16fab8a2d9f7363cfba7fa64ea32681929655 Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Thu, 23 Jul 2026 20:57:17 +0200 Subject: [PATCH 5/5] docs(errors): clarify cooperative timeoutMs, final-error normalization, and workflow retry classification comment --- src/errors/error-handlers.ts | 10 ++++++++-- .../services/rsc/endpoints/rsc-bundles.generated.ts | 2 +- src/workflow/executor/step-executor.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/errors/error-handlers.ts b/src/errors/error-handlers.ts index 1cf2616a18..ac81454c69 100644 --- a/src/errors/error-handlers.ts +++ b/src/errors/error-handlers.ts @@ -56,7 +56,10 @@ export interface RetryWithBackoffOptions { initialDelay?: number; maxDelay?: number; logger?: typeof serverLogger; - /** Per-attempt timeout; aborts the attempt's signal with an AbortError. */ + /** + * Per-attempt timeout: aborts the attempt's AbortSignal with an AbortError. + * Cooperative — the attempt only stops if `fn` observes the signal it is given. + */ timeoutMs?: number; /** Return false to rethrow immediately without further attempts (default: always retry). */ shouldRetry?: (error: unknown, attempt: number) => boolean; @@ -64,7 +67,10 @@ export interface RetryWithBackoffOptions { computeDelay?: (attempt: number, error: unknown) => number; /** Called before each backoff wait; replaces the default warn log. */ onRetry?: (info: { error: Error; attempt: number; delay: number; isTimeout: boolean }) => void; - /** Wrap the terminal error once all attempts are exhausted (default: rethrow as-is). */ + /** + * Wrap the terminal error once all attempts are exhausted. Default: rethrow + * the normalized Error (non-Error throws become `new Error(String(value))`). + */ wrapFinalError?: (lastError: Error, lastAttempt: number) => Error; } diff --git a/src/server/services/rsc/endpoints/rsc-bundles.generated.ts b/src/server/services/rsc/endpoints/rsc-bundles.generated.ts index 108322f78f..95c9fabc81 100644 --- a/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +++ b/src/server/services/rsc/endpoints/rsc-bundles.generated.ts @@ -7,7 +7,7 @@ */ export const CLIENT_BOOT_BUNDLE: string = - 'var It=Object.defineProperty;var St=(t,e,r)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>St(t,typeof e!="symbol"?e+"":e,r);var Ot="3.2.3";function Nt(t,e,r,n){let s=[];if(n?.external?.length&&s.push(`external=${n.external.join(",")}`),s.push(`target=${n?.target??"es2022"}`),n?.deps){let a=Object.entries(n.deps).map(([d,f])=>`${d}@${f}`).join(",");s.push(`deps=${a}`)}let u=e?`@${e}`:"",c=r??"",g=s.length?`?${s.join("&")}`:"";return`https://esm.sh/${t}${u}${c}${g}`}function m(t,e,r,n=!1){return Nt(t,e,r,{external:n?["react"]:void 0,deps:{csstype:Ot}})}var Dt="19.2.4",_=Dt;function z(t=_){return{react:m("react",t),"react-dom":m("react-dom",t,void 0,!0),"react-dom/client":m("react-dom",t,"/client",!0),"react-dom/server":m("react-dom",t,"/server",!0),"react/jsx-runtime":m("react",t,"/jsx-runtime",!0),"react/jsx-dev-runtime":m("react",t,"/jsx-dev-runtime",!0)}}function J(t=_){return z(t).react}function X(t=_){return z(t)["react-dom/client"]}function vt(t){return t.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function bt(t){if(typeof globalThis.btoa=="function")try{return globalThis.btoa(t)}catch{return Mt(new TextEncoder().encode(t))}let e=globalThis.Buffer;if(e)return e.from(t,"utf8").toString("base64");throw new Error("Base64 encoding is not supported in this runtime")}function Mt(t){let e=globalThis.Buffer;if(e)return e.from(t).toString("base64");if(typeof globalThis.btoa=="function"){let r="";for(let n of t)r+=String.fromCharCode(n);return globalThis.btoa(r)}throw new Error("Base64 encoding is not supported in this runtime")}function H(t){return vt(bt(t))}var io=Object.freeze({react:"","react-dom":"","react-dom/client":"","react-dom/server":"","react/jsx-runtime":"","react/jsx-dev-runtime":""});function O(t,e){if(!e)return!1;if(Object.prototype.hasOwnProperty.call(e,t))return!0;for(let r of Object.keys(e))if(r.endsWith("/")&&t.startsWith(r))return!0;return!1}function Lt(t){try{return JSON.parse(t)?.imports??{}}catch(e){return console.warn("Failed to parse import map JSON; treating as empty",{errorName:e instanceof Error?e.name:typeof e,inputLength:t.length}),{}}}function V(t=document){let e=t.querySelector(\'script[type="importmap"]\');return e?.textContent?Lt(e.textContent):{}}var l="/_veryfront",F={RSC:`${l}/rsc/`,FS:`${l}/fs/`,MODULES:`${l}/modules/`,PAGES:`${l}/pages/`,DATA:`${l}/data/`,LIB:`${l}/lib/`,CHUNKS:`${l}/chunks/`,CLIENT:`${l}/client/`},K={HMR_RUNTIME:`${l}/hmr-runtime.js`,HMR:`${l}/hmr.js`,ERROR_OVERLAY:`${l}/error-overlay.js`,DEV_LOADER:`${l}/dev-loader.js`,CLIENT_LOG:`${l}/log`,CLIENT_JS:`${l}/client.js`,ROUTER_JS:`${l}/router.js`,PREFETCH_JS:`${l}/prefetch.js`,MANIFEST_JSON:`${l}/manifest.json`,APP_JS:`${l}/app.js`,RSC_CLIENT:`${l}/rsc/client.js`,RSC_MANIFEST:`${l}/rsc/manifest`,RSC_STREAM:`${l}/rsc/stream`,RSC_PAYLOAD:`${l}/rsc/payload`,RSC_RENDER:`${l}/rsc/render`,RSC_PAGE:`${l}/rsc/page`,RSC_MODULE:`${l}/rsc/module`,RSC_DOM:`${l}/rsc/dom.js`,LIB_CHAT_REACT:`${l}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${l}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${l}/lib/chat/primitives.js`};var Ut={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},go=Ut.CACHE;var po={HMR_RUNTIME:K.HMR_RUNTIME,ERROR_OVERLAY:K.ERROR_OVERLAY};var h=F.RSC,Z=F.FS,Q="veryfront-hydration-data",C="rsc-root";var R=class{constructor(e,r){p(this,"prefix",e);p(this,"level",r)}log(e,r,n,...s){this.level>e||r?.(n,...s)}debug(e,...r){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${e}`,...r)}info(e,...r){this.log(1,console.log,`[${this.prefix}] ${e}`,...r)}warn(e,...r){this.log(2,console.warn,`[${this.prefix}] WARN: ${e}`,...r)}error(e,...r){this.log(3,console.error,`[${this.prefix}] ERROR: ${e}`,...r)}};function Pt(){if(typeof window>"u")return 2;let t=globalThis;return t.__VERYFRONT_DEV__||t.__RSC_DEV__?t.__VERYFRONT_DEBUG__||t.__RSC_DEBUG__?0:1:2}var N=Pt(),i=new R("RSC",N),yo=new R("PREFETCH",N),_o=new R("HYDRATE",N),ho=new R("VERYFRONT",N);function E(t=document){try{let e=t.getElementById(Q);return e?JSON.parse(e.textContent||"{}"):null}catch(e){return i.debug("hydration data parse failed",e),null}}function A(t){return t?.clientModuleStrategy?t.clientModuleStrategy:t?.dev?"fs":"rsc-module"}function Ht(t,e){if(!e)return t;let r=t.includes("?")?"&":"?";return`${t}${r}v=${encodeURIComponent(e)}`}function Vt(t,e){return Ht(`${Z}${H(t)}.js`,e)}function Ft(t,e){let r=e?`&v=${encodeURIComponent(e)}`:"";return`${h}module?rel=${encodeURIComponent(t)}${r}`}function D(t){if(t.strategy==="fs"){let e=t.absPath??t.rel;return e?Vt(e,t.version):null}return Ft(t.rel,t.version)}function v(t=document,e=_){let r=V(t);return{react:O("react",r)?"react":J(e),reactDomClient:O("react-dom/client",r)?"react-dom/client":X(e)}}function tt(t=document){let e=V(t);return O("veryfront/router",e)?"veryfront/router":null}function o(t){return{...t,create(e){return new k(e?.message||e?.detail||t.title,{slug:t.slug,category:t.category,status:e?.status??t.status,title:t.title,suggestion:t.suggestion,detail:e?.detail,cause:e?.cause,instance:e?.instance,context:e?.context})}}}var k=class extends Error{constructor(r,n){super(r);p(this,"slug");p(this,"category");p(this,"status");p(this,"title");p(this,"suggestion");p(this,"detail");p(this,"cause");p(this,"instance");p(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var kt=o({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),Gt=o({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),$t=o({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),Bt=o({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),Yt=o({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),jt=o({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),Wt=o({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),qt=o({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),zt=o({slug:"webhook-config-invalid",category:"CONFIG",status:400,title:"Invalid webhook configuration",suggestion:"Check webhook definition fields, target settings, and eventFilter conditions"}),Jt=o({slug:"schedule-config-invalid",category:"CONFIG",status:400,title:"Invalid schedule configuration",suggestion:"Check schedule definition fields, cron expression, target settings, and positive-integer limits"}),Xt=o({slug:"trigger-config-invalid",category:"CONFIG",status:400,title:"Invalid trigger configuration",suggestion:"Check trigger ID format (lowercase, alphanumeric, dots/slashes/hyphens) and ensure all input values are JSON-serializable"}),et={"config-not-found":kt,"config-invalid":Gt,"config-parse-error":$t,"config-validation-error":Bt,"config-type-error":Yt,"import-map-invalid":jt,"cors-config-invalid":Wt,"config-validation-failed":qt,"webhook-config-invalid":zt,"schedule-config-invalid":Jt,"trigger-config-invalid":Xt};var Kt=o({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),Zt=o({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),Qt=o({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),te=o({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),ee=o({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),re=o({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),oe=o({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),ne=o({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),rt={"build-failed":Kt,"bundle-error":Zt,"typescript-error":Qt,"mdx-compile-error":te,"asset-optimization-error":ee,"ssg-generation-error":re,"sourcemap-error":oe,"compilation-error":ne};var se=o({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),ie=o({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ae=o({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),ce=o({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),le=o({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),ue=o({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),de=o({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),ge=o({slug:"trigger-target-not-found",category:"RUNTIME",status:404,title:"Trigger target not found",suggestion:"Ensure the referenced task or workflow ID is registered in the project"}),pe=o({slug:"trigger-execution-failed",category:"RUNTIME",status:500,title:"Trigger target execution failed",suggestion:"Check the task or workflow for errors and review the trigger input"}),fe=o({slug:"trigger-not-supported",category:"RUNTIME",status:501,title:"Trigger target type not supported in local runtime",suggestion:"Use a workflow or task target for local trigger runs; agent targets require the Cloud runtime"}),ot={"hydration-mismatch":se,"render-error":ie,"component-error":ae,"layout-not-found":ce,"page-not-found":le,"api-error":ue,"middleware-error":de,"trigger-target-not-found":ge,"trigger-execution-failed":pe,"trigger-not-supported":fe};var me=o({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),Re=o({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),Ee=o({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),ye=o({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),_e=o({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),he=o({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),nt={"route-conflict":me,"invalid-route-file":Re,"route-handler-invalid":Ee,"dynamic-route-error":ye,"route-params-error":_e,"api-route-error":he};var Ce=o({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),Te=o({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),xe=o({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),Ie=o({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Se=o({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Oe=o({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),st={"module-not-found":Ce,"import-resolution-error":Te,"circular-dependency":xe,"invalid-import":Ie,"dependency-missing":Se,"version-mismatch":Oe};var Ne=o({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),Ae=o({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),De=o({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),ve=o({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),be=o({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Me=o({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Le=o({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),we=o({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),Ue=o({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Pe=o({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),He=o({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Ve=o({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),Fe=o({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),ke=o({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),Ge=o({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),it={"port-in-use":Ne,"server-start-error":Ae,"cache-error":De,"file-watch-error":ve,"request-error":be,"service-overloaded":Me,"semaphore-timeout":Le,"circuit-breaker-open":we,"cache-path-mismatch":Ue,"network-error":Pe,"api-client-error":He,"token-storage-error":Ve,"cache-invariant-violation":Fe,"release-not-found":ke,"fallback-exhausted":Ge};var $e=o({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),Be=o({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),Ye=o({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),je=o({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),We=o({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),qe=o({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),at={"client-boundary-violation":$e,"server-only-in-client":Be,"client-only-in-server":Ye,"invalid-use-client":je,"invalid-use-server":We,"rsc-payload-error":qe};var ze=o({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),Je=o({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Xe=o({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),Ke=o({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Ze=o({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),ct={"hmr-error":ze,"dev-server-error":Je,"fast-refresh-error":Xe,"error-overlay-error":Ke,"source-map-error":Ze};var Qe=o({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),tr=o({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),er=o({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),rr=o({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),lt={"deployment-error":Qe,"platform-error":tr,"env-var-missing":er,"production-build-required":rr};var or=o({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),nr=o({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),sr=o({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),ir=o({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),ar=o({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),cr=o({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),lr=o({slug:"tool-id-conflict",category:"AGENT",status:409,title:"Tool ID conflict",suggestion:"Use a unique tool ID or rename one of the conflicting tools"}),ut={"agent-error":or,"agent-not-found":nr,"agent-timeout":sr,"agent-intent-error":ir,"orchestration-error":ar,"cost-limit-exceeded":cr,"tool-id-conflict":lr};var ur=o({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),dr=o({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),gr=o({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),pr=o({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),fr=o({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),mr=o({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),Rr=o({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Er=o({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),G=o({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),yr=o({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),dt={"unknown-error":ur,"permission-denied":dr,"file-not-found":gr,"resource-not-found":pr,"invalid-argument":fr,"timeout-error":mr,"initialization-error":Rr,"not-supported":Er,"security-violation":G,"input-validation-failed":yr};var En={...et,...rt,...ot,...nt,...st,...it,...at,...ct,...lt,...ut,...dt};var _r=[{source:String.raw`]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function hr(){return _r.map(({source:t,flags:e,name:r})=>({pattern:new RegExp(t,e),name:r}))}function Cr(){let t=globalThis;return t.__VERYFRONT_DEV__===!0||t.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function T(t,e={}){let{allowInlineScripts:r=!1,strict:n=!1,warn:s=!0}=e;for(let{pattern:u,name:c}of hr())if(!(r&&c==="inline script")&&(u.lastIndex=0,!!u.test(t)&&(s&&console.warn(`[Security] Suspicious ${c} detected in server HTML`),n||!Cr())))throw G.create({detail:`Potentially unsafe HTML: ${c} detected`});return t}function x(t,e){let r=e==="root"?C:`rsc-slot-${e}`,n=t.getElementById(r);if(n)return n;let s=t.createElement("div");return s.id=r,t.body.appendChild(s),s}function Tr(t,e){if(e.type!=="slot")return;let r=x(t,e.id);r.innerHTML=T(String(e.html??""))}function gt(t,e){let r=e.split(`\n`),n=r.pop()??"";for(let s of r){let u=s.trim();if(!u)continue;let c;try{c=JSON.parse(u)}catch(a){i.debug("[client-dom] malformed NDJSON line",{line:u,error:a instanceof Error?a.message:String(a)});continue}if(!c||typeof c!="object")continue;let g=c;if(g.type==="slot"){Tr(t,g);try{Sr(t,g.id||"root")}catch(a){i.debug("[client-dom] hydration optional failed",a)}}}return n}function xr(t){return new Promise((e,r)=>{let n=()=>r(new DOMException("aborted","AbortError"));if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0})})}async function pt(t,e=document,r){let n="body"in t?t:null,s=n?.body??t;if(!s)return;let u=s.getReader(),c=new TextDecoder,g="",a=!1;try{for(;;){if(r?.aborted)throw new DOMException("aborted","AbortError");let d=u.read(),{done:f,value:y}=r?await Promise.race([d,xr(r)]):await d;if(f){a=!0;break}g+=c.decode(y,{stream:!0}),g=gt(e,g)}g&>(e,`${g}\n`)}catch(d){throw d instanceof Error&&d.name==="AbortError"||i.debug("[client-dom] consumeNdjsonStream error",d),d}finally{try{await u.cancel()}catch(d){a||i.debug("[client-dom] reader.cancel failed",d)}try{u.releaseLock()}catch(d){i.debug("[client-dom] reader.releaseLock failed",d)}if(typeof s.cancel=="function")try{await s.cancel()}catch(d){i.debug("[client-dom] stream.cancel failed",d)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(d){i.debug("[client-dom] response.body.cancel failed",d)}}}function Ir(t,e){let r=x(t,e),n=[],s=u=>{let c=u;c.dataset?.clientRef&&n.push(c);for(let g of u.children)s(g)};return s(r),n}function Sr(t,e){let r=Ir(t,e);for(let n of r){let s=n.dataset?.clientRef;s&&(n.dataset.hydrated="true",i.debug("[client-dom] marked for hydration",s))}}var Or=new Set(["server","client","html","fragment"]);function ft(t){if(!t)return[];try{let e=JSON.parse(t);return Ar(e)?e.nodes:[]}catch{return[]}}async function B(t,e,r){return await Promise.all(t.map(n=>Nr(n,e,r)))}async function Nr(t,e,r){if(t.type==="html")return t.text??t.html??"";let n=await B(t.children??[],e,r);if(t.type==="fragment"||t.type==="server"&&!t.component)return e.createElement(e.Fragment,{},...n);if(t.type==="server")return e.createElement(t.component,t.props??{},...n);let s=await r(t.component);return s?e.createElement(s,t.props??{},...n):null}function Ar(t){return!$(t)||t.version!==1||!Array.isArray(t.nodes)?!1:t.nodes.every(e=>mt(e,0))}function mt(t,e){return e>100||!$(t)||!Or.has(t.type)||t.type==="html"&&typeof t.html!="string"&&typeof t.text!="string"||t.type==="client"&&typeof t.component!="string"||t.type==="server"&&t.component!==void 0&&typeof t.component!="string"||t.props!==void 0&&!$(t.props)?!1:t.children===void 0?!0:Array.isArray(t.children)&&t.children.every(r=>mt(r,e+1))}function $(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Dr(t){if(!t)return{};let e={};for(let[r,n]of Object.entries(t))e[r]=Array.isArray(n)?n.join("/"):n;return e}async function b(t,e,r=document){try{let n=tt(r);if(!n)return t;let u=(await import(n)).wrapForHydration;return typeof u!="function"?t:u(t,{params:Dr(e?.params),frontmatter:e?.frontmatter??{}})}catch(n){return i.debug("router provider wrap failed",n),t}}var vr=100;function br(t,e){if(globalThis.__VF_CLIENT_MOD_CACHE??(globalThis.__VF_CLIENT_MOD_CACHE=new Map),globalThis.__VF_CLIENT_MOD_CACHE.size>=vr){let r=globalThis.__VF_CLIENT_MOD_CACHE.keys().next().value;r&&globalThis.__VF_CLIENT_MOD_CACHE.delete(r)}globalThis.__VF_CLIENT_MOD_CACHE.set(t,e)}function Rt(t){let e=t.match(/^\\/app\\/(.+)#([\\w$.-]+)$/);if(e)return{rel:`/${e[1]||""}`,exportName:e[2]||"default"};let r=t.match(/^(\\/_veryfront\\/[^#]+)#([\\w$.-]+)$/);return r?{moduleUrl:r[1],exportName:r[2]||"default"}:(i.debug("hydrate: unrecognised client ref format, skipping",{ref:t}),null)}function Mr(t){let e=t.dataset?.rscProps;if(!e)return{};try{let r=JSON.parse(e);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch(r){return i.debug("hydrate: invalid client boundary props, using empty props",r),{}}}function Lr(t){return ft(t.dataset?.rscChildren)}async function wr(){try{let t=await fetch("/_veryfront/rsc/manifest");return t.ok?await t.json():null}catch{return null}}async function Et(t,e,r){let n=Ur(t,e,r),s=e.moduleUrl??e.rel;if(!s)return null;let u=`${s}#${t.hash??""}`;try{let c=globalThis.__VF_CLIENT_MOD_CACHE?.get(u);if(c)return c}catch(c){i.debug("hydrate: cache get failed",c)}if(!n)return null;try{let c=await import(n);try{br(u,c)}catch(g){i.debug("hydrate: cache set failed",g)}return c}catch(c){return i.debug("hydrate: failed to import module",{moduleUrl:n,error:c}),null}}function Ur(t,e,r){if(e.moduleUrl)return e.moduleUrl;if(!e.rel)return null;let n=t.graphIds?.client.find(s=>s.rel===e.rel)?.path;return D({strategy:r,rel:e.rel,absPath:n,version:t.hash})}function Pr(t){let e=Array.from(t.querySelectorAll("[data-client-ref]")),r=new Set(e);return e.filter(n=>{let s=n.parentElement;for(;s;){if(r.has(s))return!1;s=s.parentElement}return!0})}async function yt(t=document){let e=null;try{e=await wr()}catch(a){i.debug("hydrate: fetch manifest failed",a)}if(!e){i.debug("hydrate: no manifest");return}let r=Pr(t);try{let a=globalThis.__VF_MANIFEST_HASH;if(!r.some(f=>f.dataset?.hydrated!=="true")&&a&&e.hash&&a===e.hash)return}catch(a){i.debug("hydrate: hmr hash read failed",a)}if(r.length===0){try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(a){i.debug("hydrate: set hash failed",a)}return}let n=E(t),s=A(n);try{if(globalThis.__VF_TEST_MODE__){globalThis.__VF_HYDRATE_CALLED=!0,globalThis.__VF_MANIFEST_HASH=e.hash??"";return}}catch(a){i.debug("hydrate: test mode flags failed",a)}let u=v(t,n?.reactVersion),[{default:c},{createRoot:g}]=await Promise.all([import(u.react),import(u.reactDomClient)]);for(let a of r){let d=a.dataset?.clientRef??"";if(!d||a.dataset?.hydrated==="true")continue;let f=Rt(d);if(!f)continue;let y=await Et(e,f,s);if(!y)continue;let j=y[f.exportName]??y.default;if(typeof j=="function")try{let L=g(a),_t=Mr(a),ht=Lr(a),Ct=await B(ht,{Fragment:c.Fragment,createElement(I,w,...S){return c.createElement(I,w,...S)}},async I=>{let w=e.modules.find(xt=>xt.id===I),S=e.components?.[I],W=w?.clientRef??(S?`${S}#default`:void 0);if(!W)return null;let U=Rt(W);if(!U)return null;let P=await Et(e,U,s);if(!P)return null;let q=P[U.exportName]??P.default;return typeof q=="function"?q:null}),Tt=await b(c.createElement(j,_t,...Ct),n,t);L.render(Tt),a.dataset.hydrated="true"}catch(L){i.warn("hydrate: render failed",L)}}try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(a){i.debug("hydrate: set hash failed (post)",a)}}async function Hr(){let t=E(document),e=v(document,t?.reactVersion),[r,n]=await Promise.all([import(e.react),import(e.reactDomClient)]);return{React:r,ReactDOM:n}}var Vr=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE"]);function Y(t){let e=t.getAttribute("style")??"";return t.hasAttribute("data-veryfront-head")||t.hasAttribute("hidden")||/(?:^|;)\\s*display\\s*:\\s*none(?:\\s*;|$)/i.test(e)||Vr.has(t.tagName.toUpperCase())}function Fr(t,e){return t.find(r=>r.tagName.toUpperCase()==="DIV"&&!!r.getAttribute("class")?.trim()&&!Y(r))??e}function kr(t,e){return t===e}function Gr(t,e){let r=document.createElement("div");r.setAttribute("data-veryfront-hydration-root","page");let n=t.find(s=>!Y(s));n?.parentNode===e?e.insertBefore(r,n):e.appendChild(r);for(let s of t)!Y(s)&&s.parentNode===e&&r.appendChild(s);return r}function $r(t,e,r=document){return!!e?.pagePath&&typeof t?.__veryfrontRenderPage=="function"&&!!r.getElementById("root")}function Br(t,e){return e?.pagePath?!1:!!t.getElementById(C)}function Yr(t=import.meta.url){try{return new URL(t,"http://veryfront.local").searchParams.get("hydrate")==="1"}catch{return!1}}function jr(t){return t==="rsc-module"}async function Wr(t){try{let e=await fetch(h+"stream"+t);if(!e.ok||!e.body)return!1;let r=new AbortController;return addEventListener("pagehide",()=>r.abort(),{once:!0}),await pt(e,document,r.signal),!0}catch(e){return i.debug("tryStream failed",e),!1}}async function M(){try{await yt(document)}catch(t){i.debug("hydration failed",t)}}async function qr(t,e){try{let{React:r,ReactDOM:n}=await Hr(),s=D({strategy:e,rel:t});if(!s)return!1;i.debug("Loading component from:",s);let c=(await import(s)).default;if(typeof c!="function")return i.debug("Page component is not a function"),!1;let g=Array.from(document.body.children),a=Fr(g,document.body),d=kr(a,document.body)?Gr(g,document.body):a,f=await b(r.createElement(c,{}),E(document));return jr(e)?n.createRoot(d).render(f):n.hydrateRoot(d,f,{identifierPrefix:"vf",onRecoverableError:()=>{}}),i.debug("Page component hydrated successfully"),!0}catch(r){return i.error("Page hydration failed",r),!1}}async function zr(t){try{let e=await fetch(h+"payload"+t);if(!e.ok)return!1;let r=await e.json();if(r?.slots){for(let[n,s]of Object.entries(r.slots))x(document,n).innerHTML=T(String(s||""));return!0}return x(document,C).innerHTML=T(String(r?.html||"")),!0}catch(e){return i.debug("payload fetch failed",e),!1}}async function Jr(){try{let t=globalThis.window?.location.search??"",e=E(document);if(Yr()){await M();return}let r=e?.pagePath,n=A(e);if(r){if($r(globalThis.window,e,document)){i.debug("Page renderer owns hydration");return}i.debug("Found page component in hydration data:",r),await qr(r,n)&&i.debug("Client component hydrated successfully");return}if(!Br(document,e))return;if(await Wr(t)){await M();return}if(await zr(t)){await M();return}await M()}catch(t){i.error("boot failed",t)}}if(typeof document<"u"){let t=()=>{Jr()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{Jr as boot,Fr as selectHydrationRoot,Br as shouldAttemptRSCTransport,Yr as shouldHydrateOnly,jr as shouldRenderPageComponent,$r as shouldUsePageRendererHydration,kr as shouldWrapPageHydrationRoot};\n'; + 'var It=Object.defineProperty;var St=(t,e,r)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>St(t,typeof e!="symbol"?e+"":e,r);var Ot="3.2.3";function Nt(t,e,r,n){let s=[];if(n?.external?.length&&s.push(`external=${n.external.join(",")}`),s.push(`target=${n?.target??"es2022"}`),n?.deps){let a=Object.entries(n.deps).map(([d,f])=>`${d}@${f}`).join(",");s.push(`deps=${a}`)}let u=e?`@${e}`:"",c=r??"",g=s.length?`?${s.join("&")}`:"";return`https://esm.sh/${t}${u}${c}${g}`}function m(t,e,r,n=!1){return Nt(t,e,r,{external:n?["react"]:void 0,deps:{csstype:Ot}})}var Dt="19.2.4",_=Dt;function z(t=_){return{react:m("react",t),"react-dom":m("react-dom",t,void 0,!0),"react-dom/client":m("react-dom",t,"/client",!0),"react-dom/server":m("react-dom",t,"/server",!0),"react/jsx-runtime":m("react",t,"/jsx-runtime",!0),"react/jsx-dev-runtime":m("react",t,"/jsx-dev-runtime",!0)}}function J(t=_){return z(t).react}function X(t=_){return z(t)["react-dom/client"]}function vt(t){return t.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function bt(t){if(typeof globalThis.btoa=="function")try{return globalThis.btoa(t)}catch{let n=new TextEncoder().encode(t),s="";for(let u of n)s+=String.fromCharCode(u);return globalThis.btoa(s)}let e=globalThis.Buffer;if(e)return e.from(t,"utf8").toString("base64");throw new Error("Base64 encoding is not supported in this runtime")}function H(t){return vt(bt(t))}var so=Object.freeze({react:"","react-dom":"","react-dom/client":"","react-dom/server":"","react/jsx-runtime":"","react/jsx-dev-runtime":""});function O(t,e){if(!e)return!1;if(Object.prototype.hasOwnProperty.call(e,t))return!0;for(let r of Object.keys(e))if(r.endsWith("/")&&t.startsWith(r))return!0;return!1}function Mt(t){try{return JSON.parse(t)?.imports??{}}catch(e){return console.warn("Failed to parse import map JSON; treating as empty",{errorName:e instanceof Error?e.name:typeof e,inputLength:t.length}),{}}}function V(t=document){let e=t.querySelector(\'script[type="importmap"]\');return e?.textContent?Mt(e.textContent):{}}var l="/_veryfront",F={RSC:`${l}/rsc/`,FS:`${l}/fs/`,MODULES:`${l}/modules/`,PAGES:`${l}/pages/`,DATA:`${l}/data/`,LIB:`${l}/lib/`,CHUNKS:`${l}/chunks/`,CLIENT:`${l}/client/`},K={HMR_RUNTIME:`${l}/hmr-runtime.js`,HMR:`${l}/hmr.js`,ERROR_OVERLAY:`${l}/error-overlay.js`,DEV_LOADER:`${l}/dev-loader.js`,CLIENT_LOG:`${l}/log`,CLIENT_JS:`${l}/client.js`,ROUTER_JS:`${l}/router.js`,PREFETCH_JS:`${l}/prefetch.js`,MANIFEST_JSON:`${l}/manifest.json`,APP_JS:`${l}/app.js`,RSC_CLIENT:`${l}/rsc/client.js`,RSC_MANIFEST:`${l}/rsc/manifest`,RSC_STREAM:`${l}/rsc/stream`,RSC_PAYLOAD:`${l}/rsc/payload`,RSC_RENDER:`${l}/rsc/render`,RSC_PAGE:`${l}/rsc/page`,RSC_MODULE:`${l}/rsc/module`,RSC_DOM:`${l}/rsc/dom.js`,LIB_CHAT_REACT:`${l}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${l}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${l}/lib/chat/primitives.js`};var wt={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},uo=wt.CACHE;var go={HMR_RUNTIME:K.HMR_RUNTIME,ERROR_OVERLAY:K.ERROR_OVERLAY};var h=F.RSC,Z=F.FS,Q="veryfront-hydration-data",C="rsc-root";var R=class{constructor(e,r){p(this,"prefix",e);p(this,"level",r)}log(e,r,n,...s){this.level>e||r?.(n,...s)}debug(e,...r){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${e}`,...r)}info(e,...r){this.log(1,console.log,`[${this.prefix}] ${e}`,...r)}warn(e,...r){this.log(2,console.warn,`[${this.prefix}] WARN: ${e}`,...r)}error(e,...r){this.log(3,console.error,`[${this.prefix}] ERROR: ${e}`,...r)}};function Ut(){if(typeof window>"u")return 2;let t=globalThis;return t.__VERYFRONT_DEV__||t.__RSC_DEV__?t.__VERYFRONT_DEBUG__||t.__RSC_DEBUG__?0:1:2}var N=Ut(),i=new R("RSC",N),Eo=new R("PREFETCH",N),yo=new R("HYDRATE",N),_o=new R("VERYFRONT",N);function E(t=document){try{let e=t.getElementById(Q);return e?JSON.parse(e.textContent||"{}"):null}catch(e){return i.debug("hydration data parse failed",e),null}}function A(t){return t?.clientModuleStrategy?t.clientModuleStrategy:t?.dev?"fs":"rsc-module"}function Pt(t,e){if(!e)return t;let r=t.includes("?")?"&":"?";return`${t}${r}v=${encodeURIComponent(e)}`}function Ht(t,e){return Pt(`${Z}${H(t)}.js`,e)}function Vt(t,e){let r=e?`&v=${encodeURIComponent(e)}`:"";return`${h}module?rel=${encodeURIComponent(t)}${r}`}function D(t){if(t.strategy==="fs"){let e=t.absPath??t.rel;return e?Ht(e,t.version):null}return Vt(t.rel,t.version)}function v(t=document,e=_){let r=V(t);return{react:O("react",r)?"react":J(e),reactDomClient:O("react-dom/client",r)?"react-dom/client":X(e)}}function tt(t=document){let e=V(t);return O("veryfront/router",e)?"veryfront/router":null}function o(t){return{...t,create(e){return new k(e?.message||e?.detail||t.title,{slug:t.slug,category:t.category,status:e?.status??t.status,title:t.title,suggestion:t.suggestion,detail:e?.detail,cause:e?.cause,instance:e?.instance,context:e?.context})}}}var k=class extends Error{constructor(r,n){super(r);p(this,"slug");p(this,"category");p(this,"status");p(this,"title");p(this,"suggestion");p(this,"detail");p(this,"cause");p(this,"instance");p(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var Ft=o({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),kt=o({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),Gt=o({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),$t=o({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),Bt=o({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),Yt=o({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),jt=o({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),Wt=o({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),qt=o({slug:"webhook-config-invalid",category:"CONFIG",status:400,title:"Invalid webhook configuration",suggestion:"Check webhook definition fields, target settings, and eventFilter conditions"}),zt=o({slug:"schedule-config-invalid",category:"CONFIG",status:400,title:"Invalid schedule configuration",suggestion:"Check schedule definition fields, cron expression, target settings, and positive-integer limits"}),Jt=o({slug:"trigger-config-invalid",category:"CONFIG",status:400,title:"Invalid trigger configuration",suggestion:"Check trigger ID format (lowercase, alphanumeric, dots/slashes/hyphens) and ensure all input values are JSON-serializable"}),et={"config-not-found":Ft,"config-invalid":kt,"config-parse-error":Gt,"config-validation-error":$t,"config-type-error":Bt,"import-map-invalid":Yt,"cors-config-invalid":jt,"config-validation-failed":Wt,"webhook-config-invalid":qt,"schedule-config-invalid":zt,"trigger-config-invalid":Jt};var Xt=o({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),Kt=o({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),Zt=o({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),Qt=o({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),te=o({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),ee=o({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),re=o({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),oe=o({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),rt={"build-failed":Xt,"bundle-error":Kt,"typescript-error":Zt,"mdx-compile-error":Qt,"asset-optimization-error":te,"ssg-generation-error":ee,"sourcemap-error":re,"compilation-error":oe};var ne=o({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),se=o({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ie=o({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),ae=o({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),ce=o({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),le=o({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),ue=o({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),de=o({slug:"trigger-target-not-found",category:"RUNTIME",status:404,title:"Trigger target not found",suggestion:"Ensure the referenced task or workflow ID is registered in the project"}),ge=o({slug:"trigger-execution-failed",category:"RUNTIME",status:500,title:"Trigger target execution failed",suggestion:"Check the task or workflow for errors and review the trigger input"}),pe=o({slug:"trigger-not-supported",category:"RUNTIME",status:501,title:"Trigger target type not supported in local runtime",suggestion:"Use a workflow or task target for local trigger runs; agent targets require the Cloud runtime"}),ot={"hydration-mismatch":ne,"render-error":se,"component-error":ie,"layout-not-found":ae,"page-not-found":ce,"api-error":le,"middleware-error":ue,"trigger-target-not-found":de,"trigger-execution-failed":ge,"trigger-not-supported":pe};var fe=o({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),me=o({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),Re=o({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),Ee=o({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),ye=o({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),_e=o({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),nt={"route-conflict":fe,"invalid-route-file":me,"route-handler-invalid":Re,"dynamic-route-error":Ee,"route-params-error":ye,"api-route-error":_e};var he=o({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),Ce=o({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),Te=o({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),xe=o({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Ie=o({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Se=o({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),st={"module-not-found":he,"import-resolution-error":Ce,"circular-dependency":Te,"invalid-import":xe,"dependency-missing":Ie,"version-mismatch":Se};var Oe=o({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),Ne=o({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Ae=o({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),De=o({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),ve=o({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),be=o({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Me=o({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),Le=o({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),we=o({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Ue=o({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),Pe=o({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),He=o({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),Ve=o({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),Fe=o({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),ke=o({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),it={"port-in-use":Oe,"server-start-error":Ne,"cache-error":Ae,"file-watch-error":De,"request-error":ve,"service-overloaded":be,"semaphore-timeout":Me,"circuit-breaker-open":Le,"cache-path-mismatch":we,"network-error":Ue,"api-client-error":Pe,"token-storage-error":He,"cache-invariant-violation":Ve,"release-not-found":Fe,"fallback-exhausted":ke};var Ge=o({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),$e=o({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),Be=o({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),Ye=o({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),je=o({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),We=o({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),at={"client-boundary-violation":Ge,"server-only-in-client":$e,"client-only-in-server":Be,"invalid-use-client":Ye,"invalid-use-server":je,"rsc-payload-error":We};var qe=o({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),ze=o({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Je=o({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),Xe=o({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Ke=o({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),ct={"hmr-error":qe,"dev-server-error":ze,"fast-refresh-error":Je,"error-overlay-error":Xe,"source-map-error":Ke};var Ze=o({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),Qe=o({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),tr=o({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),er=o({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),lt={"deployment-error":Ze,"platform-error":Qe,"env-var-missing":tr,"production-build-required":er};var rr=o({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),or=o({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),nr=o({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),sr=o({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),ir=o({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),ar=o({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),cr=o({slug:"tool-id-conflict",category:"AGENT",status:409,title:"Tool ID conflict",suggestion:"Use a unique tool ID or rename one of the conflicting tools"}),ut={"agent-error":rr,"agent-not-found":or,"agent-timeout":nr,"agent-intent-error":sr,"orchestration-error":ir,"cost-limit-exceeded":ar,"tool-id-conflict":cr};var lr=o({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),ur=o({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),dr=o({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),gr=o({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),pr=o({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),fr=o({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),mr=o({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Rr=o({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),G=o({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),Er=o({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),dt={"unknown-error":lr,"permission-denied":ur,"file-not-found":dr,"resource-not-found":gr,"invalid-argument":pr,"timeout-error":fr,"initialization-error":mr,"not-supported":Rr,"security-violation":G,"input-validation-failed":Er};var Rn={...et,...rt,...ot,...nt,...st,...it,...at,...ct,...lt,...ut,...dt};var yr=[{source:String.raw`]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function _r(){return yr.map(({source:t,flags:e,name:r})=>({pattern:new RegExp(t,e),name:r}))}function hr(){let t=globalThis;return t.__VERYFRONT_DEV__===!0||t.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function T(t,e={}){let{allowInlineScripts:r=!1,strict:n=!1,warn:s=!0}=e;for(let{pattern:u,name:c}of _r())if(!(r&&c==="inline script")&&(u.lastIndex=0,!!u.test(t)&&(s&&console.warn(`[Security] Suspicious ${c} detected in server HTML`),n||!hr())))throw G.create({detail:`Potentially unsafe HTML: ${c} detected`});return t}function x(t,e){let r=e==="root"?C:`rsc-slot-${e}`,n=t.getElementById(r);if(n)return n;let s=t.createElement("div");return s.id=r,t.body.appendChild(s),s}function Cr(t,e){if(e.type!=="slot")return;let r=x(t,e.id);r.innerHTML=T(String(e.html??""))}function gt(t,e){let r=e.split(`\n`),n=r.pop()??"";for(let s of r){let u=s.trim();if(!u)continue;let c;try{c=JSON.parse(u)}catch(a){i.debug("[client-dom] malformed NDJSON line",{line:u,error:a instanceof Error?a.message:String(a)});continue}if(!c||typeof c!="object")continue;let g=c;if(g.type==="slot"){Cr(t,g);try{Ir(t,g.id||"root")}catch(a){i.debug("[client-dom] hydration optional failed",a)}}}return n}function Tr(t){return new Promise((e,r)=>{let n=()=>r(new DOMException("aborted","AbortError"));if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0})})}async function pt(t,e=document,r){let n="body"in t?t:null,s=n?.body??t;if(!s)return;let u=s.getReader(),c=new TextDecoder,g="",a=!1;try{for(;;){if(r?.aborted)throw new DOMException("aborted","AbortError");let d=u.read(),{done:f,value:y}=r?await Promise.race([d,Tr(r)]):await d;if(f){a=!0;break}g+=c.decode(y,{stream:!0}),g=gt(e,g)}g&>(e,`${g}\n`)}catch(d){throw d instanceof Error&&d.name==="AbortError"||i.debug("[client-dom] consumeNdjsonStream error",d),d}finally{try{await u.cancel()}catch(d){a||i.debug("[client-dom] reader.cancel failed",d)}try{u.releaseLock()}catch(d){i.debug("[client-dom] reader.releaseLock failed",d)}if(typeof s.cancel=="function")try{await s.cancel()}catch(d){i.debug("[client-dom] stream.cancel failed",d)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(d){i.debug("[client-dom] response.body.cancel failed",d)}}}function xr(t,e){let r=x(t,e),n=[],s=u=>{let c=u;c.dataset?.clientRef&&n.push(c);for(let g of u.children)s(g)};return s(r),n}function Ir(t,e){let r=xr(t,e);for(let n of r){let s=n.dataset?.clientRef;s&&(n.dataset.hydrated="true",i.debug("[client-dom] marked for hydration",s))}}var Sr=new Set(["server","client","html","fragment"]);function ft(t){if(!t)return[];try{let e=JSON.parse(t);return Nr(e)?e.nodes:[]}catch{return[]}}async function B(t,e,r){return await Promise.all(t.map(n=>Or(n,e,r)))}async function Or(t,e,r){if(t.type==="html")return t.text??t.html??"";let n=await B(t.children??[],e,r);if(t.type==="fragment"||t.type==="server"&&!t.component)return e.createElement(e.Fragment,{},...n);if(t.type==="server")return e.createElement(t.component,t.props??{},...n);let s=await r(t.component);return s?e.createElement(s,t.props??{},...n):null}function Nr(t){return!$(t)||t.version!==1||!Array.isArray(t.nodes)?!1:t.nodes.every(e=>mt(e,0))}function mt(t,e){return e>100||!$(t)||!Sr.has(t.type)||t.type==="html"&&typeof t.html!="string"&&typeof t.text!="string"||t.type==="client"&&typeof t.component!="string"||t.type==="server"&&t.component!==void 0&&typeof t.component!="string"||t.props!==void 0&&!$(t.props)?!1:t.children===void 0?!0:Array.isArray(t.children)&&t.children.every(r=>mt(r,e+1))}function $(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ar(t){if(!t)return{};let e={};for(let[r,n]of Object.entries(t))e[r]=Array.isArray(n)?n.join("/"):n;return e}async function b(t,e,r=document){try{let n=tt(r);if(!n)return t;let u=(await import(n)).wrapForHydration;return typeof u!="function"?t:u(t,{params:Ar(e?.params),frontmatter:e?.frontmatter??{}})}catch(n){return i.debug("router provider wrap failed",n),t}}var Dr=100;function vr(t,e){if(globalThis.__VF_CLIENT_MOD_CACHE??(globalThis.__VF_CLIENT_MOD_CACHE=new Map),globalThis.__VF_CLIENT_MOD_CACHE.size>=Dr){let r=globalThis.__VF_CLIENT_MOD_CACHE.keys().next().value;r&&globalThis.__VF_CLIENT_MOD_CACHE.delete(r)}globalThis.__VF_CLIENT_MOD_CACHE.set(t,e)}function Rt(t){let e=t.match(/^\\/app\\/(.+)#([\\w$.-]+)$/);if(e)return{rel:`/${e[1]||""}`,exportName:e[2]||"default"};let r=t.match(/^(\\/_veryfront\\/[^#]+)#([\\w$.-]+)$/);return r?{moduleUrl:r[1],exportName:r[2]||"default"}:(i.debug("hydrate: unrecognised client ref format, skipping",{ref:t}),null)}function br(t){let e=t.dataset?.rscProps;if(!e)return{};try{let r=JSON.parse(e);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch(r){return i.debug("hydrate: invalid client boundary props, using empty props",r),{}}}function Mr(t){return ft(t.dataset?.rscChildren)}async function Lr(){try{let t=await fetch("/_veryfront/rsc/manifest");return t.ok?await t.json():null}catch{return null}}async function Et(t,e,r){let n=wr(t,e,r),s=e.moduleUrl??e.rel;if(!s)return null;let u=`${s}#${t.hash??""}`;try{let c=globalThis.__VF_CLIENT_MOD_CACHE?.get(u);if(c)return c}catch(c){i.debug("hydrate: cache get failed",c)}if(!n)return null;try{let c=await import(n);try{vr(u,c)}catch(g){i.debug("hydrate: cache set failed",g)}return c}catch(c){return i.debug("hydrate: failed to import module",{moduleUrl:n,error:c}),null}}function wr(t,e,r){if(e.moduleUrl)return e.moduleUrl;if(!e.rel)return null;let n=t.graphIds?.client.find(s=>s.rel===e.rel)?.path;return D({strategy:r,rel:e.rel,absPath:n,version:t.hash})}function Ur(t){let e=Array.from(t.querySelectorAll("[data-client-ref]")),r=new Set(e);return e.filter(n=>{let s=n.parentElement;for(;s;){if(r.has(s))return!1;s=s.parentElement}return!0})}async function yt(t=document){let e=null;try{e=await Lr()}catch(a){i.debug("hydrate: fetch manifest failed",a)}if(!e){i.debug("hydrate: no manifest");return}let r=Ur(t);try{let a=globalThis.__VF_MANIFEST_HASH;if(!r.some(f=>f.dataset?.hydrated!=="true")&&a&&e.hash&&a===e.hash)return}catch(a){i.debug("hydrate: hmr hash read failed",a)}if(r.length===0){try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(a){i.debug("hydrate: set hash failed",a)}return}let n=E(t),s=A(n);try{if(globalThis.__VF_TEST_MODE__){globalThis.__VF_HYDRATE_CALLED=!0,globalThis.__VF_MANIFEST_HASH=e.hash??"";return}}catch(a){i.debug("hydrate: test mode flags failed",a)}let u=v(t,n?.reactVersion),[{default:c},{createRoot:g}]=await Promise.all([import(u.react),import(u.reactDomClient)]);for(let a of r){let d=a.dataset?.clientRef??"";if(!d||a.dataset?.hydrated==="true")continue;let f=Rt(d);if(!f)continue;let y=await Et(e,f,s);if(!y)continue;let j=y[f.exportName]??y.default;if(typeof j=="function")try{let L=g(a),_t=br(a),ht=Mr(a),Ct=await B(ht,{Fragment:c.Fragment,createElement(I,w,...S){return c.createElement(I,w,...S)}},async I=>{let w=e.modules.find(xt=>xt.id===I),S=e.components?.[I],W=w?.clientRef??(S?`${S}#default`:void 0);if(!W)return null;let U=Rt(W);if(!U)return null;let P=await Et(e,U,s);if(!P)return null;let q=P[U.exportName]??P.default;return typeof q=="function"?q:null}),Tt=await b(c.createElement(j,_t,...Ct),n,t);L.render(Tt),a.dataset.hydrated="true"}catch(L){i.warn("hydrate: render failed",L)}}try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(a){i.debug("hydrate: set hash failed (post)",a)}}async function Pr(){let t=E(document),e=v(document,t?.reactVersion),[r,n]=await Promise.all([import(e.react),import(e.reactDomClient)]);return{React:r,ReactDOM:n}}var Hr=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE"]);function Y(t){let e=t.getAttribute("style")??"";return t.hasAttribute("data-veryfront-head")||t.hasAttribute("hidden")||/(?:^|;)\\s*display\\s*:\\s*none(?:\\s*;|$)/i.test(e)||Hr.has(t.tagName.toUpperCase())}function Vr(t,e){return t.find(r=>r.tagName.toUpperCase()==="DIV"&&!!r.getAttribute("class")?.trim()&&!Y(r))??e}function Fr(t,e){return t===e}function kr(t,e){let r=document.createElement("div");r.setAttribute("data-veryfront-hydration-root","page");let n=t.find(s=>!Y(s));n?.parentNode===e?e.insertBefore(r,n):e.appendChild(r);for(let s of t)!Y(s)&&s.parentNode===e&&r.appendChild(s);return r}function Gr(t,e,r=document){return!!e?.pagePath&&typeof t?.__veryfrontRenderPage=="function"&&!!r.getElementById("root")}function $r(t,e){return e?.pagePath?!1:!!t.getElementById(C)}function Br(t=import.meta.url){try{return new URL(t,"http://veryfront.local").searchParams.get("hydrate")==="1"}catch{return!1}}function Yr(t){return t==="rsc-module"}async function jr(t){try{let e=await fetch(h+"stream"+t);if(!e.ok||!e.body)return!1;let r=new AbortController;return addEventListener("pagehide",()=>r.abort(),{once:!0}),await pt(e,document,r.signal),!0}catch(e){return i.debug("tryStream failed",e),!1}}async function M(){try{await yt(document)}catch(t){i.debug("hydration failed",t)}}async function Wr(t,e){try{let{React:r,ReactDOM:n}=await Pr(),s=D({strategy:e,rel:t});if(!s)return!1;i.debug("Loading component from:",s);let c=(await import(s)).default;if(typeof c!="function")return i.debug("Page component is not a function"),!1;let g=Array.from(document.body.children),a=Vr(g,document.body),d=Fr(a,document.body)?kr(g,document.body):a,f=await b(r.createElement(c,{}),E(document));return Yr(e)?n.createRoot(d).render(f):n.hydrateRoot(d,f,{identifierPrefix:"vf",onRecoverableError:()=>{}}),i.debug("Page component hydrated successfully"),!0}catch(r){return i.error("Page hydration failed",r),!1}}async function qr(t){try{let e=await fetch(h+"payload"+t);if(!e.ok)return!1;let r=await e.json();if(r?.slots){for(let[n,s]of Object.entries(r.slots))x(document,n).innerHTML=T(String(s||""));return!0}return x(document,C).innerHTML=T(String(r?.html||"")),!0}catch(e){return i.debug("payload fetch failed",e),!1}}async function zr(){try{let t=globalThis.window?.location.search??"",e=E(document);if(Br()){await M();return}let r=e?.pagePath,n=A(e);if(r){if(Gr(globalThis.window,e,document)){i.debug("Page renderer owns hydration");return}i.debug("Found page component in hydration data:",r),await Wr(r,n)&&i.debug("Client component hydrated successfully");return}if(!$r(document,e))return;if(await jr(t)){await M();return}if(await qr(t)){await M();return}await M()}catch(t){i.error("boot failed",t)}}if(typeof document<"u"){let t=()=>{zr()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{zr as boot,Vr as selectHydrationRoot,$r as shouldAttemptRSCTransport,Br as shouldHydrateOnly,Yr as shouldRenderPageComponent,Gr as shouldUsePageRendererHydration,Fr as shouldWrapPageHydrationRoot};\n'; export const CLIENT_DOM_BUNDLE: string = 'var V=Object.defineProperty;var k=(r,t,o)=>t in r?V(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var l=(r,t,o)=>k(r,typeof t!="symbol"?t+"":t,o);function e(r){return{...r,create(t){return new f(t?.message||t?.detail||r.title,{slug:r.slug,category:r.category,status:t?.status??r.status,title:r.title,suggestion:r.suggestion,detail:t?.detail,cause:t?.cause,instance:t?.instance,context:t?.context})}}}var f=class extends Error{constructor(o,n){super(o);l(this,"slug");l(this,"category");l(this,"status");l(this,"title");l(this,"suggestion");l(this,"detail");l(this,"cause");l(this,"instance");l(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var w=e({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),F=e({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),H=e({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),Y=e({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),B=e({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),$=e({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),j=e({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),q=e({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),z=e({slug:"webhook-config-invalid",category:"CONFIG",status:400,title:"Invalid webhook configuration",suggestion:"Check webhook definition fields, target settings, and eventFilter conditions"}),W=e({slug:"schedule-config-invalid",category:"CONFIG",status:400,title:"Invalid schedule configuration",suggestion:"Check schedule definition fields, cron expression, target settings, and positive-integer limits"}),J=e({slug:"trigger-config-invalid",category:"CONFIG",status:400,title:"Invalid trigger configuration",suggestion:"Check trigger ID format (lowercase, alphanumeric, dots/slashes/hyphens) and ensure all input values are JSON-serializable"}),y={"config-not-found":w,"config-invalid":F,"config-parse-error":H,"config-validation-error":Y,"config-type-error":B,"import-map-invalid":$,"cors-config-invalid":j,"config-validation-failed":q,"webhook-config-invalid":z,"schedule-config-invalid":W,"trigger-config-invalid":J};var X=e({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),K=e({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),Z=e({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),Q=e({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),ee=e({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),te=e({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),re=e({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),oe=e({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),I={"build-failed":X,"bundle-error":K,"typescript-error":Z,"mdx-compile-error":Q,"asset-optimization-error":ee,"ssg-generation-error":te,"sourcemap-error":re,"compilation-error":oe};var ne=e({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),se=e({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ie=e({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),ae=e({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),ce=e({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),ue=e({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),le=e({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),ge=e({slug:"trigger-target-not-found",category:"RUNTIME",status:404,title:"Trigger target not found",suggestion:"Ensure the referenced task or workflow ID is registered in the project"}),pe=e({slug:"trigger-execution-failed",category:"RUNTIME",status:500,title:"Trigger target execution failed",suggestion:"Check the task or workflow for errors and review the trigger input"}),de=e({slug:"trigger-not-supported",category:"RUNTIME",status:501,title:"Trigger target type not supported in local runtime",suggestion:"Use a workflow or task target for local trigger runs; agent targets require the Cloud runtime"}),O={"hydration-mismatch":ne,"render-error":se,"component-error":ie,"layout-not-found":ae,"page-not-found":ce,"api-error":ue,"middleware-error":le,"trigger-target-not-found":ge,"trigger-execution-failed":pe,"trigger-not-supported":de};var Ee=e({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),Re=e({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),fe=e({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),me=e({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),_e=e({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),ye=e({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),T={"route-conflict":Ee,"invalid-route-file":Re,"route-handler-invalid":fe,"dynamic-route-error":me,"route-params-error":_e,"api-route-error":ye};var Ie=e({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),Oe=e({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),Te=e({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),he=e({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),xe=e({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Se=e({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),h={"module-not-found":Ie,"import-resolution-error":Oe,"circular-dependency":Te,"invalid-import":he,"dependency-missing":xe,"version-mismatch":Se};var Ne=e({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),ve=e({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Ce=e({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),Ae=e({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),De=e({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Le=e({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Ue=e({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),be=e({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),Me=e({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Ge=e({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),Pe=e({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Ve=e({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),ke=e({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),we=e({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),Fe=e({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),x={"port-in-use":Ne,"server-start-error":ve,"cache-error":Ce,"file-watch-error":Ae,"request-error":De,"service-overloaded":Le,"semaphore-timeout":Ue,"circuit-breaker-open":be,"cache-path-mismatch":Me,"network-error":Ge,"api-client-error":Pe,"token-storage-error":Ve,"cache-invariant-violation":ke,"release-not-found":we,"fallback-exhausted":Fe};var He=e({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),Ye=e({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),Be=e({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),$e=e({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),je=e({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),qe=e({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),S={"client-boundary-violation":He,"server-only-in-client":Ye,"client-only-in-server":Be,"invalid-use-client":$e,"invalid-use-server":je,"rsc-payload-error":qe};var ze=e({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),We=e({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Je=e({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),Xe=e({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Ke=e({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),N={"hmr-error":ze,"dev-server-error":We,"fast-refresh-error":Je,"error-overlay-error":Xe,"source-map-error":Ke};var Ze=e({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),Qe=e({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),et=e({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),tt=e({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),v={"deployment-error":Ze,"platform-error":Qe,"env-var-missing":et,"production-build-required":tt};var rt=e({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),ot=e({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),nt=e({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),st=e({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),it=e({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),at=e({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),ct=e({slug:"tool-id-conflict",category:"AGENT",status:409,title:"Tool ID conflict",suggestion:"Use a unique tool ID or rename one of the conflicting tools"}),C={"agent-error":rt,"agent-not-found":ot,"agent-timeout":nt,"agent-intent-error":st,"orchestration-error":it,"cost-limit-exceeded":at,"tool-id-conflict":ct};var ut=e({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),lt=e({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),gt=e({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),pt=e({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),dt=e({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),Et=e({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),Rt=e({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),ft=e({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),m=e({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),mt=e({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),A={"unknown-error":ut,"permission-denied":lt,"file-not-found":gt,"resource-not-found":pt,"invalid-argument":dt,"timeout-error":Et,"initialization-error":Rt,"not-supported":ft,"security-violation":m,"input-validation-failed":mt};var fr={...y,...I,...O,...T,...h,...x,...S,...N,...v,...C,...A};var _t=[{source:String.raw`]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function yt(){return _t.map(({source:r,flags:t,name:o})=>({pattern:new RegExp(r,t),name:o}))}function It(){let r=globalThis;return r.__VERYFRONT_DEV__===!0||r.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function D(r,t={}){let{allowInlineScripts:o=!1,strict:n=!1,warn:i=!0}=t;for(let{pattern:c,name:u}of yt())if(!(o&&u==="inline script")&&(c.lastIndex=0,!!c.test(r)&&(i&&console.warn(`[Security] Suspicious ${u} detected in server HTML`),n||!It())))throw m.create({detail:`Potentially unsafe HTML: ${u} detected`});return r}var E=class{constructor(t,o){l(this,"prefix",t);l(this,"level",o)}log(t,o,n,...i){this.level>t||o?.(n,...i)}debug(t,...o){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${t}`,...o)}info(t,...o){this.log(1,console.log,`[${this.prefix}] ${t}`,...o)}warn(t,...o){this.log(2,console.warn,`[${this.prefix}] WARN: ${t}`,...o)}error(t,...o){this.log(3,console.error,`[${this.prefix}] ERROR: ${t}`,...o)}};function Ot(){if(typeof window>"u")return 2;let r=globalThis;return r.__VERYFRONT_DEV__||r.__RSC_DEV__?r.__VERYFRONT_DEBUG__||r.__RSC_DEBUG__?0:1:2}var R=Ot(),p=new E("RSC",R),br=new E("PREFETCH",R),Mr=new E("HYDRATE",R),Gr=new E("VERYFRONT",R);var s="/_veryfront",_={RSC:`${s}/rsc/`,FS:`${s}/fs/`,MODULES:`${s}/modules/`,PAGES:`${s}/pages/`,DATA:`${s}/data/`,LIB:`${s}/lib/`,CHUNKS:`${s}/chunks/`,CLIENT:`${s}/client/`},L={HMR_RUNTIME:`${s}/hmr-runtime.js`,HMR:`${s}/hmr.js`,ERROR_OVERLAY:`${s}/error-overlay.js`,DEV_LOADER:`${s}/dev-loader.js`,CLIENT_LOG:`${s}/log`,CLIENT_JS:`${s}/client.js`,ROUTER_JS:`${s}/router.js`,PREFETCH_JS:`${s}/prefetch.js`,MANIFEST_JSON:`${s}/manifest.json`,APP_JS:`${s}/app.js`,RSC_CLIENT:`${s}/rsc/client.js`,RSC_MANIFEST:`${s}/rsc/manifest`,RSC_STREAM:`${s}/rsc/stream`,RSC_PAYLOAD:`${s}/rsc/payload`,RSC_RENDER:`${s}/rsc/render`,RSC_PAGE:`${s}/rsc/page`,RSC_MODULE:`${s}/rsc/module`,RSC_DOM:`${s}/rsc/dom.js`,LIB_CHAT_REACT:`${s}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${s}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${s}/lib/chat/primitives.js`};var ht={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},Hr=ht.CACHE;var Yr={HMR_RUNTIME:L.HMR_RUNTIME,ERROR_OVERLAY:L.ERROR_OVERLAY};var qr=_.RSC,zr=_.FS;var U="rsc-root";function M(r,t){let o=t==="root"?U:`rsc-slot-${t}`,n=r.getElementById(o);if(n)return n;let i=r.createElement("div");return i.id=o,r.body.appendChild(i),i}function xt(r,t){if(t.type!=="slot")return;let o=M(r,t.id);o.innerHTML=D(String(t.html??""))}function b(r,t){let o=t.split(`\n`),n=o.pop()??"";for(let i of o){let c=i.trim();if(!c)continue;let u;try{u=JSON.parse(c)}catch(d){p.debug("[client-dom] malformed NDJSON line",{line:c,error:d instanceof Error?d.message:String(d)});continue}if(!u||typeof u!="object")continue;let g=u;if(g.type==="slot"){xt(r,g);try{vt(r,g.id||"root")}catch(d){p.debug("[client-dom] hydration optional failed",d)}}}return n}function St(r){return new Promise((t,o)=>{let n=()=>o(new DOMException("aborted","AbortError"));if(r.aborted){n();return}r.addEventListener("abort",n,{once:!0})})}async function Zr(r,t=document,o){let n="body"in r?r:null,i=n?.body??r;if(!i)return;let c=i.getReader(),u=new TextDecoder,g="",d=!1;try{for(;;){if(o?.aborted)throw new DOMException("aborted","AbortError");let a=c.read(),{done:G,value:P}=o?await Promise.race([a,St(o)]):await a;if(G){d=!0;break}g+=u.decode(P,{stream:!0}),g=b(t,g)}g&&b(t,`${g}\n`)}catch(a){throw a instanceof Error&&a.name==="AbortError"||p.debug("[client-dom] consumeNdjsonStream error",a),a}finally{try{await c.cancel()}catch(a){d||p.debug("[client-dom] reader.cancel failed",a)}try{c.releaseLock()}catch(a){p.debug("[client-dom] reader.releaseLock failed",a)}if(typeof i.cancel=="function")try{await i.cancel()}catch(a){p.debug("[client-dom] stream.cancel failed",a)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(a){p.debug("[client-dom] response.body.cancel failed",a)}}}function Nt(r,t){let o=M(r,t),n=[],i=c=>{let u=c;u.dataset?.clientRef&&n.push(u);for(let g of c.children)i(g)};return i(o),n}function vt(r,t){let o=Nt(r,t);for(let n of o){let i=n.dataset?.clientRef;i&&(n.dataset.hydrated="true",p.debug("[client-dom] marked for hydration",i))}}export{Zr as consumeNdjsonStream,M as getContainer};\n'; diff --git a/src/workflow/executor/step-executor.ts b/src/workflow/executor/step-executor.ts index 7eafc929fd..e83f76dfe6 100644 --- a/src/workflow/executor/step-executor.ts +++ b/src/workflow/executor/step-executor.ts @@ -233,7 +233,7 @@ export class StepExecutor { }; } - /** HTTP-style statuses worth retrying: timeout, rate limit, and transient 5xx. */ + /** Shared transient classification (HTTP statuses + network error codes) via retry-policy. */ private isRetryableError(error: Error, config: RetryConfig): boolean { // Starting another attempt while the timed-out operation is still active // would violate step isolation and allow concurrent external side effects.