/** * Subgraph Client — CLI host wrapper over @poa-box/core. * * The tiered transport (free Studio / paid gateway routing, quota pins, field * fallback) lives in @poa-box/core/graph/client and is browser-pure. This module * is the CLI's binding of it to the Node environment: * * env process.env (live reference, so per-call env reads behave * exactly like the pre-extraction module) * stateStore ~/.pop/subgraph-tier-state.json — see getStatePath() for the * POP_SUBGRAPH_STATE_FILE / POP_AGENT_HOME overrides and why a * human install must never grow a ~/.pop-agent directory * onWarn process.stderr (visible to a human without corrupting --json) * * Every export keeps its pre-extraction signature, so the ~66 command files * and @poa-box/agent's deep imports (`@poa-box/cli/lib/subgraph`) are unaffected. */ import { GraphClient, FREE_BACKOFF_SECONDS, redactSubgraphUrl, isQuotaError, isAuthError } from '@poa-box/core/graph/client'; import type { SubgraphTierName, SubgraphTierMode, TransportAvailability, TransportAttempt, TransportPlan, TransportStatus, FieldFallbackTier, ChainQueryResult } from '@poa-box/core/graph/client'; export { FREE_BACKOFF_SECONDS, redactSubgraphUrl, isQuotaError, isAuthError }; export type { SubgraphTierName, SubgraphTierMode, TransportAvailability, TransportAttempt, TransportPlan, TransportStatus, FieldFallbackTier, ChainQueryResult, }; /** The GraphClient this process uses — for handing to @poa-box/core helpers. */ export declare function getGraphClient(): GraphClient; /** Test/diagnostic hook: drop memoised transport state and the state-file memo. */ export declare function resetSubgraphTransportCache(): void; /** unix-seconds until which the free transport is considered spent, or undefined. */ export declare function getFreeExhaustedUntil(chainId: number): number | undefined; /** * Work out which transports exist for a chain and in what order to try them. * Pure w.r.t. the network: reads env + config + the persisted state file only. */ export declare function resolveTransportPlan(chainId?: number): TransportPlan; /** * Query a subgraph on the specified chain, routed through the tier plan * (see @poa-box/core/graph/client). */ export declare function query(gqlQuery: string, variables?: Record, chainId?: number): Promise; /** * Try query tiers in order, falling through to the next tier when the * deployed schema rejects a field (validation error). Any other error * (network, HTTP, rate limit without fallback) is rethrown immediately. * Returns the first successful result plus the tier index that served it. */ export declare function queryWithFieldFallback(tiers: Array, opts?: { chainId?: number; }): Promise<{ data: T; tierIndex: number; }>; /** * Query a specific subgraph URL directly, still tier-aware: if `url` is a free * (Studio) endpoint belonging to a known chain and it rate-limits, the request * is retried against that chain's gateway rather than simply failing. */ export declare function queryUrl(url: string, gqlQuery: string, variables?: Record): Promise; /** * Query all non-testnet subgraphs in parallel, each through its own tier plan. * Returns results keyed by chainId. Failures are reported per-chain rather * than swallowed: see ChainQueryResult.error. */ export declare function queryAllChains(gqlQuery: string, variables?: Record): Promise>>; /** * Describe the transport that will serve the next query on `chainId`. * Purely local — issues no network request. URLs are redacted. */ export declare function getTransportStatus(chainId?: number): TransportStatus;