/** * The persistent-agent HTTP route contract, shared by every runtime target. * * Node boots `server.ts` directly; Cloudflare runs a worker generated by the * build. Both must expose the same URLs, parse them the same way, and return * the same admission receipt — a client cannot be expected to special-case the * backend it happens to be talking to. Parsing and receipt construction live * here so there is one definition rather than one per target. * * Runtime-neutral by construction: this module touches only URLs and plain * objects, never a store, a submission runner, or a platform binding. */ /** Subroutes under `/agents/:name/:instanceId`. */ export type AgentRouteSection = "submissions" | "conversation" | "abort" | "schedules" | "stream"; export interface AgentRouteMatch { /** Registered agent name, percent-decoded. */ agent: string; /** Caller-chosen durable instance id, percent-decoded. */ instanceId: string; /** Absent for the instance root (`POST`/`GET`/`DELETE`). */ section?: AgentRouteSection; /** Trailing identifier, e.g. the submission id under `submissions`. */ resourceId?: string; } /** * Parse a pathname against the agent route surface. * * Returns `undefined` when the path is not an agent route, so a caller can * fall through to its other route families. Percent-decoding happens here: a * target that matched the raw segments would treat `ticket%2F1` as a different * instance than the one the client addressed. */ export declare function matchAgentRoute(pathname: string): AgentRouteMatch | undefined; /** Session name carried by `?session=`, defaulting to `default`. */ export declare function agentRouteSession(searchParams: URLSearchParams): string; export interface AgentSubmissionReceiptInput { submissionId: string; agent: string; instanceId: string; session: string; /** * Stream position captured *before* admission, so reading from it returns * this delivery and everything the agent produces answering it. A target * that cannot determine the position must not substitute `"0"` — that * silently re-reads the whole conversation on every send. */ offset: string; /** Resolved persistent-instance generation, when the target has one. */ uid?: string; /** ISO-8601 admission timestamp, when the target records one. */ acceptedAt?: string; /** * Whether this target serves the SSE updates route. Targets without one * omit `updatesUrl` rather than advertising a URL that 404s. */ updates?: boolean; } export interface AgentSubmissionReceipt { submissionId: string; uid?: string; acceptedAt?: string; streamUrl: string; conversationUrl: string; updatesUrl?: string; offset: string; } /** Base path for one persistent instance, with both segments escaped. */ export declare function agentInstancePath(agent: string, instanceId: string): string; /** * Build the `202` admission receipt. * * `streamUrl` and `conversationUrl` are the same URL; the former is retained * for compatibility with clients written against the earlier shape. */ export declare function agentSubmissionReceipt(input: AgentSubmissionReceiptInput): AgentSubmissionReceipt; //# sourceMappingURL=agent-route.d.ts.map