export declare const AGENT_CHAT_PROCESS_RUN_PATH = "/_agent-native/agent-chat/_process-run"; export declare const AGENT_CHAT_RECOVERY_OF_RUN_FIELD = "__agentChatRecoveryOfRunId"; export declare const AGENT_TEAM_PROCESS_RUN_PATH = "/_agent-native/agent-teams/_process-run"; export declare const AGENT_BACKGROUND_FUNCTION_NAME = "server-agent-background"; export declare const AGENT_BACKGROUND_FUNCTION_URL_PATH = "/.netlify/functions/server-agent-background"; export declare const AGENT_BACKGROUND_PROCESSOR_FIELD = "__agentNativeProcessor"; export declare const AGENT_BACKGROUND_PROCESSOR_A2A = "a2a"; export declare const AGENT_BACKGROUND_PROCESSOR_INTEGRATION = "integration"; export declare const AGENT_BACKGROUND_PROCESSOR_AGENT_TEAM = "agent-team"; export declare const AGENT_BACKGROUND_PROCESSOR_ROUTE = "route"; export declare const AGENT_BACKGROUND_PROCESSOR_ROUTE_FIELD = "__agentNativeProcessorRoute"; /** * Resolve the path the foreground POST should self-dispatch the chat background * worker to. * * GROUNDED IN THE REAL NETLIFY BUILD OUTPUT + THE NETLIFY DOCS DEFAULT-URL RULE: * the background function is emitted INTO the scanned dir * (`.netlify/functions-internal/server-agent-background`, or per-app * `-agent-background` for workspaces) with `export const config = { * background: true, ... }` and NO custom `config.path`. Because it has no custom * path, Netlify keeps its DEFAULT function url `/.netlify/functions/`, and * `background: true` makes any invocation of that url ASYNC (immediate 202, * 15-min budget). The Nitro `server` function already excludes `/.netlify/*` * from its `/*` catch-all, so the default-url namespace is NEVER shadowed by the * synchronous function. * * Therefore on hosted Netlify the foreground dispatches to the function's DEFAULT * url (`/.netlify/functions/`); the function entry then rewrites the * incoming pathname to `AGENT_CHAT_PROCESS_RUN_PATH` (base-path-prefixed for * workspaces) before delegating to the Nitro router, so the `_process-run` * plugin runs with the async 15-min budget. Everywhere else (local dev, `netlify * dev`, non-Netlify hosts where no second function exists) there is no second * function, so the foreground dispatches to the framework route * `AGENT_CHAT_PROCESS_RUN_PATH` and the same in-process catch-all handles it * inline. The HMAC token (signed over the runId) is unchanged either way. * * NOTE: this is the DOC-CORRECT approach. An earlier attempt gave the function a * custom `config.path` + a catch-all `excludedPath` patch; the custom path was * NOT honored as a route in prod (probe → 404). Using the default function url * (no custom path) is what Netlify documents and is simpler — there is nothing * to shadow because `/.netlify/*` is already excluded from the `server` catch-all. */ export declare function resolveAgentChatProcessRunDispatchPath(): string; export declare function resolveDurableBackgroundDispatchPath(fallbackPath: string): string; export declare function dispatchPathTargetsNetlifyBackgroundFunction(dispatchPath: string): boolean; export declare const AGENT_CHAT_DURABLE_BACKGROUND_ENV = "AGENT_CHAT_DURABLE_BACKGROUND"; /** * Body field the foreground handler injects when self-dispatching to the * background processor. Its presence is how the re-entered handler knows it is * the background worker (run inline with the background soft-timeout; do NOT * re-claim the slot or re-dispatch). Untrusted on its own — the route also * verifies the HMAC token before invoking the handler. */ export declare const AGENT_CHAT_BACKGROUND_RUN_FIELD = "__backgroundRun"; export declare const AGENT_CHAT_BACKGROUND_SETUP_CLEANUP_FIELD = "__agentChatBackgroundSetupCleanup"; /** Analytics-only source context captured before the run leaves its browser request. */ export declare const AGENT_CHAT_BROWSER_SESSION_ID_FIELD = "__agentNativeBrowserSessionId"; /** Captured turn origin; durable workers do not restore loopback trust from this payload. */ export declare const AGENT_CHAT_REQUEST_CONTEXT_FIELD = "__agentChatRequestContext"; export declare function isHostedRuntimeForDurableBackground(): boolean; export declare function isNetlifyHostedRuntimeForDurableBackground(): boolean; export declare function isInBackgroundFunctionRuntime(): boolean; export declare function backgroundRunMarkerExpectsBackgroundRuntime(marker: unknown): boolean; export declare function shouldUseBackgroundFunctionTimeoutForWorker(_marker: unknown): boolean; export declare function backgroundRuntimeDiagnosticDetail(marker: unknown): string; export declare const BACKGROUND_FUNCTION_UNREACHABLE_NOTICE_KEY = "__AGENT_NATIVE_BACKGROUND_UNREACHABLE_NOTICE__"; export declare function isDurableBackgroundFlagEnabled(): boolean; export declare function isDurableBackgroundFlagExplicitlyDisabled(): boolean; export declare function isAgentChatDurableBackgroundEnabled(options?: { appOptIn?: boolean; }): boolean; export declare const AGENT_CHAT_FOREGROUND_SELF_CHAIN_ENV = "AGENT_CHAT_FOREGROUND_SELF_CHAIN"; export declare function isAgentChatForegroundSelfChainEnabled(): boolean; export type ProcessRunPreparation = { ok: true; runId: string; body: Record; } | { ok: false; status: number; error: string; runId: string | null; }; export declare function extractProcessRunId(body: unknown): string | null; /** * Pure, transport-agnostic core of the `_process-run` route: validate the body, * authenticate the HMAC self-dispatch, and produce the body the re-entered * agent-chat handler should run as the background worker. * * Auth policy mirrors the agent-teams processor exactly: * - `A2A_SECRET` set → require a valid `verifyInternalToken(runId, token)`. * - no secret → require `isTrustedLocalRuntime({ loopback })` (see * auth-policy.ts): refuse (503) unless `A2A_ALLOW_UNSIGNED_INTERNAL=1` is * set. This function has no h3 `event` of its own, so callers that CAN * see the inbound socket peer (the route handler, which has the event) * should compute `loopback` from it and pass it through; callers that * can't determine the peer address should omit it (defaults to `false` * — never trust unsigned dispatch without an explicit opt-in). * * Extracted from the route handler so the auth + marker-prep decision is unit * testable without booting the whole Nitro plugin. The route only adds body * reading and the final handler invocation around this. */ export declare function prepareProcessRunRequest(body: unknown, authHeader: string | undefined, loopback?: boolean): ProcessRunPreparation;