2026-04-19 14:18:20 +08:00
|
|
|
import type { DesktopArticleContent, JsonValue } from "@geo/shared-types";
|
|
|
|
|
import type { Session, WebContentsView } from "electron";
|
2026-04-20 17:16:15 +08:00
|
|
|
import type { Browser as PlaywrightBrowser, Page as PlaywrightPage } from "playwright-core";
|
2026-04-19 14:18:20 +08:00
|
|
|
|
|
|
|
|
export type AdapterTaskPhase = "initial" | "resume";
|
|
|
|
|
export type AdapterCompletionStatus = "succeeded" | "failed" | "unknown";
|
2026-04-20 09:52:48 +08:00
|
|
|
export type AdapterExecutionMode = "session" | "view" | "playwright";
|
2026-04-19 14:18:20 +08:00
|
|
|
|
|
|
|
|
export interface AdapterContext {
|
|
|
|
|
taskId: string;
|
|
|
|
|
accountId: string;
|
|
|
|
|
session: Session;
|
2026-04-20 09:52:48 +08:00
|
|
|
view: WebContentsView | null;
|
2026-04-20 17:16:15 +08:00
|
|
|
playwright: {
|
|
|
|
|
browser: PlaywrightBrowser;
|
|
|
|
|
page: PlaywrightPage;
|
|
|
|
|
} | null;
|
2026-04-19 14:18:20 +08:00
|
|
|
signal: AbortSignal;
|
|
|
|
|
phase: AdapterTaskPhase;
|
|
|
|
|
reportProgress(stage: string): void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PublishAdapterContext extends AdapterContext {
|
2026-04-20 09:52:48 +08:00
|
|
|
article: DesktopArticleContent;
|
2026-04-19 14:18:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AdapterExecutionResult {
|
|
|
|
|
status: AdapterCompletionStatus;
|
|
|
|
|
summary: string;
|
|
|
|
|
payload?: Record<string, JsonValue>;
|
|
|
|
|
error?: Record<string, JsonValue>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PublishAdapter {
|
|
|
|
|
platform: string;
|
2026-04-20 09:52:48 +08:00
|
|
|
executionMode?: AdapterExecutionMode;
|
2026-04-19 14:18:20 +08:00
|
|
|
publish(context: PublishAdapterContext, payload: Record<string, unknown>): Promise<AdapterExecutionResult>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface MonitorAdapter {
|
|
|
|
|
provider: string;
|
2026-04-20 09:52:48 +08:00
|
|
|
executionMode?: AdapterExecutionMode;
|
2026-04-19 14:18:20 +08:00
|
|
|
query(context: AdapterContext, payload: Record<string, unknown>): Promise<AdapterExecutionResult>;
|
|
|
|
|
}
|