import { type ChainAdapter, type OnChainPublishResult, type RpcUsageWindow } from '@origintrail-official/dkg-chain'; import { type Ed25519Keypair } from '@origintrail-official/dkg-core'; import { AsyncLiftRunner, DKGPublisher, type ACKTransportFactory, type AsyncKnowledgeAssetVmPublishRecoveryEvidence, type AsyncKnowledgeAssetVmPublishRecoveryResolver, type AsyncLiftPublisher, type AsyncLiftPublisherConfig, type AsyncLiftPublisherRecoveryResult, type VmPublishIntentRecoveryPublisher, type VmPublishIntentIndexBackfiller, type VmPublishAdmissionJournalReader, type LiftJobBroadcast, type LiftJobIncluded, type PublishOptions, type WorkspacePublicSnapshotStore } from '@origintrail-official/dkg-publisher'; import { type TripleStore } from '@origintrail-official/dkg-storage'; import { type DkgConfig } from './config.js'; import { type RuntimeEvmChainConfig } from './runtime-chain-config.js'; export type { ACKTransportFactory } from '@origintrail-official/dkg-publisher'; /** Single construction boundary for every async-publisher wallet adapter. */ export declare function createPublisherWalletChain(chainBase: RuntimeEvmChainConfig | undefined, privateKey: string): ChainAdapter; export interface PublisherRuntime { readonly runner: AsyncLiftRunner; readonly publisher: AsyncLiftPublisher; readonly walletIds: string[]; readonly wallets: readonly PublisherRuntimeWallet[]; readonly stop: () => Promise; /** RpcUsageDrainable: merged window across every per-wallet chain adapter. */ readonly drainRpcUsage: () => RpcUsageWindow; } export interface PublisherRuntimeWallet { readonly address: string; readonly identityId: bigint; } export type AsyncPublisherUnavailableReason = 'publisher_disabled' | 'publisher_starting' | 'no_publisher_wallets' | 'publisher_startup_failed'; type PublisherDisabledAvailability = { available: false; reason: 'publisher_disabled'; retryable: false; operatorActionRequired: true; }; type PublisherStartingAvailability = { available: false; reason: 'publisher_starting'; retryable: true; operatorActionRequired: false; }; type NoPublisherWalletsAvailability = { available: false; reason: 'no_publisher_wallets'; retryable: false; operatorActionRequired: true; }; type PublisherStartupFailedAvailability = { available: false; reason: 'publisher_startup_failed'; retryable: false; operatorActionRequired: true; }; type AsyncPublisherUnavailableAvailability = PublisherDisabledAvailability | PublisherStartingAvailability | NoPublisherWalletsAvailability | PublisherStartupFailedAvailability; export type AsyncPublisherAvailability = { available: true; } | AsyncPublisherUnavailableAvailability; /** * Canonical readiness boundary for every async-ingress route. Lifecycle may * supply an explicit starting/failure state; otherwise the runtime/config * shape is classified consistently for direct route tests and embedded users. */ export declare function resolveAsyncPublisherAvailability(args: { config: DkgConfig; runtime: PublisherRuntime | null; lifecycleReason?: AsyncPublisherUnavailableReason; }): AsyncPublisherAvailability; export interface PublisherInspector { readonly publisher: AsyncLiftPublisher; readonly stop: () => Promise; } type PublishEncryptionFactory = (publishOptions: PublishOptions) => Promise | undefined> | Pick | undefined; export declare function startPublisherRuntimeIfEnabled(args: { dataDir: string; config: DkgConfig; store: TripleStore; keypair: Ed25519Keypair; chainBase?: RuntimeEvmChainConfig; log: (message: string) => void; ackTransportFactory?: ACKTransportFactory; publishEncryptionFactory?: PublishEncryptionFactory; knowledgeAssetVmPublishHandler?: AsyncLiftPublisherConfig['knowledgeAssetVmPublishHandler']; }): Promise; export type PublisherStartupOutcome = { runtime: PublisherRuntime; availability: Extract; } | { runtime: null; availability: PublisherDisabledAvailability; } | { runtime: null; availability: NoPublisherWalletsAvailability; } | { runtime: null; availability: PublisherStartupFailedAvailability; error: unknown; }; export type PublisherState = PublisherStartupOutcome | { runtime: null; availability: PublisherStartingAvailability; }; /** * Initial daemon state before the deferred publisher bootstrap settles. Routes * receive this whole discriminated value, so runtime and readiness cannot * disagree in a request context. */ export declare function createInitialPublisherState(config: DkgConfig): PublisherState; /** * Explicit daemon-startup boundary. The compatibility helper above retains its * historical nullable return, while lifecycle code consumes this discriminant * and never has to guess which unavailable state a null runtime represents. */ export declare function startPublisherRuntimeWithOutcome(args: Parameters[0]): Promise; export declare function createPublisherRuntime(args: { dataDir: string; config: DkgConfig; pollIntervalMs?: number; errorBackoffMs?: number; maxRetries?: number; }): Promise; export declare function createPublisherInspector(args: { dataDir: string; config: DkgConfig; }): Promise; export declare function createPublisherInspectorFromStore(store: TripleStore, closeStoreOnStop?: boolean, publicSnapshotStore?: WorkspacePublicSnapshotStore): PublisherInspector; export declare function createPublisherControlFromStore(store: TripleStore, options?: { publicSnapshotStore?: WorkspacePublicSnapshotStore; maxRetries?: number; }): VmPublishIntentRecoveryPublisher & VmPublishIntentIndexBackfiller & VmPublishAdmissionJournalReader; export declare function createPublisherRuntimeFromAgent(args: { dataDir: string; store: TripleStore; keypair: Ed25519Keypair; chainBase?: RuntimeEvmChainConfig; pollIntervalMs?: number; errorBackoffMs?: number; maxRetries?: number; config?: Pick; ackTransportFactory?: ACKTransportFactory; v10ACKProviderFactory?: () => PublishOptions['v10ACKProvider']; publishEncryptionFactory?: PublishEncryptionFactory; knowledgeAssetVmPublishHandler?: AsyncLiftPublisherConfig['knowledgeAssetVmPublishHandler']; }): Promise; /** * Bind every named-KA queue lifecycle callback to the wallet that owns the * claimed job. Keeping this as one handler prevents execution, preflight, and * recovery from accidentally selecting different publisher instances. */ export declare function scopeKnowledgeAssetVmPublishHandler(publishers: Map, handler: AsyncLiftPublisherConfig['knowledgeAssetVmPublishHandler']): AsyncLiftPublisherConfig['knowledgeAssetVmPublishHandler']; export declare function createChainRecoveryResolver(publishers: Map): (job: LiftJobBroadcast | LiftJobIncluded) => Promise; export declare function createKnowledgeAssetVmPublishRecoveryResolver(publishers: Map): AsyncKnowledgeAssetVmPublishRecoveryResolver; export declare function mapOnChainPublishResultToLiftRecovery(result: OnChainPublishResult, chainId: string, knowledgeAssetsContract: string): AsyncLiftPublisherRecoveryResult | null; export declare function mapOnChainPublishResultToKnowledgeAssetVmRecovery(result: OnChainPublishResult, chainId: string, knowledgeAssetsContract: string): AsyncKnowledgeAssetVmPublishRecoveryEvidence | null; export declare function createPublicSnapshotStore(dataDir: string, config?: Pick): WorkspacePublicSnapshotStore | undefined; //# sourceMappingURL=publisher-runner.d.ts.map