/** * Artifact openers + optional HTTP bridge to a host (e.g. a VS Code extension). * * DESIGN — the filesystem artifact protocol is the source of truth. * The plan/tasks/walkthrough/status files are ALWAYS written to disk on every * phase transition (see index.ts writeStatus + tools.ts). Any host that can * read files and watch a directory can integrate — no HTTP, no tokens, no * in-process embedding required. See BRIDGE.md for the public contract. * * The HTTP bridge here (openFile / setPlanStatus) is a COSMETIC, OPTIONAL * enhancement. It is auto-detected from environment variables and is strictly * best-effort: if no bridge is configured, or the configured bridge is * unreachable, or the `code` CLI binary is missing, openArtifactInVSCode * resolves to "skipped" and NEVER throws or rejects. The files are on disk * regardless, so the workflow never blocks. * * Two env-var conventions are recognized (generic preferred over legacy): * - Generic: PI_CO_BRIDGE_URL / PI_CO_BRIDGE_TOKEN / PI_CO_BRIDGE_AUTH_HEADER * (auth header defaults to "x-pi-bridge-authorization") * - Legacy: PI_VSCODE_BRIDGE_URL / PI_VSCODE_BRIDGE_TOKEN * (auth header "x-pi-vscode-authorization") — kept for backward * compatibility with the original pithings/pi-vscode bridge. */ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; export interface BridgeConfig { url: string; token: string; authHeader: string; } /** Env-var keys this module reads — exported so tests can save/restore them. */ export declare const BRIDGE_ENV_KEYS: readonly ["PI_CO_BRIDGE_URL", "PI_CO_BRIDGE_TOKEN", "PI_CO_BRIDGE_AUTH_HEADER", "PI_VSCODE_BRIDGE_URL", "PI_VSCODE_BRIDGE_TOKEN"]; /** * Lazily resolve the HTTP bridge config from the environment at call time. * Generic env vars are preferred over the legacy pi-vscode ones when both are * present. Returns null when no bridge URL+token pair is configured. * * Reading at call time (not module load) keeps this testable and lets a host * register a bridge after startup. */ export declare function getBridgeConfig(): BridgeConfig | null; /** Result of an open attempt — returned so callers/tests can observe the outcome. */ export type OpenResult = "opened" | "skipped"; /** * Open a file in the host editor, preferring the configured HTTP bridge when * present, otherwise spawning the `code` CLI. ALWAYS best-effort: never throws * and never rejects. Returns "opened" on success, "skipped" if no path worked * (the file is still on disk for manual opening). */ export declare function openArtifactInVSCode(pi: ExtensionAPI, absPath: string, preview?: boolean): Promise; /** Notify a host of plan status over the HTTP bridge (best-effort, never rejects). */ export declare function pushPlanStatusToVSCode(status: Record): Promise; /** Atomic-ish read-modify-write helper for an artifact file. */ export declare function writeArtifact(absPath: string, content: string): Promise; export declare function readArtifact(absPath: string): Promise; export declare function joinArtifact(dir: string, name: string): string; export declare function absOrCwd(cwd: string, p: string): string; //# sourceMappingURL=open.d.ts.map