55e1c2e74b
Move monitor-task scheduling authority onto the client with a durable file-backed queue that survives restart, drops stale cross-day tasks, enforces per-platform serialism, and adapts global concurrency from Electron process metrics. Publish tasks keep their existing FIFO. Add a hidden Playwright CDP manager that attaches to Electron Chromium on account session partitions, lets adapters opt into `executionMode: "playwright"`, and leaves the existing hidden WebContentsView path in place for current adapters. Introduce an account-health subsystem with silent probes, projected health/auth states, and IPC invalidation events so the renderer can show accurate auth/probe status and verification timestamps. Server-side, derive and forward title/business_date/scheduler_group_key/ question_text metadata on desktop task events so the local scheduler can defer same-question fan-out before leasing.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import type { DesktopArticleContent, JsonValue } from "@geo/shared-types";
|
|
import type { Session, WebContentsView } from "electron";
|
|
import type { Browser as PlaywrightBrowser, Page as PlaywrightPage } from "playwright-core";
|
|
|
|
export type AdapterTaskPhase = "initial" | "resume";
|
|
export type AdapterCompletionStatus = "succeeded" | "failed" | "unknown";
|
|
export type AdapterExecutionMode = "session" | "view" | "playwright";
|
|
|
|
export interface AdapterContext {
|
|
taskId: string;
|
|
accountId: string;
|
|
session: Session;
|
|
view: WebContentsView | null;
|
|
playwright: {
|
|
browser: PlaywrightBrowser;
|
|
page: PlaywrightPage;
|
|
} | null;
|
|
signal: AbortSignal;
|
|
phase: AdapterTaskPhase;
|
|
reportProgress(stage: string): void;
|
|
}
|
|
|
|
export interface PublishAdapterContext extends AdapterContext {
|
|
article: DesktopArticleContent;
|
|
}
|
|
|
|
export interface AdapterExecutionResult {
|
|
status: AdapterCompletionStatus;
|
|
summary: string;
|
|
payload?: Record<string, JsonValue>;
|
|
error?: Record<string, JsonValue>;
|
|
}
|
|
|
|
export interface PublishAdapter {
|
|
platform: string;
|
|
executionMode?: AdapterExecutionMode;
|
|
publish(context: PublishAdapterContext, payload: Record<string, unknown>): Promise<AdapterExecutionResult>;
|
|
}
|
|
|
|
export interface MonitorAdapter {
|
|
provider: string;
|
|
executionMode?: AdapterExecutionMode;
|
|
query(context: AdapterContext, payload: Record<string, unknown>): Promise<AdapterExecutionResult>;
|
|
}
|