AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(scrapegraphai): add AI actions and output schemas (#16360)
Kishan Parmar5bac34566171
diff --git a/packages/pieces/community/scrapegrapghai/package.json b/packages/pieces/community/scrapegrapghai/package.jsonindex be02cf793d1..077b48154a3 100644--- a/packages/pieces/community/scrapegrapghai/package.json+++ b/packages/pieces/community/scrapegrapghai/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-scrapegrapghai",- "version": "0.2.1",+ "version": "0.3.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {diff --git a/packages/pieces/community/scrapegrapghai/src/index.ts b/packages/pieces/community/scrapegrapghai/src/index.tsindex 36fde8da3ef..67969cc812f 100644--- a/packages/pieces/community/scrapegrapghai/src/index.ts+++ b/packages/pieces/community/scrapegrapghai/src/index.ts@@ -1,33 +1,27 @@-import { createCustomApiCallAction, httpClient, HttpMethod } from '@activepieces/pieces-common';-import { createPiece, PieceAuth } from '@activepieces/pieces-framework';-import { PieceCategory } from '@activepieces/pieces-framework';-import { smartScraper } from './lib/actions/smart-scraper';-import { localScraper } from './lib/actions/local-scraper';-import { markdownify } from './lib/actions/markdownify';+import { createCustomApiCallAction } from '@activepieces/pieces-common';+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';import { scrapegraphaiAuth } from './lib/auth';--const markdownDescription = `-Follow these steps to obtain your ScrapeGraphAI API Key:--1. Visit [ScrapeGraphAI](https://scrapegraphai.com) and create an account.-2. Log in and navigate to your dashboard.-3. Locate and copy your API key from the dashboard.-`;+import { scrapegraphaiClient } from './lib/common/client';+import { smartScraperAction } from './lib/actions/smart-scraper';+import { localScraperAction } from './lib/actions/local-scraper';+import { markdownifyAction } from './lib/actions/convert-to-markdown';+import { scrapegraphaiAiActions } from './lib/actions/ai';export const scrapegraphai = createPiece({displayName: 'ScrapeGraphAI',description: 'AI-powered web scraping and content extraction.',- minimumSupportedRelease: '0.30.0',+ minimumSupportedRelease: '0.88.2',logoUrl: 'https://cdn.activepieces.com/pieces/scrapegraphai.jpg',categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],authors: ["OsamaHaikal"],auth: scrapegraphaiAuth,actions: [- smartScraper,- localScraper,- markdownify,+ smartScraperAction,+ localScraperAction,+ markdownifyAction,+ ...scrapegraphaiAiActions,createCustomApiCallAction({- baseUrl: () => 'https://api.scrapegraphai.com/v1',+ baseUrl: () => scrapegraphaiClient.baseUrl(),auth: scrapegraphaiAuth,authMapping: async (auth) => ({'SGAI-APIKEY': `${auth.secret_text}`,@@ -36,4 +30,3 @@ export const scrapegraphai = createPiece({],triggers: [],});-\ No newline at end of filediff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/create-monitor.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/create-monitor.tsnew file mode 100644index 00000000000..a5980cbac8e--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/create-monitor.ts@@ -0,0 +1,52 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegraphaiUtils } from '../../common/utils';+import { scrapegrapghaiMonitorOutputSchema } from '../../output-schemas';++export const createMonitorAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_create_monitor',+ outputSchema: scrapegrapghaiMonitorOutputSchema,+ displayName: 'Create Monitor',+ description: 'Schedules a recurring fetch of a page with change detection.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Creates a monitor that fetches a URL on a cron schedule, captures it in the chosen formats and records what changed between runs, optionally posting each run to a webhook. Returns the monitor with its `cronId`. Uses one of the plan's monitor slots.",+ idempotent: false,+ },+ props: {+ url: scrapegraphaiAiProps.url({+ required: true,+ description: 'Public page URL to watch, including the scheme.',+ }),+ interval: scrapegraphaiAiProps.interval({ required: true }),+ name: scrapegraphaiAiProps.monitorName({ required: false }),+ formats: scrapegraphaiAiProps.formats({ required: false }),+ mode: scrapegraphaiAiProps.formatMode({ required: false }),+ jsonPrompt: scrapegraphaiAiProps.jsonPrompt({ required: false }),+ jsonSchema: scrapegraphaiAiProps.jsonSchema({ required: false }),+ webhookUrl: scrapegraphaiAiProps.webhookUrl({ required: false }),+ fetchConfig: scrapegraphaiAiProps.fetchConfig({ required: false }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.createMonitor({+ auth,+ url: propsValue.url,+ interval: propsValue.interval,+ name: propsValue.name,+ formats: scrapegraphaiUtils.buildFormats({+ types: propsValue.formats,+ mode: propsValue.mode,+ jsonPrompt: propsValue.jsonPrompt,+ jsonSchema: propsValue.jsonSchema,+ }),+ webhookUrl: propsValue.webhookUrl,+ fetchConfig: propsValue.fetchConfig,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/delete-crawl.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/delete-crawl.tsnew file mode 100644index 00000000000..34f715a748f--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/delete-crawl.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiOkOutputSchema } from '../../output-schemas';++export const deleteCrawlAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_delete_crawl',+ outputSchema: scrapegrapghaiOkOutputSchema,+ displayName: 'Delete Crawl',+ description: 'Permanently deletes a crawl job and its stored pages.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Permanently deletes a crawl job\'s stored pages; this cannot be undone. Get Crawl then returns the job with status "deleted" and no pages. Use Stop Crawl instead to only halt it.',+ idempotent: false,+ },+ props: {+ crawlId: scrapegraphaiAiProps.crawlId({ required: true }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.deleteCrawl({ auth, crawlId: propsValue.crawlId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/delete-monitor.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/delete-monitor.tsnew file mode 100644index 00000000000..32d29242996--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/delete-monitor.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiOkOutputSchema } from '../../output-schemas';++export const deleteMonitorAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_delete_monitor',+ outputSchema: scrapegrapghaiOkOutputSchema,+ displayName: 'Delete Monitor',+ description: 'Permanently deletes a monitor and its run history.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Permanently deletes a monitor and all its run history; this cannot be undone. Use Pause Monitor to only stop it.',+ idempotent: false,+ },+ props: {+ monitorId: scrapegraphaiAiProps.monitorId({ required: true }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.deleteMonitor({ auth, monitorId: propsValue.monitorId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/extract-data.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/extract-data.tsnew file mode 100644index 00000000000..33ac30594f9--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/extract-data.ts@@ -0,0 +1,71 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiExtractOutputSchema } from '../../output-schemas';++export const extractDataAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_extract_data',+ outputSchema: scrapegrapghaiExtractOutputSchema,+ displayName: 'Extract Data',+ description:+ 'Extracts structured data from a URL, HTML or markdown using a natural-language prompt.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Uses AI to extract the data described in a prompt from exactly one source: a public URL (fetched server-side), raw HTML or markdown you already have (max 2 MB). Pass a JSON Schema to force the output shape. Returns the result under `json`; use Scrape Page instead for whole-page content.',+ idempotent: true,+ },+ props: {+ url: scrapegraphaiAiProps.url({+ required: false,+ description:+ 'Public page URL to fetch and extract from. Provide exactly one of URL, HTML or Markdown.',+ }),+ html: Property.LongText({+ displayName: 'HTML',+ description:+ 'Raw HTML to extract from (max 2 MB). Provide exactly one of URL, HTML or Markdown.',+ required: false,+ }),+ markdown: Property.LongText({+ displayName: 'Markdown',+ description:+ 'Markdown text to extract from (max 2 MB). Provide exactly one of URL, HTML or Markdown.',+ required: false,+ }),+ prompt: Property.LongText({+ displayName: 'Prompt',+ description:+ 'Natural-language description of what to extract, e.g. "the product name and price".',+ required: true,+ }),+ schema: scrapegraphaiAiProps.jsonSchema({+ required: false,+ displayName: 'Schema',+ description: 'Optional JSON Schema object the output must match.',+ }),+ mode: scrapegraphaiAiProps.formatMode({+ required: false,+ displayName: 'HTML Mode',+ description:+ 'Pre-processing of the source: normal, reader (main article only) or prune (strip boilerplate). Defaults to normal.',+ }),+ fetchConfig: scrapegraphaiAiProps.fetchConfig({ required: false }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.extract({+ auth,+ url: propsValue.url,+ html: propsValue.html,+ markdown: propsValue.markdown,+ prompt: propsValue.prompt,+ schema: propsValue.schema,+ mode: propsValue.mode,+ fetchConfig: propsValue.fetchConfig,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-crawl.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-crawl.tsnew file mode 100644index 00000000000..c83a4075ead--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-crawl.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiCrawlOutputSchema } from '../../output-schemas';++export const getCrawlAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_get_crawl',+ outputSchema: scrapegrapghaiCrawlOutputSchema,+ displayName: 'Get Crawl',+ description: 'Gets the status and progress of a crawl job.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Reads a crawl job once: status (running, completed, failed, or paused after Stop Crawl), page counters and lightweight per-page metadata with each page's `scrapeRefId`. Call it repeatedly to poll a job from Start Crawl; it never waits. Page content comes from List Crawl Pages.",+ idempotent: true,+ },+ props: {+ crawlId: scrapegraphaiAiProps.crawlId({ required: true }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.getCrawl({ auth, crawlId: propsValue.crawlId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-credits.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-credits.tsnew file mode 100644index 00000000000..fc4d0ab17ac--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-credits.ts@@ -0,0 +1,24 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiGetCreditsOutputSchema } from '../../output-schemas';++export const getCreditsAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_get_credits',+ outputSchema: scrapegrapghaiGetCreditsOutputSchema,+ displayName: 'Get Credits',+ description: 'Gets the remaining credit balance, plan and job quotas.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Returns remaining and used credits, the plan name, and crawl and monitor job slots used vs the plan limit. Free to call; use it before a large batch. Takes no inputs.',+ idempotent: true,+ },+ props: {},+ async run({ auth }) {+ return await scrapegraphaiApi.getCredits({ auth });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-history-entry.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-history-entry.tsnew file mode 100644index 00000000000..aa008460eb3--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-history-entry.ts@@ -0,0 +1,31 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiGetHistoryEntryOutputSchema } from '../../output-schemas';++export const getHistoryEntryAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_get_history_entry',+ outputSchema: scrapegrapghaiGetHistoryEntryOutputSchema,+ displayName: 'Get History Entry',+ description: 'Gets one past request and its full result by ID.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Returns one past request with its params, status and full result. The ID is the `id` returned by Scrape Page, Extract Data or Search the Web, a page `scrapeRefId` from Get Crawl, or a run `id` from List Monitor Activity.',+ idempotent: true,+ },+ props: {+ requestId: Property.ShortText({+ displayName: 'Request ID',+ description:+ 'UUID of the request: `id` from Scrape Page, Extract Data or Search the Web, `scrapeRefId` from Get Crawl, or a run `id` from List Monitor Activity.',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.getHistoryEntry({ auth, requestId: propsValue.requestId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-monitor.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-monitor.tsnew file mode 100644index 00000000000..1c0744daf69--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/get-monitor.ts@@ -0,0 +1,26 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiMonitorOutputSchema } from '../../output-schemas';++export const getMonitorAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_get_monitor',+ outputSchema: scrapegrapghaiMonitorOutputSchema,+ displayName: 'Get Monitor',+ description: 'Gets one monitor by ID.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description: 'Returns one monitor with its status, schedule, failure count and full config.',+ idempotent: true,+ },+ props: {+ monitorId: scrapegraphaiAiProps.monitorId({ required: true }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.getMonitor({ auth, monitorId: propsValue.monitorId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/index.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/index.tsnew file mode 100644index 00000000000..62ea1f60d00--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/index.ts@@ -0,0 +1,43 @@+import { createMonitorAction } from './create-monitor';+import { deleteCrawlAction } from './delete-crawl';+import { deleteMonitorAction } from './delete-monitor';+import { extractDataAction } from './extract-data';+import { getCrawlAction } from './get-crawl';+import { getCreditsAction } from './get-credits';+import { getHistoryEntryAction } from './get-history-entry';+import { getMonitorAction } from './get-monitor';+import { listCrawlPagesAction } from './list-crawl-pages';+import { listHistoryAction } from './list-history';+import { listMonitorActivityAction } from './list-monitor-activity';+import { listMonitorsAction } from './list-monitors';+import { pauseMonitorAction } from './pause-monitor';+import { resumeCrawlAction } from './resume-crawl';+import { resumeMonitorAction } from './resume-monitor';+import { scrapePageAction } from './scrape-page';+import { searchWebAction } from './search-web';+import { startCrawlAction } from './start-crawl';+import { stopCrawlAction } from './stop-crawl';+import { updateMonitorAction } from './update-monitor';++export const scrapegraphaiAiActions = [+ scrapePageAction,+ extractDataAction,+ searchWebAction,+ startCrawlAction,+ getCrawlAction,+ listCrawlPagesAction,+ stopCrawlAction,+ resumeCrawlAction,+ deleteCrawlAction,+ createMonitorAction,+ listMonitorsAction,+ getMonitorAction,+ updateMonitorAction,+ pauseMonitorAction,+ resumeMonitorAction,+ deleteMonitorAction,+ listMonitorActivityAction,+ listHistoryAction,+ getHistoryEntryAction,+ getCreditsAction,+];diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-crawl-pages.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-crawl-pages.tsnew file mode 100644index 00000000000..bfa82771c45--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-crawl-pages.ts@@ -0,0 +1,43 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiListCrawlPagesOutputSchema } from '../../output-schemas';++export const listCrawlPagesAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_list_crawl_pages',+ outputSchema: scrapegrapghaiListCrawlPagesOutputSchema,+ displayName: 'List Crawl Pages',+ description: 'Lists the pages of a crawl job with their scraped content.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Returns one slice of a crawl job's pages with each page's scraped content resolved under `scrape`. Pass `pagination.nextCursor` from the previous call as Cursor to get the next slice; it is null when there are no more.",+ idempotent: true,+ },+ props: {+ crawlId: scrapegraphaiAiProps.crawlId({ required: true }),+ limit: Property.Number({+ displayName: 'Limit',+ description: 'Pages to return, 1-100. Defaults to 50.',+ required: false,+ }),+ cursor: Property.Number({+ displayName: 'Cursor',+ description:+ 'Zero-based page index to start from, from `pagination.nextCursor`. Defaults to 0.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.listCrawlPages({+ auth,+ crawlId: propsValue.crawlId,+ limit: propsValue.limit,+ cursor: propsValue.cursor,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-history.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-history.tsnew file mode 100644index 00000000000..604eba154cb--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-history.ts@@ -0,0 +1,61 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiListHistoryOutputSchema } from '../../output-schemas';++export const listHistoryAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_list_history',+ outputSchema: scrapegrapghaiListHistoryOutputSchema,+ displayName: 'List History',+ description: 'Lists past API requests, newest first.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists past requests on the account, newest first, with their params, status and full result. Filter by service or by session ID (partial, case-insensitive). Page through with Page; `pagination.total` is the total match count.',+ idempotent: true,+ },+ props: {+ service: Property.StaticDropdown({+ displayName: 'Service',+ description: 'Only return requests from this service. Defaults to all.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Scrape', value: 'scrape' },+ { label: 'Extract', value: 'extract' },+ { label: 'Search', value: 'search' },+ { label: 'Monitor', value: 'monitor' },+ { label: 'Crawl', value: 'crawl' },+ ],+ },+ }),+ sessionId: Property.ShortText({+ displayName: 'Session ID',+ description: 'Only return requests whose session ID contains this text (case-insensitive).',+ required: false,+ }),+ page: Property.Number({+ displayName: 'Page',+ description: 'Page number, starting at 1. Defaults to 1.',+ required: false,+ }),+ limit: Property.Number({+ displayName: 'Limit',+ description: 'Entries per page. Defaults to 20.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.listHistory({+ auth,+ service: propsValue.service,+ sessionId: propsValue.sessionId,+ page: propsValue.page,+ limit: propsValue.limit,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-monitor-activity.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-monitor-activity.tsnew file mode 100644index 00000000000..f997b840ec2--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-monitor-activity.ts@@ -0,0 +1,42 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiListMonitorActivityOutputSchema } from '../../output-schemas';++export const listMonitorActivityAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_list_monitor_activity',+ outputSchema: scrapegrapghaiListMonitorActivityOutputSchema,+ displayName: 'List Monitor Activity',+ description: "Lists a monitor's recent runs with change flags.",+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Returns a monitor's recent runs, newest first, each with status, duration, whether the page changed and per-format diffs. Each run `id` can be passed to Get History Entry for the captured content. Pass `nextCursor` as Cursor for older runs.",+ idempotent: true,+ },+ props: {+ monitorId: scrapegraphaiAiProps.monitorId({ required: true }),+ limit: Property.Number({+ displayName: 'Limit',+ description: 'Runs to return, 1-100. Defaults to 20.',+ required: false,+ }),+ cursor: Property.ShortText({+ displayName: 'Cursor',+ description: 'The `nextCursor` timestamp from the previous call, to fetch older runs.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.listMonitorActivity({+ auth,+ monitorId: propsValue.monitorId,+ limit: propsValue.limit,+ cursor: propsValue.cursor,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-monitors.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-monitors.tsnew file mode 100644index 00000000000..2f72c0792ce--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/list-monitors.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiListMonitorsOutputSchema } from '../../output-schemas';++export const listMonitorsAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_list_monitors',+ outputSchema: scrapegrapghaiListMonitorsOutputSchema,+ displayName: 'List Monitors',+ description: 'Lists all monitors on the account.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns every monitor on the account with its `cronId`, status (active or paused), schedule and config. Takes no filters or paging.',+ idempotent: true,+ },+ props: {},+ async run({ auth }) {+ const monitors = await scrapegraphaiApi.listMonitors({ auth });+ return { monitors, count: monitors.length };+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/pause-monitor.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/pause-monitor.tsnew file mode 100644index 00000000000..929d2d88516--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/pause-monitor.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiMonitorOutputSchema } from '../../output-schemas';++export const pauseMonitorAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_pause_monitor',+ outputSchema: scrapegrapghaiMonitorOutputSchema,+ displayName: 'Pause Monitor',+ description: 'Pauses a monitor so it stops running.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Pauses a monitor: future runs stop but the monitor and its history are kept. Undo with Resume Monitor.',+ idempotent: true,+ },+ props: {+ monitorId: scrapegraphaiAiProps.monitorId({ required: true }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.pauseMonitor({ auth, monitorId: propsValue.monitorId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/resume-crawl.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/resume-crawl.tsnew file mode 100644index 00000000000..7f1abb8be12--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/resume-crawl.ts@@ -0,0 +1,26 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiOkOutputSchema } from '../../output-schemas';++export const resumeCrawlAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_resume_crawl',+ outputSchema: scrapegrapghaiOkOutputSchema,+ displayName: 'Resume Crawl',+ description: 'Resumes a stopped crawl job.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description: 'Resumes a crawl stopped with Stop Crawl from where it left off.',+ idempotent: true,+ },+ props: {+ crawlId: scrapegraphaiAiProps.crawlId({ required: true }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.resumeCrawl({ auth, crawlId: propsValue.crawlId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/resume-monitor.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/resume-monitor.tsnew file mode 100644index 00000000000..10eead62229--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/resume-monitor.ts@@ -0,0 +1,26 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiMonitorOutputSchema } from '../../output-schemas';++export const resumeMonitorAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_resume_monitor',+ outputSchema: scrapegrapghaiMonitorOutputSchema,+ displayName: 'Resume Monitor',+ description: 'Resumes a paused monitor.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description: 'Puts a paused monitor back on its schedule immediately.',+ idempotent: true,+ },+ props: {+ monitorId: scrapegraphaiAiProps.monitorId({ required: true }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.resumeMonitor({ auth, monitorId: propsValue.monitorId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/scrape-page.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/scrape-page.tsnew file mode 100644index 00000000000..19a4749d744--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/scrape-page.ts@@ -0,0 +1,43 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegraphaiUtils } from '../../common/utils';+import { scrapegrapghaiScrapePageOutputSchema } from '../../output-schemas';++export const scrapePageAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_scrape_page',+ outputSchema: scrapegrapghaiScrapePageOutputSchema,+ displayName: 'Scrape Page',+ description: 'Fetches a URL and returns its content in one or more formats.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Fetches one public URL and returns it in every selected format in a single call: markdown, HTML, links, images, an AI summary, an AI JSON extraction (with JSON Prompt), branding or a screenshot URL. Pick it for the raw page content; use Extract Data when you only need prompt-driven structured fields. Each format costs credits.',+ idempotent: true,+ },+ props: {+ url: scrapegraphaiAiProps.url({ required: true }),+ formats: scrapegraphaiAiProps.formats({ required: true }),+ mode: scrapegraphaiAiProps.formatMode({ required: false }),+ jsonPrompt: scrapegraphaiAiProps.jsonPrompt({ required: false }),+ jsonSchema: scrapegraphaiAiProps.jsonSchema({ required: false }),+ fetchConfig: scrapegraphaiAiProps.fetchConfig({ required: false }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.scrape({+ auth,+ url: propsValue.url,+ formats: scrapegraphaiUtils.buildFormats({+ types: propsValue.formats,+ mode: propsValue.mode,+ jsonPrompt: propsValue.jsonPrompt,+ jsonSchema: propsValue.jsonSchema,+ }),+ fetchConfig: propsValue.fetchConfig,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/search-web.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/search-web.tsnew file mode 100644index 00000000000..3f936ff2624--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/search-web.ts@@ -0,0 +1,90 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiSearchWebOutputSchema } from '../../output-schemas';++export const searchWebAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_search_web',+ outputSchema: scrapegrapghaiSearchWebOutputSchema,+ displayName: 'Search the Web',+ description: 'Runs a web search and returns the top results with their page content.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Runs a web search and returns the top results (1-20, default 3) with each page's content inline. Add a prompt (and optional schema) to also get one AI extraction across all results under `json`. Costs 2 credits per result, or 5 with a prompt.",+ idempotent: true,+ },+ props: {+ query: Property.ShortText({+ displayName: 'Query',+ description: 'The search query, e.g. "scrapegraphai pricing".',+ required: true,+ }),+ numResults: Property.Number({+ displayName: 'Number of Results',+ description: 'How many results to fetch, 1-20. Defaults to 3.',+ required: false,+ }),+ prompt: Property.LongText({+ displayName: 'Prompt',+ description:+ 'Optional extraction prompt run across all fetched results; the answer is returned under `json`.',+ required: false,+ }),+ schema: scrapegraphaiAiProps.jsonSchema({+ required: false,+ displayName: 'Schema',+ description: 'Optional JSON Schema object for the extraction output. Requires Prompt.',+ }),+ format: Property.StaticDropdown({+ displayName: 'Content Format',+ description: "Format of each result's inline content. Defaults to markdown.",+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Markdown', value: 'markdown' },+ { label: 'HTML', value: 'html' },+ ],+ },+ }),+ timeRange: Property.StaticDropdown({+ displayName: 'Time Range',+ description: 'Only return results published within this window. Defaults to any time.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Past hour', value: 'past_hour' },+ { label: 'Past 24 hours', value: 'past_24_hours' },+ { label: 'Past week', value: 'past_week' },+ { label: 'Past month', value: 'past_month' },+ { label: 'Past year', value: 'past_year' },+ ],+ },+ }),+ locationGeoCode: Property.ShortText({+ displayName: 'Country',+ description: 'ISO 3166-1 alpha-2 country code for localized results, e.g. "us" or "it".',+ required: false,+ }),+ fetchConfig: scrapegraphaiAiProps.fetchConfig({ required: false }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.search({+ auth,+ query: propsValue.query,+ numResults: propsValue.numResults,+ prompt: propsValue.prompt,+ schema: propsValue.schema,+ format: propsValue.format,+ timeRange: propsValue.timeRange,+ locationGeoCode: propsValue.locationGeoCode,+ fetchConfig: propsValue.fetchConfig,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/start-crawl.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/start-crawl.tsnew file mode 100644index 00000000000..b22dd25408b--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/start-crawl.ts@@ -0,0 +1,82 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegraphaiUtils } from '../../common/utils';+import { scrapegrapghaiStartCrawlOutputSchema } from '../../output-schemas';++export const startCrawlAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_start_crawl',+ outputSchema: scrapegrapghaiStartCrawlOutputSchema,+ displayName: 'Start Crawl',+ description: 'Starts an asynchronous multi-page crawl and returns its job ID.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Starts an asynchronous crawl from a URL and returns the job `id` immediately, without waiting. Poll it with Get Crawl until status is completed or failed (a crawl halted with Stop Crawl reads paused), then read content with List Crawl Pages. Uses one of the plan's crawl job slots and 2 credits plus the per-page scrape cost.",+ idempotent: false,+ },+ props: {+ url: scrapegraphaiAiProps.url({+ required: true,+ description: 'Starting URL of the crawl, including the scheme.',+ }),+ formats: scrapegraphaiAiProps.formats({ required: false }),+ mode: scrapegraphaiAiProps.formatMode({ required: false }),+ jsonPrompt: scrapegraphaiAiProps.jsonPrompt({ required: false }),+ jsonSchema: scrapegraphaiAiProps.jsonSchema({ required: false }),+ maxPages: Property.Number({+ displayName: 'Max Pages',+ description: 'Maximum number of pages to crawl.',+ required: false,+ }),+ maxDepth: Property.Number({+ displayName: 'Max Depth',+ description: 'How many levels of links to follow from the starting URL.',+ required: false,+ }),+ maxLinksPerPage: Property.Number({+ displayName: 'Max Links per Page',+ description: 'Cap on links followed from each page.',+ required: false,+ }),+ allowExternal: Property.Checkbox({+ displayName: 'Allow External Links',+ description: 'Follow links to other domains. Defaults to false.',+ required: false,+ }),+ includePatterns: Property.Array({+ displayName: 'Include Patterns',+ description: 'Glob URL patterns to include, e.g. ["/blog/*"].',+ required: false,+ }),+ excludePatterns: Property.Array({+ displayName: 'Exclude Patterns',+ description: 'Glob URL patterns to skip, e.g. ["/admin/*"].',+ required: false,+ }),+ fetchConfig: scrapegraphaiAiProps.fetchConfig({ required: false }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.startCrawl({+ auth,+ url: propsValue.url,+ formats: scrapegraphaiUtils.buildFormats({+ types: propsValue.formats,+ mode: propsValue.mode,+ jsonPrompt: propsValue.jsonPrompt,+ jsonSchema: propsValue.jsonSchema,+ }),+ maxPages: propsValue.maxPages,+ maxDepth: propsValue.maxDepth,+ maxLinksPerPage: propsValue.maxLinksPerPage,+ allowExternal: propsValue.allowExternal,+ includePatterns: propsValue.includePatterns,+ excludePatterns: propsValue.excludePatterns,+ fetchConfig: propsValue.fetchConfig,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/stop-crawl.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/stop-crawl.tsnew file mode 100644index 00000000000..4fc5e82a4a0--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/stop-crawl.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegrapghaiOkOutputSchema } from '../../output-schemas';++export const stopCrawlAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_stop_crawl',+ outputSchema: scrapegrapghaiOkOutputSchema,+ displayName: 'Stop Crawl',+ description: 'Stops a running crawl job.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Stops a running crawl from Start Crawl; its status becomes "paused", pages already fetched stay available and no new URLs are followed. Resume it with Resume Crawl. A crawl that already finished returns a 410 "Crawl session expired" error.',+ idempotent: true,+ },+ props: {+ crawlId: scrapegraphaiAiProps.crawlId({ required: true }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.stopCrawl({ auth, crawlId: propsValue.crawlId });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/update-monitor.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/update-monitor.tsnew file mode 100644index 00000000000..24516671e31--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/ai/update-monitor.ts@@ -0,0 +1,49 @@+import { createAction } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../../auth';+import { scrapegraphaiAiProps } from '../../common/ai-props';+import { scrapegraphaiApi } from '../../common/api';+import { scrapegraphaiUtils } from '../../common/utils';+import { scrapegrapghaiMonitorOutputSchema } from '../../output-schemas';++export const updateMonitorAction = createAction({+ auth: scrapegraphaiAuth,+ name: 'scrapegrapghai_update_monitor',+ outputSchema: scrapegrapghaiMonitorOutputSchema,+ displayName: 'Update Monitor',+ description: "Updates a monitor's schedule, name, formats, webhook or fetch options.",+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Changes only the fields you set on a monitor: interval, name, formats, webhook URL or fetch options. The watched URL cannot be changed; create a new monitor for a different page.',+ idempotent: true,+ },+ props: {+ monitorId: scrapegraphaiAiProps.monitorId({ required: true }),+ interval: scrapegraphaiAiProps.interval({ required: false }),+ name: scrapegraphaiAiProps.monitorName({ required: false }),+ formats: scrapegraphaiAiProps.formats({ required: false }),+ mode: scrapegraphaiAiProps.formatMode({ required: false }),+ jsonPrompt: scrapegraphaiAiProps.jsonPrompt({ required: false }),+ jsonSchema: scrapegraphaiAiProps.jsonSchema({ required: false }),+ webhookUrl: scrapegraphaiAiProps.webhookUrl({ required: false }),+ fetchConfig: scrapegraphaiAiProps.fetchConfig({ required: false }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.updateMonitor({+ auth,+ monitorId: propsValue.monitorId,+ interval: propsValue.interval,+ name: propsValue.name,+ formats: scrapegraphaiUtils.buildFormats({+ types: propsValue.formats,+ mode: propsValue.mode,+ jsonPrompt: propsValue.jsonPrompt,+ jsonSchema: propsValue.jsonSchema,+ }),+ webhookUrl: propsValue.webhookUrl,+ fetchConfig: propsValue.fetchConfig,+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/convert-to-markdown.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/convert-to-markdown.tsnew file mode 100644index 00000000000..aac45ead153--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/convert-to-markdown.ts@@ -0,0 +1,34 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { scrapegraphaiAuth } from '../auth';+import { scrapegraphaiApi } from '../common/api';+import { scrapegrapghaiMarkdownifyOutputSchema } from '../output-schemas';++export const markdownifyAction = createAction({+ name: 'markdownify',+ outputSchema: scrapegrapghaiMarkdownifyOutputSchema,+ classification: 'READ',+ displayName: 'Convert to Markdown',+ description: 'Convert any webpage into clean, readable Markdown format.',+ audience: 'human',+ aiMetadata: {+ description:+ 'Fetches a webpage by URL and returns its content as clean, readable Markdown. Choose this when you need the whole page as text for an LLM or document rather than a targeted extraction — use Smart Scraper instead when you want specific fields described by a prompt. Requires a public URL; read-only and safe to retry.',+ idempotent: true,+ },+ auth: scrapegraphaiAuth,+ props: {+ website_url: Property.ShortText({+ displayName: 'Website URL',+ description: 'The webpage URL to convert to Markdown',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ return await scrapegraphaiApi.scrape({+ auth,+ url: propsValue.website_url,+ formats: [{ type: 'markdown' }],+ });+ },+});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/local-scraper.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/local-scraper.tsindex f21cecb912c..4ea0d74f7c0 100644--- a/packages/pieces/community/scrapegrapghai/src/lib/actions/local-scraper.ts+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/local-scraper.ts@@ -1,13 +1,15 @@import { createAction, Property } from '@activepieces/pieces-framework';-import { httpClient, HttpMethod } from '@activepieces/pieces-common';import { scrapegraphaiAuth } from '../auth';+import { scrapegraphaiApi } from '../common/api';+import { scrapegrapghaiExtractOutputSchema } from '../output-schemas';-export const localScraper = createAction({+export const localScraperAction = createAction({name: 'local_scraper',+ outputSchema: scrapegrapghaiExtractOutputSchema,classification: 'READ',displayName: 'Local Scraper',description: 'Extract content from HTML content using AI by providing a natural language prompt.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Uses AI to extract information described in a natural-language prompt from raw HTML you supply directly (max 2MB); optionally pass an output schema to shape the result into structured fields. Choose this when you already have the page HTML in hand and do not want the service to fetch a URL — for a live URL use Smart Scraper instead. Read-only and safe to retry.', idempotent: true },auth: scrapegraphaiAuth,props: {@@ -28,20 +30,11 @@ export const localScraper = createAction({}),},async run({ auth, propsValue }) {- const response = await httpClient.sendRequest({- method: HttpMethod.POST,- url: 'https://api.scrapegraphai.com/v1/localscraper',- headers: {- 'Content-Type': 'application/json',- 'SGAI-APIKEY': auth.secret_text,- },- body: {- website_html: propsValue.website_html,- user_prompt: propsValue.user_prompt,- output_schema: propsValue.output_schema,- },+ return await scrapegraphaiApi.extract({+ auth,+ html: propsValue.website_html,+ prompt: propsValue.user_prompt,+ schema: propsValue.output_schema,});-- return response.body;},});\ No newline at end of filediff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/markdownify.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/markdownify.tsdeleted file mode 100644index d82e6f99e60..00000000000--- a/packages/pieces/community/scrapegrapghai/src/lib/actions/markdownify.ts+++ /dev/null@@ -1,35 +0,0 @@-import { createAction, Property } from '@activepieces/pieces-framework';-import { httpClient, HttpMethod } from '@activepieces/pieces-common';-import { scrapegraphaiAuth } from '../auth';--export const markdownify = createAction({- name: 'markdownify',- classification: 'READ',- displayName: 'Convert to Markdown',- description: 'Convert any webpage into clean, readable Markdown format.',- audience: 'both',- aiMetadata: { description: 'Fetches a webpage by URL and returns its content as clean, readable Markdown. Choose this when you need the whole page as text for an LLM or document rather than a targeted extraction — use Smart Scraper instead when you want specific fields described by a prompt. Requires a public URL; read-only and safe to retry.', idempotent: true },- auth: scrapegraphaiAuth,- props: {- website_url: Property.ShortText({- displayName: 'Website URL',- description: 'The webpage URL to convert to Markdown',- required: true,- }),- },- async run({ auth, propsValue }) {- const response = await httpClient.sendRequest({- method: HttpMethod.POST,- url: 'https://api.scrapegraphai.com/v1/markdownify',- headers: {- 'Content-Type': 'application/json',- 'SGAI-APIKEY': auth.secret_text,- },- body: {- website_url: propsValue.website_url,- },- });-- return response.body;- },-});\ No newline at end of filediff --git a/packages/pieces/community/scrapegrapghai/src/lib/actions/smart-scraper.ts b/packages/pieces/community/scrapegrapghai/src/lib/actions/smart-scraper.tsindex d9be011b87d..627cb424dca 100644--- a/packages/pieces/community/scrapegrapghai/src/lib/actions/smart-scraper.ts+++ b/packages/pieces/community/scrapegrapghai/src/lib/actions/smart-scraper.ts@@ -1,13 +1,15 @@import { createAction, Property } from '@activepieces/pieces-framework';-import { httpClient, HttpMethod } from '@activepieces/pieces-common';import { scrapegraphaiAuth } from '../auth';+import { scrapegraphaiApi } from '../common/api';+import { scrapegrapghaiExtractOutputSchema } from '../output-schemas';-export const smartScraper = createAction({+export const smartScraperAction = createAction({name: 'smart_scraper',+ outputSchema: scrapegrapghaiExtractOutputSchema,classification: 'READ',displayName: 'Smart Scraper',description: 'Extract content from a webpage using AI by providing a natural language prompt.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Fetches a live webpage by URL and uses AI to extract the information described in a natural-language prompt; optionally pass an output schema to shape the result into structured fields. Choose this when you have a public URL and want targeted data from it rather than the full raw page. The page is fetched server-side from the given URL; for HTML you already hold, use Local Scraper instead. Read-only and safe to retry.', idempotent: true },auth: scrapegraphaiAuth,props: {@@ -28,20 +30,11 @@ export const smartScraper = createAction({}),},async run({ auth, propsValue }) {- const response = await httpClient.sendRequest({- method: HttpMethod.POST,- url: 'https://api.scrapegraphai.com/v1/smartscraper',- headers: {- 'Content-Type': 'application/json',- 'SGAI-APIKEY': auth.secret_text,- },- body: {- website_url: propsValue.website_url,- user_prompt: propsValue.user_prompt,- output_schema: propsValue.output_schema,- },+ return await scrapegraphaiApi.extract({+ auth,+ url: propsValue.website_url,+ prompt: propsValue.user_prompt,+ schema: propsValue.output_schema,});-- return response.body;},});\ No newline at end of filediff --git a/packages/pieces/community/scrapegrapghai/src/lib/auth.ts b/packages/pieces/community/scrapegrapghai/src/lib/auth.tsindex 10e066b929b..c67a9e5a0d5 100644--- a/packages/pieces/community/scrapegrapghai/src/lib/auth.ts+++ b/packages/pieces/community/scrapegrapghai/src/lib/auth.ts@@ -1,5 +1,5 @@-import { PieceAuth } from '@activepieces/pieces-framework';-import { httpClient, HttpMethod } from '@activepieces/pieces-common';+import { AppConnectionType, PieceAuth, tryCatch } from '@activepieces/pieces-framework';+import { scrapegraphaiApi } from './common/api';const markdownDescription = `Follow these steps to obtain your ScrapeGraphAI API Key:@@ -14,27 +14,11 @@ export const scrapegraphaiAuth = PieceAuth.SecretText({displayName: 'API Key',required: true,validate: async ({ auth }) => {- try {- await httpClient.sendRequest({- method: HttpMethod.POST,- url: 'https://api.scrapegraphai.com/v1/smartscraper',- headers: {- 'Content-Type': 'application/json',- 'SGAI-APIKEY': auth,- },- body: {- user_prompt: 'test',- website_url: 'https://www.example.com',- },- });- return {- valid: true,- };- } catch (e) {- return {- valid: false,- error: 'Invalid API Key',- };- }+ const { error } = await tryCatch(() =>+ scrapegraphaiApi.validateApiKey({+ auth: { type: AppConnectionType.SECRET_TEXT, secret_text: auth },+ }),+ );+ return error ? { valid: false, error: 'Invalid API Key' } : { valid: true };},});diff --git a/packages/pieces/community/scrapegrapghai/src/lib/common/ai-props.ts b/packages/pieces/community/scrapegrapghai/src/lib/common/ai-props.tsnew file mode 100644index 00000000000..8455f609dd5--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/common/ai-props.ts@@ -0,0 +1,136 @@+import { Property } from '@activepieces/pieces-framework';++function url<R extends boolean>({+ required,+ displayName = 'URL',+ description = 'Public page URL including the scheme, e.g. "https://example.com/pricing". Private and internal addresses are rejected.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function formats<R extends boolean>({+ required,+ displayName = 'Formats',+ description = 'Output formats to capture for the page: markdown, html, links, images, summary (AI summary), json (AI extraction, needs JSON Prompt), branding (colors, fonts, logos) or screenshot (pre-signed image URL valid for 1 hour).',+}: PropParams<R>) {+ return Property.StaticMultiSelectDropdown({+ displayName,+ description,+ required,+ options: { disabled: false, options: FORMAT_OPTIONS },+ });+}++function formatMode<R extends boolean>({+ required,+ displayName = 'Markdown/HTML Mode',+ description = 'Pre-processing for the markdown and html formats: normal (full page), reader (main article only) or prune (strip boilerplate). Defaults to normal.',+}: PropParams<R>) {+ return Property.StaticDropdown({+ displayName,+ description,+ required,+ options: { disabled: false, options: MODE_OPTIONS },+ });+}++function jsonPrompt<R extends boolean>({+ required,+ displayName = 'JSON Prompt',+ description = 'Natural-language description of the data to extract. Required when the json format is selected; ignored otherwise.',+}: PropParams<R>) {+ return Property.LongText({ displayName, description, required });+}++function jsonSchema<R extends boolean>({+ required,+ displayName = 'JSON Schema',+ description = 'Optional JSON Schema object the json output must match, e.g. {"type":"object","properties":{"title":{"type":"string"}}}. Only used with the json format.',+}: PropParams<R>) {+ return Property.Json({ displayName, description, required });+}++function fetchConfig<R extends boolean>({+ required,+ displayName = 'Fetch Config',+ description = 'Optional fetch options object: mode ("auto" default, "fast" or "js"), stealth (true for residential proxy, +5 credits), headers (object), cookies (object), scrolls (0-100), wait (ms after load, 0-30000), timeout (ms, 1000-60000), country (ISO 3166-1 alpha-2 code), e.g. {"mode":"js","wait":2000}.',+}: PropParams<R>) {+ return Property.Json({ displayName, description, required });+}++function crawlId<R extends boolean>({+ required,+ displayName = 'Crawl ID',+ description = 'Crawl job UUID, returned as `id` by Start Crawl.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function monitorId<R extends boolean>({+ required,+ displayName = 'Monitor ID',+ description = 'Monitor UUID, returned as `cronId` by Create Monitor or List Monitors.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function monitorName<R extends boolean>({+ required,+ displayName = 'Name',+ description = 'Human-readable monitor name, e.g. "Pricing page watch".',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function interval<R extends boolean>({+ required,+ displayName = 'Interval',+ description = '5-field cron expression in UTC for how often to fetch, e.g. "*/30 * * * *" (every 30 minutes) or "0 9 * * 1" (Mondays 09:00).',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function webhookUrl<R extends boolean>({+ required,+ displayName = 'Webhook URL',+ description = 'Optional URL that receives a POST with the captured payload on every tick.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++export const scrapegraphaiAiProps = {+ url,+ formats,+ formatMode,+ jsonPrompt,+ jsonSchema,+ fetchConfig,+ crawlId,+ monitorId,+ monitorName,+ interval,+ webhookUrl,+};++const FORMAT_OPTIONS = [+ { label: 'Markdown', value: 'markdown' },+ { label: 'HTML', value: 'html' },+ { label: 'Links', value: 'links' },+ { label: 'Images', value: 'images' },+ { label: 'Summary', value: 'summary' },+ { label: 'JSON (AI extraction)', value: 'json' },+ { label: 'Branding', value: 'branding' },+ { label: 'Screenshot', value: 'screenshot' },+];++const MODE_OPTIONS = [+ { label: 'Normal', value: 'normal' },+ { label: 'Reader', value: 'reader' },+ { label: 'Prune', value: 'prune' },+];++export type PropParams<R extends boolean> = {+ required: R;+ displayName?: string;+ description?: string;+};diff --git a/packages/pieces/community/scrapegrapghai/src/lib/common/api.ts b/packages/pieces/community/scrapegrapghai/src/lib/common/api.tsnew file mode 100644index 00000000000..746614b7e63--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/common/api.ts@@ -0,0 +1,362 @@+import { HttpMethod, QueryParams } from '@activepieces/pieces-common';++import { scrapegraphaiClient } from './client';++import type {+ ScrapegraphaiAuthValue,+ ScrapegraphaiCrawl,+ ScrapegraphaiCrawlPages,+ ScrapegraphaiCrawlParams,+ ScrapegraphaiCredits,+ ScrapegraphaiExtractParams,+ ScrapegraphaiExtractResult,+ ScrapegraphaiHistoryEntry,+ ScrapegraphaiHistoryPage,+ ScrapegraphaiMonitor,+ ScrapegraphaiMonitorActivity,+ ScrapegraphaiMonitorCreateParams,+ ScrapegraphaiMonitorUpdateParams,+ ScrapegraphaiOk,+ ScrapegraphaiScrapeParams,+ ScrapegraphaiScrapeResult,+ ScrapegraphaiSearchParams,+ ScrapegraphaiSearchResult,+ ScrapegraphaiValidateResult,+} from './types';++function toQuery({ values }: { values: Record<string, string | number | undefined> }): QueryParams {+ return Object.fromEntries(+ Object.entries(values).flatMap(([key, value]) =>+ value === undefined ? [] : [[key, String(value)]],+ ),+ );+}++async function validateApiKey({+ auth,+}: {+ auth: ScrapegraphaiAuthValue;+}): Promise<ScrapegraphaiValidateResult> {+ return await scrapegraphaiClient.request<ScrapegraphaiValidateResult>({+ auth,+ method: HttpMethod.GET,+ path: '/validate',+ });+}++async function scrape({+ auth,+ ...body+}: ScrapegraphaiScrapeParams & {+ auth: ScrapegraphaiAuthValue;+}): Promise<ScrapegraphaiScrapeResult> {+ return await scrapegraphaiClient.request<ScrapegraphaiScrapeResult>({+ auth,+ method: HttpMethod.POST,+ path: '/scrape',+ body,+ });+}++async function extract({+ auth,+ ...body+}: ScrapegraphaiExtractParams & {+ auth: ScrapegraphaiAuthValue;+}): Promise<ScrapegraphaiExtractResult> {+ return await scrapegraphaiClient.request<ScrapegraphaiExtractResult>({+ auth,+ method: HttpMethod.POST,+ path: '/extract',+ body,+ });+}++async function search({+ auth,+ ...body+}: ScrapegraphaiSearchParams & {+ auth: ScrapegraphaiAuthValue;+}): Promise<ScrapegraphaiSearchResult> {+ return await scrapegraphaiClient.request<ScrapegraphaiSearchResult>({+ auth,+ method: HttpMethod.POST,+ path: '/search',+ body,+ });+}++async function startCrawl({+ auth,+ ...body+}: ScrapegraphaiCrawlParams & { auth: ScrapegraphaiAuthValue }): Promise<ScrapegraphaiCrawl> {+ return await scrapegraphaiClient.request<ScrapegraphaiCrawl>({+ auth,+ method: HttpMethod.POST,+ path: '/crawl',+ body,+ });+}++async function getCrawl({+ auth,+ crawlId,+}: {+ auth: ScrapegraphaiAuthValue;+ crawlId: string;+}): Promise<ScrapegraphaiCrawl> {+ return await scrapegraphaiClient.request<ScrapegraphaiCrawl>({+ auth,+ method: HttpMethod.GET,+ path: `/crawl/${encodeURIComponent(crawlId)}`,+ });+}++async function listCrawlPages({+ auth,+ crawlId,+ limit,+ cursor,+}: {+ auth: ScrapegraphaiAuthValue;+ crawlId: string;+ limit?: number;+ cursor?: number;+}): Promise<ScrapegraphaiCrawlPages> {+ return await scrapegraphaiClient.request<ScrapegraphaiCrawlPages>({+ auth,+ method: HttpMethod.GET,+ path: `/crawl/${encodeURIComponent(crawlId)}/pages`,+ query: toQuery({ values: { limit, cursor } }),+ });+}++async function stopCrawl({+ auth,+ crawlId,+}: {+ auth: ScrapegraphaiAuthValue;+ crawlId: string;+}): Promise<ScrapegraphaiOk> {+ return await scrapegraphaiClient.request<ScrapegraphaiOk>({+ auth,+ method: HttpMethod.POST,+ path: `/crawl/${encodeURIComponent(crawlId)}/stop`,+ });+}++async function resumeCrawl({+ auth,+ crawlId,+}: {+ auth: ScrapegraphaiAuthValue;+ crawlId: string;+}): Promise<ScrapegraphaiOk> {+ return await scrapegraphaiClient.request<ScrapegraphaiOk>({+ auth,+ method: HttpMethod.POST,+ path: `/crawl/${encodeURIComponent(crawlId)}/resume`,+ });+}++async function deleteCrawl({+ auth,+ crawlId,+}: {+ auth: ScrapegraphaiAuthValue;+ crawlId: string;+}): Promise<ScrapegraphaiOk> {+ return await scrapegraphaiClient.request<ScrapegraphaiOk>({+ auth,+ method: HttpMethod.DELETE,+ path: `/crawl/${encodeURIComponent(crawlId)}`,+ });+}++async function createMonitor({+ auth,+ ...body+}: ScrapegraphaiMonitorCreateParams & {+ auth: ScrapegraphaiAuthValue;+}): Promise<ScrapegraphaiMonitor> {+ return await scrapegraphaiClient.request<ScrapegraphaiMonitor>({+ auth,+ method: HttpMethod.POST,+ path: '/monitor',+ body,+ });+}++async function listMonitors({+ auth,+}: {+ auth: ScrapegraphaiAuthValue;+}): Promise<ScrapegraphaiMonitor[]> {+ return await scrapegraphaiClient.request<ScrapegraphaiMonitor[]>({+ auth,+ method: HttpMethod.GET,+ path: '/monitor',+ });+}++async function getMonitor({+ auth,+ monitorId,+}: {+ auth: ScrapegraphaiAuthValue;+ monitorId: string;+}): Promise<ScrapegraphaiMonitor> {+ return await scrapegraphaiClient.request<ScrapegraphaiMonitor>({+ auth,+ method: HttpMethod.GET,+ path: `/monitor/${encodeURIComponent(monitorId)}`,+ });+}++async function updateMonitor({+ auth,+ monitorId,+ ...body+}: ScrapegraphaiMonitorUpdateParams & {+ auth: ScrapegraphaiAuthValue;+ monitorId: string;+}): Promise<ScrapegraphaiMonitor> {+ return await scrapegraphaiClient.request<ScrapegraphaiMonitor>({+ auth,+ method: HttpMethod.PATCH,+ path: `/monitor/${encodeURIComponent(monitorId)}`,+ body,+ });+}++async function pauseMonitor({+ auth,+ monitorId,+}: {+ auth: ScrapegraphaiAuthValue;+ monitorId: string;+}): Promise<ScrapegraphaiMonitor> {+ return await scrapegraphaiClient.request<ScrapegraphaiMonitor>({+ auth,+ method: HttpMethod.POST,+ path: `/monitor/${encodeURIComponent(monitorId)}/pause`,+ });+}++async function resumeMonitor({+ auth,+ monitorId,+}: {+ auth: ScrapegraphaiAuthValue;+ monitorId: string;+}): Promise<ScrapegraphaiMonitor> {+ return await scrapegraphaiClient.request<ScrapegraphaiMonitor>({+ auth,+ method: HttpMethod.POST,+ path: `/monitor/${encodeURIComponent(monitorId)}/resume`,+ });+}++async function deleteMonitor({+ auth,+ monitorId,+}: {+ auth: ScrapegraphaiAuthValue;+ monitorId: string;+}): Promise<ScrapegraphaiOk> {+ return await scrapegraphaiClient.request<ScrapegraphaiOk>({+ auth,+ method: HttpMethod.DELETE,+ path: `/monitor/${encodeURIComponent(monitorId)}`,+ });+}++async function listMonitorActivity({+ auth,+ monitorId,+ limit,+ cursor,+}: {+ auth: ScrapegraphaiAuthValue;+ monitorId: string;+ limit?: number;+ cursor?: string;+}): Promise<ScrapegraphaiMonitorActivity> {+ return await scrapegraphaiClient.request<ScrapegraphaiMonitorActivity>({+ auth,+ method: HttpMethod.GET,+ path: `/monitor/${encodeURIComponent(monitorId)}/activity`,+ query: toQuery({ values: { limit, cursor } }),+ });+}++async function listHistory({+ auth,+ page,+ limit,+ service,+ sessionId,+}: {+ auth: ScrapegraphaiAuthValue;+ page?: number;+ limit?: number;+ service?: string;+ sessionId?: string;+}): Promise<ScrapegraphaiHistoryPage> {+ return await scrapegraphaiClient.request<ScrapegraphaiHistoryPage>({+ auth,+ method: HttpMethod.GET,+ path: '/history',+ query: toQuery({ values: { page, limit, service, sessionId } }),+ });+}++async function getHistoryEntry({+ auth,+ requestId,+}: {+ auth: ScrapegraphaiAuthValue;+ requestId: string;+}): Promise<ScrapegraphaiHistoryEntry> {+ return await scrapegraphaiClient.request<ScrapegraphaiHistoryEntry>({+ auth,+ method: HttpMethod.GET,+ path: `/history/${encodeURIComponent(requestId)}`,+ });+}++async function getCredits({+ auth,+}: {+ auth: ScrapegraphaiAuthValue;+}): Promise<ScrapegraphaiCredits> {+ return await scrapegraphaiClient.request<ScrapegraphaiCredits>({+ auth,+ method: HttpMethod.GET,+ path: '/credits',+ });+}++export const scrapegraphaiApi = {+ validateApiKey,+ scrape,+ extract,+ search,+ startCrawl,+ getCrawl,+ listCrawlPages,+ stopCrawl,+ resumeCrawl,+ deleteCrawl,+ createMonitor,+ listMonitors,+ getMonitor,+ updateMonitor,+ pauseMonitor,+ resumeMonitor,+ deleteMonitor,+ listMonitorActivity,+ listHistory,+ getHistoryEntry,+ getCredits,+};diff --git a/packages/pieces/community/scrapegrapghai/src/lib/common/client.ts b/packages/pieces/community/scrapegrapghai/src/lib/common/client.tsnew file mode 100644index 00000000000..719fa473d30--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/common/client.ts@@ -0,0 +1,31 @@+import { HttpMethod, QueryParams, httpClient } from '@activepieces/pieces-common';++import type { ScrapegraphaiAuthValue } from './types';++function baseUrl(): string {+ return 'https://v2-api.scrapegraphai.com/api';+}++async function request<T>({+ auth,+ method,+ path,+ query,+ body,+}: RequestParams & { auth: ScrapegraphaiAuthValue }): Promise<T> {+ const response = await httpClient.sendRequest<T>({+ method,+ url: `${baseUrl()}${path}`,+ headers: {+ 'Content-Type': 'application/json',+ 'SGAI-APIKEY': auth.secret_text,+ },+ queryParams: query,+ body,+ });+ return response.body;+}++export const scrapegraphaiClient = { baseUrl, request };++type RequestParams = { method: HttpMethod; path: string; query?: QueryParams; body?: unknown };diff --git a/packages/pieces/community/scrapegrapghai/src/lib/common/types.ts b/packages/pieces/community/scrapegrapghai/src/lib/common/types.tsnew file mode 100644index 00000000000..c533bbfe281--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/common/types.ts@@ -0,0 +1,148 @@+import type { AppConnectionType } from '@activepieces/pieces-framework';++export type ScrapegraphaiAuthValue = { type: AppConnectionType.SECRET_TEXT; secret_text: string };++export type ScrapegraphaiFormat = {+ type: string;+ mode?: string;+ prompt?: string;+ schema?: Record<string, unknown>;+};++export type ScrapegraphaiScrapeParams = {+ url: string;+ formats?: ScrapegraphaiFormat[];+ contentType?: string;+ fetchConfig?: Record<string, unknown>;+};++export type ScrapegraphaiExtractParams = {+ url?: string;+ html?: string;+ markdown?: string;+ prompt: string;+ schema?: Record<string, unknown>;+ mode?: string;+ fetchConfig?: Record<string, unknown>;+};++export type ScrapegraphaiScrapeResult = {+ id?: string;+ results?: Record<string, unknown>;+ metadata?: Record<string, unknown>;+ errors?: unknown;+};++export type ScrapegraphaiExtractResult = {+ id?: string;+ raw?: string | null;+ json?: unknown;+ usage?: { promptTokens?: number; completionTokens?: number };+ metadata?: Record<string, unknown>;+};++export type ScrapegraphaiValidateResult = { email?: string };++export type ScrapegraphaiSearchParams = {+ query: string;+ numResults?: number;+ prompt?: string;+ schema?: Record<string, unknown>;+ format?: string;+ mode?: string;+ timeRange?: string;+ locationGeoCode?: string;+ fetchConfig?: Record<string, unknown>;+};++export type ScrapegraphaiSearchResult = {+ id?: string;+ results?: { url?: string; title?: string; content?: string }[];+ json?: unknown;+ raw?: string | null;+ usage?: { promptTokens?: number; completionTokens?: number };+ metadata?: Record<string, unknown>;+};++export type ScrapegraphaiCrawlParams = {+ url: string;+ formats?: ScrapegraphaiFormat[];+ maxPages?: number;+ maxDepth?: number;+ maxLinksPerPage?: number;+ allowExternal?: boolean;+ includePatterns?: unknown[];+ excludePatterns?: unknown[];+ fetchConfig?: Record<string, unknown>;+};++export type ScrapegraphaiCrawl = {+ id?: string;+ status?: string;+ reason?: string | null;+ total?: number;+ finished?: number;+ pages?: Record<string, unknown>[];+};++export type ScrapegraphaiCrawlPages = {+ data?: Record<string, unknown>[];+ pagination?: { limit?: number; nextCursor?: string | number | null };+};++export type ScrapegraphaiOk = { ok?: boolean };++export type ScrapegraphaiMonitorUpdateParams = {+ name?: string;+ interval?: string;+ formats?: ScrapegraphaiFormat[];+ webhookUrl?: string;+ fetchConfig?: Record<string, unknown>;+};++export type ScrapegraphaiMonitorCreateParams = ScrapegraphaiMonitorUpdateParams & {+ url: string;+ interval: string;+};++export type ScrapegraphaiMonitor = {+ cronId?: string;+ scheduleId?: string;+ interval?: string;+ status?: string;+ reason?: string | null;+ consecutiveFailures?: number;+ config?: Record<string, unknown>;+ createdAt?: string;+ updatedAt?: string;+};++export type ScrapegraphaiMonitorActivity = {+ ticks?: Record<string, unknown>[];+ nextCursor?: string | null;+};++export type ScrapegraphaiHistoryEntry = {+ id?: string;+ service?: string;+ status?: string;+ error?: unknown;+ elapsedMs?: number;+ createdAt?: string;+ requestParentId?: string | null;+ sessionId?: string | null;+ params?: Record<string, unknown>;+ result?: unknown;+};++export type ScrapegraphaiHistoryPage = {+ data?: ScrapegraphaiHistoryEntry[];+ pagination?: { page?: number; limit?: number; total?: number };+};++export type ScrapegraphaiCredits = {+ remaining?: number;+ used?: number;+ plan?: string;+ jobs?: Record<string, { used?: number; limit?: number }>;+};diff --git a/packages/pieces/community/scrapegrapghai/src/lib/common/utils.ts b/packages/pieces/community/scrapegrapghai/src/lib/common/utils.tsnew file mode 100644index 00000000000..376e3e10e1c--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/common/utils.ts@@ -0,0 +1,33 @@+import type { ScrapegraphaiFormat } from './types';++function buildFormats({+ types,+ mode,+ jsonPrompt,+ jsonSchema,+}: {+ types?: string[];+ mode?: string;+ jsonPrompt?: string;+ jsonSchema?: Record<string, unknown>;+}): ScrapegraphaiFormat[] | undefined {+ if (!types || types.length === 0) {+ if (mode !== undefined || jsonPrompt !== undefined || jsonSchema !== undefined) {+ throw new Error(+ 'Markdown/HTML Mode, JSON Prompt and JSON Schema apply to the selected Formats: set Formats as well, including json for JSON Prompt and JSON Schema.',+ );+ }+ return undefined;+ }+ return types.map((type) => {+ if (type === 'json') {+ return { type, prompt: jsonPrompt, schema: jsonSchema };+ }+ if (type === 'markdown' || type === 'html') {+ return { type, mode };+ }+ return { type };+ });+}++export const scrapegraphaiUtils = { buildFormats };diff --git a/packages/pieces/community/scrapegrapghai/src/lib/output-schemas.ts b/packages/pieces/community/scrapegrapghai/src/lib/output-schemas.tsnew file mode 100644index 00000000000..31f2615a3e7--- /dev/null+++ b/packages/pieces/community/scrapegrapghai/src/lib/output-schemas.ts@@ -0,0 +1,396 @@+import { OutputSchema } from '@activepieces/pieces-framework';++const okFields: OutputSchema['fields'] = [{ key: 'ok', label: 'Success', format: 'boolean' }];++const usageField: OutputSchema['fields'][number] = {+ key: 'usage',+ label: 'Token Usage',+ children: [+ { key: 'promptTokens', label: 'Prompt Tokens', format: 'number' },+ { key: 'completionTokens', label: 'Completion Tokens', format: 'number' },+ ],+};++const extractFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Request ID' },+ { key: 'json', label: 'Extracted Data', dynamicKey: true },+ { key: 'raw', label: 'Raw Model Output' },+ usageField,+];++const formatDataFields: OutputSchema['fields'] = [{ key: 'data', label: 'Content' }];++const countedFormatFields: OutputSchema['fields'] = [+ { key: 'data', label: 'URLs' },+ {+ key: 'metadata',+ label: 'Metadata',+ children: [{ key: 'count', label: 'Count', format: 'number' }],+ },+];++const scrapeResultsField: OutputSchema['fields'][number] = {+ key: 'results',+ label: 'Results',+ children: [+ { key: 'markdown', label: 'Markdown', children: formatDataFields },+ { key: 'html', label: 'HTML', children: formatDataFields },+ { key: 'links', label: 'Links', children: countedFormatFields },+ { key: 'images', label: 'Images', children: countedFormatFields },+ { key: 'summary', label: 'Summary', children: [{ key: 'data', label: 'Summary' }] },+ {+ key: 'json',+ label: 'JSON',+ children: [{ key: 'data', label: 'Extracted Data', dynamicKey: true }],+ },+ {+ key: 'branding',+ label: 'Branding',+ children: [+ {+ key: 'data',+ label: 'Branding',+ children: [+ { key: 'colorScheme', label: 'Color Scheme' },+ {+ key: 'colors',+ label: 'Colors',+ children: [+ { key: 'primary', label: 'Primary' },+ { key: 'accent', label: 'Accent' },+ { key: 'background', label: 'Background' },+ { key: 'textPrimary', label: 'Text Primary' },+ { key: 'link', label: 'Link' },+ ],+ },+ {+ key: 'fonts',+ label: 'Fonts',+ labelKey: 'family',+ listItems: [+ { key: 'family', label: 'Family' },+ { key: 'role', label: 'Role' },+ ],+ },+ {+ key: 'typography',+ label: 'Typography',+ children: [+ { key: 'fontFamilies', label: 'Font Families' },+ { key: 'fontStacks', label: 'Font Stacks' },+ { key: 'fontSizes', label: 'Font Sizes' },+ ],+ },+ {+ key: 'spacing',+ label: 'Spacing',+ children: [+ { key: 'baseUnit', label: 'Base Unit', format: 'number' },+ { key: 'borderRadius', label: 'Border Radius' },+ ],+ },+ {+ key: 'components',+ label: 'Components',+ children: [+ { key: 'input', label: 'Input' },+ { key: 'buttonPrimary', label: 'Primary Button' },+ { key: 'buttonSecondary', label: 'Secondary Button' },+ ],+ },+ {+ key: 'images',+ label: 'Images',+ children: [+ { key: 'logo', label: 'Logo', format: 'image' },+ { key: 'favicon', label: 'Favicon', format: 'image' },+ { key: 'ogImage', label: 'Open Graph Image', format: 'image' },+ ],+ },+ {+ key: 'personality',+ label: 'Personality',+ children: [+ { key: 'tone', label: 'Tone' },+ { key: 'energy', label: 'Energy' },+ { key: 'targetAudience', label: 'Target Audience' },+ ],+ },+ {+ key: 'designSystem',+ label: 'Design System',+ children: [+ { key: 'framework', label: 'Framework' },+ { key: 'componentLibrary', label: 'Component Library' },+ ],+ },+ {+ key: 'confidence',+ label: 'Confidence',+ children: [{ key: 'overall', label: 'Overall', format: 'number' }],+ },+ ],+ },+ {+ key: 'metadata',+ label: 'Page Metadata',+ children: [+ {+ key: 'branding',+ label: 'Page',+ children: [+ { key: 'title', label: 'Title' },+ { key: 'description', label: 'Description' },+ { key: 'favicon', label: 'Favicon', format: 'image' },+ { key: 'language', label: 'Language' },+ { key: 'themeColor', label: 'Theme Color' },+ { key: 'ogTitle', label: 'Open Graph Title' },+ { key: 'ogDescription', label: 'Open Graph Description' },+ { key: 'ogImage', label: 'Open Graph Image', format: 'image' },+ { key: 'ogUrl', label: 'Open Graph URL', format: 'url' },+ ],+ },+ ],+ },+ ],+ },+ {+ key: 'screenshot',+ label: 'Screenshot',+ children: [+ {+ key: 'data',+ label: 'Screenshot',+ children: [+ { key: 'url', label: 'Image URL', format: 'image' },+ { key: 'width', label: 'Width', format: 'number' },+ { key: 'height', label: 'Height', format: 'number' },+ ],+ },+ ],+ },+ ],+};++const pageMetadataField: OutputSchema['fields'][number] = {+ key: 'metadata',+ label: 'Metadata',+ children: [{ key: 'contentType', label: 'Content Type' }],+};++const crawlPageFields: OutputSchema['fields'] = [+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'title', label: 'Title' },+ { key: 'status', label: 'Status' },+ { key: 'depth', label: 'Depth', format: 'number' },+ { key: 'parentUrl', label: 'Parent URL', format: 'url' },+ { key: 'contentType', label: 'Content Type' },+ { key: 'links', label: 'Links' },+ { key: 'scrapeRefId', label: 'Scrape Request ID' },+];++const crawlFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Crawl ID' },+ { key: 'status', label: 'Status' },+ { key: 'reason', label: 'Reason' },+ { key: 'total', label: 'Total Pages', format: 'number' },+ { key: 'finished', label: 'Finished Pages', format: 'number' },+ { key: 'pages', label: 'Pages', labelKey: 'url', listItems: crawlPageFields },+];++const monitorFields: OutputSchema['fields'] = [+ { key: 'cronId', label: 'Monitor ID' },+ { key: 'scheduleId', label: 'Schedule ID' },+ { key: 'status', label: 'Status' },+ { key: 'interval', label: 'Interval' },+ { key: 'reason', label: 'Reason' },+ { key: 'consecutiveFailures', label: 'Consecutive Failures', format: 'number' },+ { key: 'createdAt', label: 'Created At', format: 'datetime' },+ { key: 'updatedAt', label: 'Updated At', format: 'datetime' },+];++const historyEntryFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Request ID' },+ { key: 'service', label: 'Service' },+ { key: 'status', label: 'Status' },+ { key: 'params', label: 'Request Params', dynamicKey: true },+ { key: 'result', label: 'Result', dynamicKey: true },+ { key: 'error', label: 'Error' },+ { key: 'elapsedMs', label: 'Elapsed (ms)', format: 'number' },+ { key: 'requestParentId', label: 'Parent Request ID' },+ { key: 'sessionId', label: 'Session ID' },+ { key: 'userId', label: 'User ID' },+ { key: 'workspaceId', label: 'Workspace ID' },+ { key: 'createdAt', label: 'Created At', format: 'datetime' },+];++export const scrapegrapghaiOkOutputSchema: OutputSchema = { fields: okFields };++export const scrapegrapghaiCrawlOutputSchema: OutputSchema = { fields: crawlFields };++export const scrapegrapghaiStartCrawlOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'Crawl ID' },+ { key: 'status', label: 'Status' },+ { key: 'total', label: 'Total Pages', format: 'number' },+ { key: 'finished', label: 'Finished Pages', format: 'number' },+ { key: 'pages', label: 'Pages' },+ ],+};++export const scrapegrapghaiListCrawlPagesOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'data',+ label: 'Pages',+ labelKey: 'url',+ listItems: [+ ...crawlPageFields,+ {+ key: 'scrape',+ label: 'Scrape Result',+ children: [+ { key: 'results', label: 'Results by Format', dynamicKey: true },+ pageMetadataField,+ ],+ },+ ],+ },+ {+ key: 'pagination',+ label: 'Pagination',+ children: [+ { key: 'limit', label: 'Limit', format: 'number' },+ { key: 'nextCursor', label: 'Next Cursor' },+ ],+ },+ ],+};++export const scrapegrapghaiGetCreditsOutputSchema: OutputSchema = {+ fields: [+ { key: 'remaining', label: 'Remaining Credits', format: 'number' },+ { key: 'used', label: 'Used Credits', format: 'number' },+ { key: 'plan', label: 'Plan' },+ {+ key: 'jobs',+ label: 'Job Slots',+ children: [+ {+ key: 'crawl',+ label: 'Crawl',+ children: [+ { key: 'used', label: 'Used', format: 'number' },+ { key: 'limit', label: 'Limit', format: 'number' },+ ],+ },+ {+ key: 'monitor',+ label: 'Monitor',+ children: [+ { key: 'used', label: 'Used', format: 'number' },+ { key: 'limit', label: 'Limit', format: 'number' },+ ],+ },+ ],+ },+ ],+};++export const scrapegrapghaiExtractOutputSchema: OutputSchema = { fields: extractFields };++export const scrapegrapghaiListHistoryOutputSchema: OutputSchema = {+ fields: [+ { key: 'data', label: 'Requests', labelKey: 'id', listItems: historyEntryFields },+ {+ key: 'pagination',+ label: 'Pagination',+ children: [+ { key: 'page', label: 'Page', format: 'number' },+ { key: 'limit', label: 'Limit', format: 'number' },+ { key: 'total', label: 'Total', format: 'number' },+ ],+ },+ ],+};++export const scrapegrapghaiGetHistoryEntryOutputSchema: OutputSchema = {+ fields: historyEntryFields,+};++export const scrapegrapghaiMarkdownifyOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'Request ID' },+ {+ key: 'results',+ label: 'Results',+ children: [{ key: 'markdown', label: 'Markdown', children: formatDataFields }],+ },+ pageMetadataField,+ ],+};++export const scrapegrapghaiListMonitorActivityOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'ticks',+ label: 'Runs',+ labelKey: 'createdAt',+ listItems: [+ { key: 'id', label: 'Run ID' },+ { key: 'status', label: 'Status' },+ { key: 'changed', label: 'Changed', format: 'boolean' },+ { key: 'diffs', label: 'Diffs', dynamicKey: true },+ { key: 'elapsedMs', label: 'Elapsed (ms)', format: 'number' },+ { key: 'createdAt', label: 'Created At', format: 'datetime' },+ ],+ },+ { key: 'nextCursor', label: 'Next Cursor' },+ ],+};++export const scrapegrapghaiMonitorOutputSchema: OutputSchema = { fields: monitorFields };++export const scrapegrapghaiListMonitorsOutputSchema: OutputSchema = {+ fields: [+ { key: 'monitors', label: 'Monitors', labelKey: 'cronId', listItems: monitorFields },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const scrapegrapghaiScrapePageOutputSchema: OutputSchema = {+ fields: [{ key: 'id', label: 'Request ID' }, scrapeResultsField, pageMetadataField],+};++export const scrapegrapghaiSearchWebOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'Request ID' },+ {+ key: 'results',+ label: 'Results',+ labelKey: 'title',+ listItems: [+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'title', label: 'Title' },+ { key: 'content', label: 'Content' },+ ],+ },+ { key: 'json', label: 'Extracted Data', dynamicKey: true },+ { key: 'raw', label: 'Raw Model Output' },+ usageField,+ {+ key: 'metadata',+ label: 'Metadata',+ children: [+ {+ key: 'pages',+ label: 'Pages',+ children: [+ { key: 'requested', label: 'Requested', format: 'number' },+ { key: 'scraped', label: 'Scraped', format: 'number' },+ ],+ },+ ],+ },+ ],+};