import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; import { HumanDecisionStore } from "../workflows/human-decision.js"; import type { ResolvedHumanDecision, HumanDecisionAnswerSource, HumanDecisionCancellationRecord, HumanDecisionChannelRequest, HumanDecisionResponse } from "../workflows/types.js"; export type HumanDecisionChannelAnswer = { request: HumanDecisionChannelRequest; response: HumanDecisionResponse; source: HumanDecisionAnswerSource; idempotencyKey: string; }; export type HumanDecisionDeliveryResult = { status: "confirmed" | "failed" | "unknown"; channel: string; attemptId: string; errorCode?: string; }; export type SettledHumanDecision = ResolvedHumanDecision | HumanDecisionCancellationRecord; export interface HumanDecisionChannel { readonly id: string; start(): Promise; deliver(request: HumanDecisionChannelRequest): Promise; settle(decision: SettledHumanDecision): Promise; stop(): Promise; } export type DecisionChannelConfig = { schema: "pi-workflows.channels.v1"; audiences: Record; telegramProfiles?: Record; }; export type DecisionCredentialConfig = { schema: "pi-workflows.credentials.v1"; telegram: Record; }; type ResolvedDecisionCredentials = Record; export type LoadedDecisionChannelConfig = { channels: DecisionChannelConfig; credentials: ResolvedDecisionCredentials; configDir: string; }; export type TelegramFetch = (input: string, init?: RequestInit) => Promise<{ ok: boolean; status: number; json(): Promise; }>; export type PiDecisionUi = Pick; export declare function decisionConfigDir(env?: NodeJS.ProcessEnv): string; export declare function loadDecisionChannelConfig(configDir?: string): Promise; export declare function audienceChannels(config: DecisionChannelConfig | null, audience: string): string[]; export declare class PiDecisionChannel implements HumanDecisionChannel { private readonly options; readonly id = "pi"; private promptAbort; private settlementTask; constructor(options: { actorId: string; ui: PiDecisionUi; store: HumanDecisionStore; onAnswer: (answer: HumanDecisionChannelAnswer) => Promise; }); start(): Promise; stop(): Promise; deliver(request: HumanDecisionChannelRequest): Promise; private alreadyDecided; settle(decision: SettledHumanDecision): Promise; private settleOnce; } export declare class TelegramDecisionChannel implements HumanDecisionChannel { readonly id: string; private readonly profile; private readonly store; private readonly fetchFn; private readonly apiBase; private readonly onAnswer; private readonly projection; private running; private pollAbort; private pollTask; private readonly settlementTasks; constructor(options: { profileName: string; token: string; allowedUserIds: string[]; allowedChatIds: string[]; store: HumanDecisionStore; configDir?: string; onAnswer: (answer: HumanDecisionChannelAnswer) => Promise; fetchFn?: TelegramFetch; apiBase?: string; ownerId?: string; }); start(): Promise; stop(): Promise; deliver(request: HumanDecisionChannelRequest): Promise; settle(decision: SettledHumanDecision): Promise; private settleOnce; handleUpdate(value: unknown): Promise; private registerCallbacks; private channelPath; private allowed; private isStale; private poll; private deliverPendingRequests; private call; } export declare function createTelegramChannels(options: { config: DecisionChannelConfig; credentials: ResolvedDecisionCredentials; store: HumanDecisionStore; configDir?: string; onAnswer: (answer: HumanDecisionChannelAnswer) => Promise; fetchFn?: TelegramFetch; apiBase?: string; }): Map; export declare function verifyTelegramTokenFile(tokenFile: string, fetchFn?: TelegramFetch, apiBase?: string): Promise; export declare function writeDecisionChannelProfile(options: { configDir?: string; audience: string; profile: string; credential: string; tokenFile: string; allowedUserIds: string[]; allowedChatIds: string[]; }): Promise; export declare function renderDecisionText(request: HumanDecisionChannelRequest): string; export declare function renderTelegramParts(request: HumanDecisionChannelRequest, textLimit?: number): string[]; export {};