{"version":3,"file":"types.cjs","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":["import type { RegisterOptions } from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\n\nexport const DEFAULT_SHUTDOWN_SIGNALS = [\"SIGINT\", \"SIGTERM\"];\n\nexport interface ConnectApp {\n  client: Inngest.Any;\n  functions?: Array<InngestFunction.Like>;\n}\n\nexport interface ConnectHandlerOptions extends RegisterOptions {\n  apps: ConnectApp[];\n\n  /**\n   * InstanceId represents a stable identifier to be used for identifying connected SDKs.\n   * This can be a hostname or other identifier that remains stable across restarts.\n   *\n   * If nil, this defaults to the current machine's hostname.\n   */\n  instanceId?: string;\n\n  /**\n   * MaxWorkerConcurrency represents the maximum number of worker concurrency to use.\n   *\n   * If left undefined, there will be no limit on the number of concurrent requests on the worker.\n   */\n  maxWorkerConcurrency?: number;\n\n  /**\n   * By default, connections will be gracefully shut down when the current\n   * process receives a SIGINT or SIGTERM signal. Set this to an empty array to disable this behavior.\n   */\n  handleShutdownSignals?: string[];\n\n  /**\n   * Override the gateway WebSocket endpoint. When set, this URL is used\n   * instead of the endpoint returned by the Inngest API.\n   *\n   * Useful when there is a proxy between the worker and the gateway\n   * that requires a different hostname (e.g. `ws://localhost:8100`).\n   *\n   * Can also be set via the `INNGEST_CONNECT_GATEWAY_URL` environment variable.\n   * This option takes precedence over the env var.\n   */\n  gatewayUrl?: string;\n\n  /**\n   * Enable running the WebSocket connection, heartbeater, and lease extender\n   * in a separate worker thread. This prevents thread-blocking user code from\n   * interfering with connection health.\n   *\n   * Only works in environments that support worker_threads.\n   *\n   * Can also be disabled via the INNGEST_CONNECT_ISOLATE_EXECUTION=false environment variable.\n   *\n   * @default true\n   */\n  isolateExecution?: boolean;\n}\n\nexport interface WorkerConnection {\n  connectionId: string;\n  closed: Promise<void>;\n  close: () => Promise<void>;\n  state: ConnectionState;\n  getDebugState: () => ConnectDebugState;\n}\n\nexport interface InFlightRequest {\n  requestId: string;\n  runId: string;\n  stepId: string | undefined;\n  appId: string;\n  envId: string;\n  functionSlug: string;\n  accountId: string;\n  /**\n   * Timestamp (ms since epoch) when the worker acknowledged the request and\n   * took the lease. Used to compute age for shutdown diagnostics.\n   *\n   * Optional so external callers constructing an `InFlightRequest` (e.g.\n   * from {@link ConnectDebugState}) aren't forced to provide it.\n   */\n  leaseAcquiredAt?: number;\n  /**\n   * Timestamp (ms since epoch) of the most recent successful lease-extend send\n   * for this request. Starts equal to `leaseAcquiredAt` and is updated each\n   * time the worker sends a WORKER_REQUEST_EXTEND_LEASE message. Useful\n   * during shutdown diagnostics to tell whether a stuck request is still\n   * being actively leased or has gone silent.\n   *\n   * Optional for the same reason as {@link leaseAcquiredAt}.\n   */\n  leaseLastExtendedAt?: number;\n}\n\nexport interface ConnectDebugState {\n  /** Current connection state */\n  state: ConnectionState;\n  /** Active connection ID, if any */\n  activeConnectionId: string | undefined;\n  /** Draining connection ID (during gateway drain), if any */\n  drainingConnectionId: string | undefined;\n  /** Timestamp of last heartbeat we sent */\n  lastHeartbeatSentAt: number | undefined;\n  /** Timestamp of last heartbeat response from gateway */\n  lastHeartbeatReceivedAt: number | undefined;\n  /** Timestamp of last WS message received (any type) */\n  lastMessageReceivedAt: number | undefined;\n  /** Whether shutdown has been requested (WORKER_PAUSE sent) */\n  shutdownRequested: boolean;\n  /** Number of in-flight requests */\n  inFlightRequestCount: number;\n  /** Detailed info about in-flight requests */\n  inFlightRequests: InFlightRequest[];\n}\n\nexport enum ConnectionState {\n  CONNECTING = \"CONNECTING\",\n  ACTIVE = \"ACTIVE\",\n  PAUSED = \"PAUSED\",\n  RECONNECTING = \"RECONNECTING\",\n  CLOSING = \"CLOSING\",\n  CLOSED = \"CLOSED\",\n}\n"],"mappings":";;AAIA,MAAa,2BAA2B,CAAC,UAAU,UAAU;AAkH7D,IAAY,8DAAL;AACL;AACA;AACA;AACA;AACA;AACA"}