From 1dfaa460b4580d8dbaf9dae9e09374c3caae066b Mon Sep 17 00:00:00 2001 From: Rohit Rajan Date: Sun, 13 Sep 2026 22:58:16 +0530 Subject: [PATCH] feat: add support for monitoring --- src/builders/workflow-builder.ts | 6 ++++++ src/client/maxun-client.ts | 2 ++ src/extract.ts | 1 + src/scrape.ts | 2 ++ src/types/index.ts | 4 ++++ 5 files changed, 15 insertions(+) diff --git a/src/builders/workflow-builder.ts b/src/builders/workflow-builder.ts index ca6d1d8..fc5cc8f 100644 --- a/src/builders/workflow-builder.ts +++ b/src/builders/workflow-builder.ts @@ -189,6 +189,12 @@ export abstract class WorkflowBuilder { return this; } + /** Enable or disable comparison with the previous successful run. */ + monitorChanges(enabled: boolean = true): this { + this.meta.compareRuns = enabled; + return this; + } + /** * Add a new step to the workflow */ diff --git a/src/client/maxun-client.ts b/src/client/maxun-client.ts index 9eabd22..5b02408 100644 --- a/src/client/maxun-client.ts +++ b/src/client/maxun-client.ts @@ -329,6 +329,7 @@ export class Client { llmApiKey?: string; llmBaseUrl?: string; robotName?: string; + compareRuns?: boolean; }): Promise { const response = await this.axios.post>( '/extract/llm', @@ -340,6 +341,7 @@ export class Client { ...(options.llmApiKey ? { llmApiKey: options.llmApiKey } : {}), ...(options.llmBaseUrl ? { llmBaseUrl: options.llmBaseUrl } : {}), robotName: options.robotName, + ...(options.compareRuns !== undefined ? { compareRuns: options.compareRuns } : {}), }, { timeout: 300000, diff --git a/src/extract.ts b/src/extract.ts index 903b7b2..1446e15 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -99,6 +99,7 @@ export class Extract { llmApiKey?: string; llmBaseUrl?: string; robotName?: string; + compareRuns?: boolean; }): Promise { const robotData = await this.client.extractWithLLM(options); const robot = await this.client.getRobot(robotData.robotId); diff --git a/src/scrape.ts b/src/scrape.ts index 667593d..01e4a61 100644 --- a/src/scrape.ts +++ b/src/scrape.ts @@ -27,6 +27,7 @@ export interface ScrapeOptions extends LlmOptions { * Adds 2 extra credits per run on top of the base 1 scrape credit. */ smartQueries?: string; + compareRuns?: boolean; } export class Scrape { @@ -55,6 +56,7 @@ export class Scrape { robotType: 'scrape', url, formats: options?.formats || ['markdown'], + ...(options?.compareRuns !== undefined ? { compareRuns: options.compareRuns } : {}), ...(options?.smartQueries ? { smartQueries: options.smartQueries } : {}), ...buildLlmPayload(options || {}), } as any, diff --git a/src/types/index.ts b/src/types/index.ts index f07ac7b..d079b4c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -29,6 +29,7 @@ export interface RobotMeta extends LlmOptions { formats?: Format[]; subscriptionLevel?: number; smartQueries?: string; + compareRuns?: boolean; } export interface Where { @@ -99,6 +100,7 @@ export interface Run { runId: string; startedAt: string; finishedAt: string | null; + hasChanges?: boolean; serializableOutput?: { scrapeSchema?: Record; scrapeList?: Record[]; @@ -155,6 +157,8 @@ export interface RunResult { screenshots?: Array; status: RunStatus; runId: string; + hasChanges?: boolean; + changedFormats?: string[]; } export interface ExecutionOptions {