import type { ResourceCtx } from '../../../core/extend-resource.js'; import { parseHerokuLogLine } from './parser.js'; export { type AttachmentAttachedEvent, type AttachmentDetachedEvent, type AttachmentUpdatedEvent, type HerokuLogEvent, parseHerokuLogLine, type ProvisioningCompletedEvent, type ScaledToEntry, type ScaledToEvent, type StartingProcessEvent, type StateChangedEvent, } from './parser.js'; export type StreamLogsOptions = { /** Limit output to a single dyno (e.g. `web.1` on Cedar, `web-abc-123` on Fir). */ dyno?: string; /** * Number of recent lines to fetch before tailing. Cedar-generation * apps only — silently ignored on Fir. */ lines?: number; /** * Maximum number of consecutive transport-error reconnects (TCP * reset, proxy `terminated`, EOF mid-stream, etc.) before the * iterator gives up and surfaces the error. Counter resets the * moment a real line yields again. Defaults to 5. */ maxConsecutiveTransportErrors?: number; /** * Cap on the per-attempt backoff after exponential growth. * Defaults to 5000ms. */ maxRetryDelayMs?: number; /** * Fires once per session creation, before the SDK opens the * `logplex_url` stream. Receives the resolved generation so the * caller can surface generation-specific UX (e.g. "Fetching * logs..." for Fir, where provisioning the stream takes a moment). * * Fires on every recreate when tailing. */ onSessionCreated?: (info: { generation: 'cedar' | 'fir' | undefined; isRecreate: boolean; }) => Promise | void; /** * When `tail` is true, watch for the platform's idle timeout and * recreate the log session to keep streaming. Defaults to true. * Set to false if you want a single bounded stream and surface the * disconnect to the caller. */ recreateSession?: boolean; /** * Initial backoff between reconnect attempts after a transport * error; doubles each attempt up to {@link maxRetryDelayMs}. * Defaults to 500ms. */ retryBaseDelayMs?: number; /** * If `recreateSession` is true, the SDK forces a recreate after * this many milliseconds without seeing data. Defaults to * 15 minutes (matches the Fir platform timeout). */ sessionTimeoutMs?: number; signal?: AbortSignal; /** Limit output to a single source (e.g. `app`, `heroku`). */ source?: string; /** * If true, the platform keeps the stream open and pushes lines as * they arrive. The platform may close the connection on its own * cadence (Fir is documented to time out around 15 minutes); when * `recreateSession` is also true, the SDK transparently opens a * new session and continues yielding lines. * * Defaults to false. Note: Fir-generation apps always tail (the * platform doesn't support a bounded log session there), so the * SDK forces `tail: true` for Fir regardless of what the caller * asked for. */ tail?: boolean; /** * Limit output to a process type (e.g. `web`, `worker`). On Cedar * the underlying API combines `dyno` and `type` into a single * field; the SDK handles that translation for you. */ type?: string; }; /** * Stream logs for an app, yielding one line at a time. * * Creates a log session via `logSession.create`, opens the resulting * `logplex_url`, and parses the chunked plain-text response into * newline-delimited entries. Use `tail: true` to keep the stream * open; `recreateSession: true` (the default when tailing) makes the * SDK transparently re-open a new session after the platform's idle * timeout, so the iterator keeps yielding without the caller having * to handle the reconnect. * * The iterator terminates cleanly when: * - the platform closes a non-tailing stream (all lines yielded) * - `signal` is aborted (an `AbortError` propagates) * - `recreateSession` is false and the platform closes a tail * * The iterator throws on: * - non-2xx response from the logplex URL * - errors thrown by `logSession.create` (auth, app-not-found, etc.) */ export declare function streamLogs(ctx: Pick, appIdentity: string, options?: StreamLogsOptions): AsyncGenerator; export declare const logSessionExtensions: import("../../../core/extend-resource.js").ResourceExtension<"platform", "logSession", { parseHerokuLogLine: typeof parseHerokuLogLine; streamLogs: (appIdentity: string, options?: StreamLogsOptions) => AsyncGenerator; }>;