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(hackernews): let AI agents browse stories, items and user profiles (#16129)
Kishan Parmar87e06a701db4
diff --git a/bun.lock b/bun.lockindex 869dfd07534..2c2413b6fbe 100644--- a/bun.lock+++ b/bun.lock@@ -242,7 +242,7 @@},"packages/pieces/community/activecampaign": {"name": "@activepieces/piece-activecampaign",- "version": "0.1.8",+ "version": "0.1.9","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -255,7 +255,7 @@},"packages/pieces/community/activepieces": {"name": "@activepieces/piece-activepieces",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -449,7 +449,7 @@},"packages/pieces/community/airtable": {"name": "@activepieces/piece-airtable",- "version": "0.9.0",+ "version": "0.9.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -552,7 +552,7 @@},"packages/pieces/community/amazon-s3": {"name": "@activepieces/piece-amazon-s3",- "version": "0.7.0",+ "version": "0.7.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -697,7 +697,7 @@},"packages/pieces/community/apify": {"name": "@activepieces/piece-apify",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -711,7 +711,7 @@},"packages/pieces/community/apitable": {"name": "@activepieces/piece-apitable",- "version": "0.4.0",+ "version": "0.4.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -766,7 +766,7 @@},"packages/pieces/community/asana": {"name": "@activepieces/piece-asana",- "version": "0.6.1",+ "version": "0.6.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -985,7 +985,7 @@},"packages/pieces/community/azure-openai": {"name": "@activepieces/piece-azure-openai",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1082,7 +1082,7 @@},"packages/pieces/community/baserow": {"name": "@activepieces/piece-baserow",- "version": "0.11.0",+ "version": "0.11.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1215,7 +1215,7 @@},"packages/pieces/community/binance": {"name": "@activepieces/piece-binance",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1866,7 +1866,7 @@},"packages/pieces/community/clarifai": {"name": "@activepieces/piece-clarifai",- "version": "0.4.0",+ "version": "0.4.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1880,7 +1880,7 @@},"packages/pieces/community/claude": {"name": "@activepieces/piece-claude",- "version": "0.7.0",+ "version": "0.7.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1977,7 +1977,7 @@},"packages/pieces/community/clickup": {"name": "@activepieces/piece-clickup",- "version": "0.8.1",+ "version": "0.8.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2256,7 +2256,7 @@},"packages/pieces/community/convertkit": {"name": "@activepieces/piece-convertkit",- "version": "0.4.0",+ "version": "0.4.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2379,7 +2379,7 @@},"packages/pieces/community/customer-io": {"name": "@activepieces/piece-customer-io",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2655,7 +2655,7 @@},"packages/pieces/community/discord": {"name": "@activepieces/piece-discord",- "version": "0.7.0",+ "version": "0.7.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2779,7 +2779,7 @@},"packages/pieces/community/dropbox": {"name": "@activepieces/piece-dropbox",- "version": "0.9.0",+ "version": "0.9.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3026,7 +3026,7 @@},"packages/pieces/community/exa": {"name": "@activepieces/piece-exa",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3217,7 +3217,7 @@},"packages/pieces/community/firecrawl": {"name": "@activepieces/piece-firecrawl",- "version": "0.4.0",+ "version": "0.4.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3323,7 +3323,7 @@},"packages/pieces/community/flowlu": {"name": "@activepieces/piece-flowlu",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3365,7 +3365,7 @@},"packages/pieces/community/formbricks": {"name": "@activepieces/piece-formbricks",- "version": "0.3.1",+ "version": "0.3.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3645,7 +3645,7 @@},"packages/pieces/community/ghostcms": {"name": "@activepieces/piece-ghostcms",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3809,7 +3809,7 @@},"packages/pieces/community/google-calendar": {"name": "@activepieces/piece-google-calendar",- "version": "0.12.0",+ "version": "0.12.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3839,7 +3839,7 @@},"packages/pieces/community/google-contacts": {"name": "@activepieces/piece-google-contacts",- "version": "0.5.1",+ "version": "0.5.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3855,7 +3855,7 @@},"packages/pieces/community/google-docs": {"name": "@activepieces/piece-google-docs",- "version": "0.5.1",+ "version": "0.5.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3873,7 +3873,7 @@},"packages/pieces/community/google-drive": {"name": "@activepieces/piece-google-drive",- "version": "0.11.0",+ "version": "0.11.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3894,7 +3894,7 @@},"packages/pieces/community/google-forms": {"name": "@activepieces/piece-google-forms",- "version": "0.6.0",+ "version": "0.6.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3909,7 +3909,7 @@},"packages/pieces/community/google-gemini": {"name": "@activepieces/piece-google-gemini",- "version": "0.4.0",+ "version": "0.4.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3929,7 +3929,7 @@},"packages/pieces/community/google-my-business": {"name": "@activepieces/piece-google-my-business",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4228,7 +4228,7 @@},"packages/pieces/community/hackernews": {"name": "@activepieces/piece-hackernews",- "version": "0.4.7",+ "version": "0.5.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/packages/pieces/community/hackernews/package.json b/packages/pieces/community/hackernews/package.jsonindex cb0ca85d340..eeb7fab9b3a 100644--- a/packages/pieces/community/hackernews/package.json+++ b/packages/pieces/community/hackernews/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-hackernews",- "version": "0.4.7",+ "version": "0.5.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {diff --git a/packages/pieces/community/hackernews/src/i18n/translation.json b/packages/pieces/community/hackernews/src/i18n/translation.jsonindex ed623004b7b..2af9fa7f6cc 100644--- a/packages/pieces/community/hackernews/src/i18n/translation.json+++ b/packages/pieces/community/hackernews/src/i18n/translation.json@@ -1,6 +1,55 @@{"A social news website": "A social news website","Fetch Top Stories": "Fetch Top Stories",+ "List Top Stories": "List Top Stories",+ "List New Stories": "List New Stories",+ "List Best Stories": "List Best Stories",+ "List Ask Stories": "List Ask Stories",+ "List Show Stories": "List Show Stories",+ "List Job Stories": "List Job Stories",+ "Get Item": "Get Item",+ "Get Max Item ID": "Get Max Item ID",+ "Get Updates": "Get Updates",+ "Get User": "Get User",+ "Custom API Call": "Custom API Call","Fetch top stories from hackernews": "Fetch top stories from hackernews",- "Number of Stories": "Number of Stories"+ "Lists the stories on the Hacker News front page, with full details.": "Lists the stories on the Hacker News front page, with full details.",+ "Lists the newest Hacker News stories, with full details.": "Lists the newest Hacker News stories, with full details.",+ "Lists the best recent Hacker News stories, with full details.": "Lists the best recent Hacker News stories, with full details.",+ "Lists the latest Ask HN posts, with full details.": "Lists the latest Ask HN posts, with full details.",+ "Lists the latest Show HN posts, with full details.": "Lists the latest Show HN posts, with full details.",+ "Lists the latest Hacker News job posts, with full details.": "Lists the latest Hacker News job posts, with full details.",+ "Gets a Hacker News story, comment, job, poll or poll option by its id.": "Gets a Hacker News story, comment, job, poll or poll option by its id.",+ "Gets the id of the newest item on Hacker News.": "Gets the id of the newest item on Hacker News.",+ "Gets the items and user profiles that changed recently on Hacker News.": "Gets the items and user profiles that changed recently on Hacker News.",+ "Gets a Hacker News user profile by username.": "Gets a Hacker News user profile by username.",+ "Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",+ "Number of Stories": "Number of Stories",+ "Limit": "Limit",+ "Item ID": "Item ID",+ "Username": "Username",+ "Method": "Method",+ "Headers": "Headers",+ "Query Parameters": "Query Parameters",+ "Body Type": "Body Type",+ "Body": "Body",+ "Response is Binary": "Response is Binary",+ "Return Error as Output": "Return Error as Output",+ "Timeout": "Timeout",+ "Follow redirects": "Follow redirects",+ "How many stories to return, from the top of the list (1-100). Defaults to 10.": "How many stories to return, from the top of the list (1-100). Defaults to 10.",+ "The numeric id of the item, e.g. 8863.": "The numeric id of the item, e.g. 8863.",+ "The case-sensitive Hacker News username, e.g. \"pg\".": "The case-sensitive Hacker News username, e.g. \"pg\".",+ "Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",+ "Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.",+ "Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",+ "On a failed request, output the error instead of failing the step.": "On a failed request, output the error instead of failing the step.",+ "Seconds to wait for a response. Empty: up to the flow limit (10 min).": "Seconds to wait for a response. Empty: up to the flow limit (10 min).",+ "Follow 3xx redirects instead of returning them as the response.": "Follow 3xx redirects instead of returning them as the response.",+ "GET": "GET",+ "POST": "POST",+ "PATCH": "PATCH",+ "PUT": "PUT",+ "DELETE": "DELETE",+ "HEAD": "HEAD"}\ No newline at end of filediff --git a/packages/pieces/community/hackernews/src/index.ts b/packages/pieces/community/hackernews/src/index.tsindex 2ad943b5765..bdfd60a8836 100644--- a/packages/pieces/community/hackernews/src/index.ts+++ b/packages/pieces/community/hackernews/src/index.ts@@ -1,15 +1,25 @@+import { createCustomApiCallAction } from '@activepieces/pieces-common';import { PieceAuth, createPiece } from '@activepieces/pieces-framework';-import { fetchTopStories } from './lib/actions/top-stories-in-hacker-news';++import { hackernewsAiActions } from './lib/actions/ai';+import { fetchTopStoriesAction } from './lib/actions/fetch-top-stories';+import { hackernewsClient } from './lib/common/client';export const hackernews = createPiece({- displayName: 'Hacker News',- description: 'A social news website',+ displayName: 'Hacker News',+ description: 'A social news website',- minimumSupportedRelease: '0.30.0',- logoUrl: 'https://cdn.activepieces.com/pieces/hackernews.png',- auth: PieceAuth.None(),- categories: [],- authors: ["kishanprmr","AbdulTheActivePiecer","khaledmashaly","abuaboud"],- actions: [fetchTopStories],- triggers: [],+ minimumSupportedRelease: '0.88.2',+ logoUrl: 'https://cdn.activepieces.com/pieces/hackernews.png',+ auth: PieceAuth.None(),+ categories: [],+ authors: ['kishanprmr', 'AbdulTheActivePiecer', 'khaledmashaly', 'abuaboud'],+ actions: [+ fetchTopStoriesAction,+ ...hackernewsAiActions,+ createCustomApiCallAction({+ baseUrl: () => hackernewsClient.baseUrl(),+ }),+ ],+ triggers: [],});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/get-item.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/get-item.tsnew file mode 100644index 00000000000..3fd9c31cc13--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/get-item.ts@@ -0,0 +1,28 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { hackernewsApi } from '../../common/api';+import { hackernewsGetItemOutputSchema } from '../../output-schemas';++export const getItemAction = createAction({+ name: 'hackernews_get_item',+ outputSchema: hackernewsGetItemOutputSchema,+ displayName: 'Get Item',+ description: 'Gets a Hacker News story, comment, job, poll or poll option by its id.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Fetches one Hacker News item (story, comment, job, poll or poll option) by its numeric id. Ids come from the List … Stories actions, from kid_ids / parent_id of another item, from Get User, or from Get Updates. To read a discussion, call this on the ids in kid_ids; it does not return nested comments.',+ idempotent: true,+ },+ props: {+ itemId: Property.Number({+ displayName: 'Item ID',+ description: 'The numeric id of the item, e.g. 8863.',+ required: true,+ }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.findItem({ itemId: propsValue.itemId });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/get-max-item-id.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/get-max-item-id.tsnew file mode 100644index 00000000000..cb313793c3a--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/get-max-item-id.ts@@ -0,0 +1,22 @@+import { createAction } from '@activepieces/pieces-framework';++import { hackernewsApi } from '../../common/api';+import { hackernewsGetMaxItemIdOutputSchema } from '../../output-schemas';++export const getMaxItemIdAction = createAction({+ name: 'hackernews_get_max_item_id',+ outputSchema: hackernewsGetMaxItemIdOutputSchema,+ displayName: 'Get Max Item ID',+ description: 'Gets the id of the newest item on Hacker News.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Returns the largest item id on Hacker News, i.e. the most recently created story, comment or job. Item ids are sequential, so counting down from this id walks every new item; pass an id to Get Item to read it.',+ idempotent: true,+ },+ props: {},+ async run() {+ return await hackernewsApi.getMaxItemId();+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/get-updates.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/get-updates.tsnew file mode 100644index 00000000000..b3d3917aed2--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/get-updates.ts@@ -0,0 +1,22 @@+import { createAction } from '@activepieces/pieces-framework';++import { hackernewsApi } from '../../common/api';+import { hackernewsGetUpdatesOutputSchema } from '../../output-schemas';++export const getUpdatesAction = createAction({+ name: 'hackernews_get_updates',+ outputSchema: hackernewsGetUpdatesOutputSchema,+ displayName: 'Get Updates',+ description: 'Gets the items and user profiles that changed recently on Hacker News.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the ids of recently changed items and the usernames of recently changed profiles on Hacker News. Use it to monitor activity; pass the ids to Get Item and the usernames to Get User for details.',+ idempotent: true,+ },+ props: {},+ async run() {+ return await hackernewsApi.getUpdates();+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/get-user.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/get-user.tsnew file mode 100644index 00000000000..0596f15c948--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/get-user.ts@@ -0,0 +1,28 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { hackernewsApi } from '../../common/api';+import { hackernewsGetUserOutputSchema } from '../../output-schemas';++export const getUserAction = createAction({+ name: 'hackernews_get_user',+ outputSchema: hackernewsGetUserOutputSchema,+ displayName: 'Get User',+ description: 'Gets a Hacker News user profile by username.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Fetches a Hacker News user profile: karma, about text, signup date and their most recent submission ids (up to 100, newest first, with the full count). Usernames are case-sensitive and come from the author field of an item. Only users with public activity exist.',+ idempotent: true,+ },+ props: {+ username: Property.ShortText({+ displayName: 'Username',+ description: 'The case-sensitive Hacker News username, e.g. "pg".',+ required: true,+ }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.getUser({ username: propsValue.username });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/index.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/index.tsnew file mode 100644index 00000000000..84eabf53a9e--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/index.ts@@ -0,0 +1,23 @@+import { getItemAction } from './get-item';+import { getMaxItemIdAction } from './get-max-item-id';+import { getUpdatesAction } from './get-updates';+import { getUserAction } from './get-user';+import { listAskStoriesAction } from './list-ask-stories';+import { listBestStoriesAction } from './list-best-stories';+import { listJobStoriesAction } from './list-job-stories';+import { listNewStoriesAction } from './list-new-stories';+import { listShowStoriesAction } from './list-show-stories';+import { listTopStoriesAction } from './list-top-stories';++export const hackernewsAiActions = [+ listTopStoriesAction,+ listNewStoriesAction,+ listBestStoriesAction,+ listAskStoriesAction,+ listShowStoriesAction,+ listJobStoriesAction,+ getItemAction,+ getMaxItemIdAction,+ getUpdatesAction,+ getUserAction,+];diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/list-ask-stories.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/list-ask-stories.tsnew file mode 100644index 00000000000..1930277259f--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/list-ask-stories.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { hackernewsAiProps } from '../../common/ai-props';+import { hackernewsApi } from '../../common/api';+import { hackernewsListStoriesOutputSchema } from '../../output-schemas';++export const listAskStoriesAction = createAction({+ name: 'hackernews_list_ask_stories',+ outputSchema: hackernewsListStoriesOutputSchema,+ displayName: 'List Ask Stories',+ description: 'Lists the latest Ask HN posts, with full details.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the latest Ask HN posts (up to 200), with full details for the first `limit` stories (default 10, max 100). Use for community questions; the question body is in text. Use Get Item with a story id from here to read a single story again later.',+ idempotent: true,+ },+ props: {+ limit: hackernewsAiProps.limit({ required: false }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.listStories({ storyList: 'ask', limit: propsValue.limit });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/list-best-stories.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/list-best-stories.tsnew file mode 100644index 00000000000..f6cd49026f6--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/list-best-stories.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { hackernewsAiProps } from '../../common/ai-props';+import { hackernewsApi } from '../../common/api';+import { hackernewsListStoriesOutputSchema } from '../../output-schemas';++export const listBestStoriesAction = createAction({+ name: 'hackernews_list_best_stories',+ outputSchema: hackernewsListStoriesOutputSchema,+ displayName: 'List Best Stories',+ description: 'Lists the best recent Hacker News stories, with full details.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the highest-voted recent Hacker News stories (up to 500), with full details for the first `limit` stories (default 10, max 100). Use for the strongest recent stories rather than the live front page. Use Get Item with a story id from here to read a single story again later.',+ idempotent: true,+ },+ props: {+ limit: hackernewsAiProps.limit({ required: false }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.listStories({ storyList: 'best', limit: propsValue.limit });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/list-job-stories.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/list-job-stories.tsnew file mode 100644index 00000000000..2d7d1c37976--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/list-job-stories.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { hackernewsAiProps } from '../../common/ai-props';+import { hackernewsApi } from '../../common/api';+import { hackernewsListStoriesOutputSchema } from '../../output-schemas';++export const listJobStoriesAction = createAction({+ name: 'hackernews_list_job_stories',+ outputSchema: hackernewsListStoriesOutputSchema,+ displayName: 'List Job Stories',+ description: 'Lists the latest Hacker News job posts, with full details.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the latest job posts from YC companies (up to 200), with full details for the first `limit` stories (default 10, max 100). Use to find hiring posts; most have a url or a text body, not comments. Use Get Item with a story id from here to read a single story again later.',+ idempotent: true,+ },+ props: {+ limit: hackernewsAiProps.limit({ required: false }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.listStories({ storyList: 'job', limit: propsValue.limit });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/list-new-stories.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/list-new-stories.tsnew file mode 100644index 00000000000..84c339e7afa--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/list-new-stories.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { hackernewsAiProps } from '../../common/ai-props';+import { hackernewsApi } from '../../common/api';+import { hackernewsListStoriesOutputSchema } from '../../output-schemas';++export const listNewStoriesAction = createAction({+ name: 'hackernews_list_new_stories',+ outputSchema: hackernewsListStoriesOutputSchema,+ displayName: 'List New Stories',+ description: 'Lists the newest Hacker News stories, with full details.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the newest Hacker News stories, newest first (up to 500), with full details for the first `limit` stories (default 10, max 100). Use to see what was just submitted, before it is ranked. Use Get Item with a story id from here to read a single story again later.',+ idempotent: true,+ },+ props: {+ limit: hackernewsAiProps.limit({ required: false }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.listStories({ storyList: 'new', limit: propsValue.limit });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/list-show-stories.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/list-show-stories.tsnew file mode 100644index 00000000000..205a0a43b8b--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/list-show-stories.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { hackernewsAiProps } from '../../common/ai-props';+import { hackernewsApi } from '../../common/api';+import { hackernewsListStoriesOutputSchema } from '../../output-schemas';++export const listShowStoriesAction = createAction({+ name: 'hackernews_list_show_stories',+ outputSchema: hackernewsListStoriesOutputSchema,+ displayName: 'List Show Stories',+ description: 'Lists the latest Show HN posts, with full details.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the latest Show HN posts (up to 200), with full details for the first `limit` stories (default 10, max 100). Use for projects people are launching or demoing. Use Get Item with a story id from here to read a single story again later.',+ idempotent: true,+ },+ props: {+ limit: hackernewsAiProps.limit({ required: false }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.listStories({ storyList: 'show', limit: propsValue.limit });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/ai/list-top-stories.ts b/packages/pieces/community/hackernews/src/lib/actions/ai/list-top-stories.tsnew file mode 100644index 00000000000..4d3395c7563--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/ai/list-top-stories.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { hackernewsAiProps } from '../../common/ai-props';+import { hackernewsApi } from '../../common/api';+import { hackernewsListStoriesOutputSchema } from '../../output-schemas';++export const listTopStoriesAction = createAction({+ name: 'hackernews_list_top_stories',+ outputSchema: hackernewsListStoriesOutputSchema,+ displayName: 'List Top Stories',+ description: 'Lists the stories on the Hacker News front page, with full details.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the current Hacker News front-page ranking (up to 500 ranked stories, including job posts), with full details for the first `limit` stories (default 10, max 100). Use for "what is trending on Hacker News now". Use Get Item with a story id from here to read a single story again later.',+ idempotent: true,+ },+ props: {+ limit: hackernewsAiProps.limit({ required: false }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.listStories({ storyList: 'top', limit: propsValue.limit });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/fetch-top-stories.ts b/packages/pieces/community/hackernews/src/lib/actions/fetch-top-stories.tsnew file mode 100644index 00000000000..ae68fde916d--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/actions/fetch-top-stories.ts@@ -0,0 +1,28 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { hackernewsApi } from '../common/api';+import { fetchTopStoriesOutputSchema } from '../output-schemas';++export const fetchTopStoriesAction = createAction({+ name: 'fetch_top_stories',+ outputSchema: fetchTopStoriesOutputSchema,+ classification: 'SEARCH',+ displayName: 'Fetch Top Stories',+ description: 'Fetch top stories from hackernews',+ audience: 'human',+ aiMetadata: {+ description:+ 'Retrieves the current top stories from Hacker News, returning the first N stories (N set by the number-of-stories input) with their full item details. Use to surface or summarize what is trending on Hacker News right now. Read-only and idempotent; a larger N simply fetches more of the same ranked list.',+ idempotent: true,+ },+ props: {+ number_of_stories: Property.Number({+ displayName: 'Number of Stories',+ description: undefined,+ required: true,+ }),+ },+ async run({ propsValue }) {+ return await hackernewsApi.listTopStories({ limit: propsValue.number_of_stories });+ },+});diff --git a/packages/pieces/community/hackernews/src/lib/actions/top-stories-in-hacker-news.ts b/packages/pieces/community/hackernews/src/lib/actions/top-stories-in-hacker-news.tsdeleted file mode 100644index e2e005d32ae..00000000000--- a/packages/pieces/community/hackernews/src/lib/actions/top-stories-in-hacker-news.ts+++ /dev/null@@ -1,45 +0,0 @@-import { createAction, Property } from '@activepieces/pieces-framework';-import { httpClient, HttpMethod } from '@activepieces/pieces-common';--export const fetchTopStories = createAction({- name: 'fetch_top_stories', // Must be a unique across the piece, this shouldn't be changed.- classification: 'SEARCH',- displayName: 'Fetch Top Stories',- description: 'Fetch top stories from hackernews',- audience: 'both',- aiMetadata: {- description: 'Retrieves the current top stories from Hacker News, returning the first N stories (N set by the number-of-stories input) with their full item details. Use to surface or summarize what is trending on Hacker News right now. Read-only and idempotent; a larger N simply fetches more of the same ranked list.',- idempotent: true,- },- props: {- // Properties to ask from the user, in this ask we will take number of- number_of_stories: Property.Number({- displayName: 'Number of Stories',- description: undefined,- required: true,- }),- },- async run(configValue) {- const HACKER_NEWS_API_URL = 'https://hacker-news.firebaseio.com/v0/';- const topStoryIdsResponse = await httpClient.sendRequest<string[]>({- method: HttpMethod.GET,- url: `${HACKER_NEWS_API_URL}topstories.json`,- });- const topStoryIds: string[] = topStoryIdsResponse.body;- const topStories: Record<string, unknown>[] = [];- for (- let i = 0;- i <- Math.min(configValue.propsValue['number_of_stories'], topStoryIds.length);- i++- ) {- const storyId = topStoryIds[i];- const storyResponse = await httpClient.sendRequest({- method: HttpMethod.GET,- url: `${HACKER_NEWS_API_URL}item/${storyId}.json`,- });- topStories.push(storyResponse.body);- }- return topStories;- },-});\ No newline at end of filediff --git a/packages/pieces/community/hackernews/src/lib/common/ai-props.ts b/packages/pieces/community/hackernews/src/lib/common/ai-props.tsnew file mode 100644index 00000000000..7d15f96c3a5--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/common/ai-props.ts@@ -0,0 +1,13 @@+import { Property } from '@activepieces/pieces-framework';++function limit<R extends boolean>({+ required,+ displayName = 'Limit',+ description = 'How many stories to return, from the top of the list (1-100). Defaults to 10.',+}: PropParams<R>) {+ return Property.Number({ displayName, description, required });+}++export const hackernewsAiProps = { limit };++type PropParams<R extends boolean> = { required: R; displayName?: string; description?: string };diff --git a/packages/pieces/community/hackernews/src/lib/common/api.ts b/packages/pieces/community/hackernews/src/lib/common/api.tsnew file mode 100644index 00000000000..b491a1549d4--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/common/api.ts@@ -0,0 +1,169 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { chunk } from '@activepieces/pieces-framework';++import { hackernewsClient } from './client';++import type {+ HackernewsItem,+ HackernewsNormalizedItem,+ HackernewsNormalizedUser,+ HackernewsStoryList,+ HackernewsUpdates,+ HackernewsUser,+} from './types';++async function listStoryIds({ storyList }: { storyList: HackernewsStoryList }): Promise<number[]> {+ return await hackernewsClient.request<number[]>({+ method: HttpMethod.GET,+ path: `/${storyList}stories.json`,+ });+}++async function getItem({ itemId }: { itemId: number }): Promise<HackernewsItem | null> {+ return await hackernewsClient.request<HackernewsItem | null>({+ method: HttpMethod.GET,+ path: `/item/${itemId}.json`,+ });+}++async function listTopStories({ limit }: { limit: number }): Promise<(HackernewsItem | null)[]> {+ const topStoryIds = await listStoryIds({ storyList: 'top' });+ const stories: (HackernewsItem | null)[] = [];+ for (let i = 0; i < Math.min(limit, topStoryIds.length); i++) {+ stories.push(await getItem({ itemId: topStoryIds[i] }));+ }+ return stories;+}++async function listStories({+ storyList,+ limit,+}: {+ storyList: HackernewsStoryList;+ limit: number | undefined;+}): Promise<{ stories: HackernewsNormalizedItem[]; count: number }> {+ const resolvedLimit = resolveLimit({ limit });+ const storyIds = await listStoryIds({ storyList });+ const items: (HackernewsItem | null)[] = [];+ for (const batch of chunk(storyIds.slice(0, resolvedLimit), ITEM_BATCH_SIZE)) {+ items.push(...(await Promise.all(batch.map(async (itemId) => await getItem({ itemId })))));+ }+ const stories = items+ .filter((item): item is HackernewsItem => item !== null)+ .map((item) => normalizeItem({ item }));+ return { stories, count: stories.length };+}++async function findItem({ itemId }: { itemId: number }): Promise<HackernewsNormalizedItem> {+ const item = await getItem({ itemId: resolveId({ id: itemId, label: 'Item ID' }) });+ if (item === null) {+ throw new Error(`Hacker News item ${itemId} was not found.`);+ }+ return normalizeItem({ item });+}++async function getUser({ username }: { username: string }): Promise<HackernewsNormalizedUser> {+ const trimmed = username.trim();+ if (trimmed.length === 0) {+ throw new Error('Username is required.');+ }+ const user = await hackernewsClient.request<HackernewsUser | null>({+ method: HttpMethod.GET,+ path: `/user/${encodeURIComponent(trimmed)}.json`,+ });+ if (user === null) {+ throw new Error(`Hacker News user "${trimmed}" was not found. Usernames are case-sensitive.`);+ }+ const submitted = user.submitted ?? [];+ return {+ username: user.id,+ karma: user.karma,+ about: user.about ?? null,+ created_at: new Date(user.created * 1000).toISOString(),+ created: user.created,+ submitted_count: submitted.length,+ recent_submission_ids: submitted.slice(0, MAX_SUBMISSION_IDS),+ hn_url: `https://news.ycombinator.com/user?id=${encodeURIComponent(user.id)}`,+ };+}++async function getMaxItemId(): Promise<{ max_item_id: number }> {+ const maxItemId = await hackernewsClient.request<number>({+ method: HttpMethod.GET,+ path: '/maxitem.json',+ });+ return { max_item_id: maxItemId };+}++async function getUpdates(): Promise<{+ item_ids: number[];+ profiles: string[];+ item_count: number;+ profile_count: number;+}> {+ const updates = await hackernewsClient.request<HackernewsUpdates>({+ method: HttpMethod.GET,+ path: '/updates.json',+ });+ return {+ item_ids: updates.items,+ profiles: updates.profiles,+ item_count: updates.items.length,+ profile_count: updates.profiles.length,+ };+}++function normalizeItem({ item }: { item: HackernewsItem }): HackernewsNormalizedItem {+ return {+ id: item.id,+ type: item.type ?? null,+ title: item.title ?? null,+ url: item.url ?? null,+ text: item.text ?? null,+ author: item.by ?? null,+ score: item.score ?? null,+ comment_count: item.descendants ?? null,+ created_at: item.time === undefined ? null : new Date(item.time * 1000).toISOString(),+ time: item.time ?? null,+ parent_id: item.parent ?? null,+ poll_id: item.poll ?? null,+ kid_ids: item.kids ?? [],+ part_ids: item.parts ?? [],+ dead: item.dead ?? false,+ deleted: item.deleted ?? false,+ hn_url: `https://news.ycombinator.com/item?id=${item.id}`,+ };+}++function resolveLimit({ limit }: { limit: number | undefined }): number {+ if (limit === undefined || limit === null) {+ return DEFAULT_LIMIT;+ }+ if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {+ throw new Error(`Limit must be a whole number between 1 and ${MAX_LIMIT}.`);+ }+ return limit;+}++function resolveId({ id, label }: { id: number; label: string }): number {+ if (!Number.isInteger(id) || id < 1) {+ throw new Error(`${label} must be a positive whole number.`);+ }+ return id;+}++export const hackernewsApi = {+ listStoryIds,+ getItem,+ listTopStories,+ listStories,+ findItem,+ getUser,+ getMaxItemId,+ getUpdates,+};++const DEFAULT_LIMIT = 10;+const MAX_LIMIT = 100;+const MAX_SUBMISSION_IDS = 100;+const ITEM_BATCH_SIZE = 10;diff --git a/packages/pieces/community/hackernews/src/lib/common/client.ts b/packages/pieces/community/hackernews/src/lib/common/client.tsnew file mode 100644index 00000000000..e9f96218bb0--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/common/client.ts@@ -0,0 +1,17 @@+import { HttpMethod, httpClient } from '@activepieces/pieces-common';++function baseUrl(): string {+ return 'https://hacker-news.firebaseio.com/v0';+}++async function request<T>({ method, path }: RequestParams): Promise<T> {+ const response = await httpClient.sendRequest<T>({+ method,+ url: `${baseUrl()}${path}`,+ });+ return response.body;+}++export const hackernewsClient = { baseUrl, request };++type RequestParams = { method: HttpMethod; path: string };diff --git a/packages/pieces/community/hackernews/src/lib/common/types.ts b/packages/pieces/community/hackernews/src/lib/common/types.tsnew file mode 100644index 00000000000..da26d4c26ca--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/common/types.ts@@ -0,0 +1,63 @@+export type HackernewsItem = {+ id: number;+ deleted?: boolean;+ type?: 'job' | 'story' | 'comment' | 'poll' | 'pollopt';+ by?: string;+ time?: number;+ text?: string;+ dead?: boolean;+ parent?: number;+ poll?: number;+ kids?: number[];+ url?: string;+ score?: number;+ title?: string;+ parts?: number[];+ descendants?: number;+};++export type HackernewsUser = {+ id: string;+ created: number;+ karma: number;+ about?: string;+ submitted?: number[];+};++export type HackernewsUpdates = {+ items: number[];+ profiles: string[];+};++export type HackernewsStoryList = 'top' | 'new' | 'best' | 'ask' | 'show' | 'job';++export type HackernewsNormalizedItem = {+ id: number;+ type: string | null;+ title: string | null;+ url: string | null;+ text: string | null;+ author: string | null;+ score: number | null;+ comment_count: number | null;+ created_at: string | null;+ time: number | null;+ parent_id: number | null;+ poll_id: number | null;+ kid_ids: number[];+ part_ids: number[];+ dead: boolean;+ deleted: boolean;+ hn_url: string;+};++export type HackernewsNormalizedUser = {+ username: string;+ karma: number;+ about: string | null;+ created_at: string;+ created: number;+ submitted_count: number;+ recent_submission_ids: number[];+ hn_url: string;+};diff --git a/packages/pieces/community/hackernews/src/lib/output-schemas.ts b/packages/pieces/community/hackernews/src/lib/output-schemas.tsnew file mode 100644index 00000000000..1ead5209114--- /dev/null+++ b/packages/pieces/community/hackernews/src/lib/output-schemas.ts@@ -0,0 +1,80 @@+import { OutputSchema } from '@activepieces/pieces-framework';++const itemFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Item ID', format: 'number' },+ { key: 'type', label: 'Type' },+ { key: 'title', label: 'Title' },+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'text', label: 'Text', format: 'html' },+ { key: 'author', label: 'Author' },+ { key: 'score', label: 'Score', format: 'number' },+ { key: 'comment_count', label: 'Comment Count', format: 'number' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'time', label: 'Created (Unix Time)', format: 'number' },+ { key: 'parent_id', label: 'Parent ID', format: 'number' },+ { key: 'poll_id', label: 'Poll ID', format: 'number' },+ { key: 'kid_ids', label: 'Comment IDs' },+ { key: 'part_ids', label: 'Poll Option IDs' },+ { key: 'dead', label: 'Dead', format: 'boolean' },+ { key: 'deleted', label: 'Deleted', format: 'boolean' },+ { key: 'hn_url', label: 'Hacker News URL', format: 'url' },+];++export const hackernewsListStoriesOutputSchema: OutputSchema = {+ fields: [+ { key: 'stories', label: 'Stories', labelKey: 'title', listItems: itemFields },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const hackernewsGetItemOutputSchema: OutputSchema = {+ fields: itemFields,+};++export const hackernewsGetUserOutputSchema: OutputSchema = {+ fields: [+ { key: 'username', label: 'Username' },+ { key: 'karma', label: 'Karma', format: 'number' },+ { key: 'about', label: 'About', format: 'html' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'created', label: 'Created (Unix Time)', format: 'number' },+ { key: 'submitted_count', label: 'Submission Count', format: 'number' },+ { key: 'recent_submission_ids', label: 'Recent Submission IDs' },+ { key: 'hn_url', label: 'Hacker News URL', format: 'url' },+ ],+};++export const hackernewsGetMaxItemIdOutputSchema: OutputSchema = {+ fields: [{ key: 'max_item_id', label: 'Max Item ID', format: 'number' }],+};++export const hackernewsGetUpdatesOutputSchema: OutputSchema = {+ fields: [+ { key: 'item_ids', label: 'Changed Item IDs' },+ { key: 'profiles', label: 'Changed Usernames' },+ { key: 'item_count', label: 'Changed Item Count', format: 'number' },+ { key: 'profile_count', label: 'Changed Profile Count', format: 'number' },+ ],+};++export const fetchTopStoriesOutputSchema: OutputSchema = {+ itemLabel: '{title}',+ fields: [+ {+ key: 'stories',+ label: 'Stories',+ value: '',+ listItems: [+ { key: 'id', label: 'Item ID', format: 'number' },+ { key: 'type', label: 'Type' },+ { key: 'title', label: 'Title' },+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'by', label: 'Author' },+ { key: 'score', label: 'Score', format: 'number' },+ { key: 'descendants', label: 'Comment Count', format: 'number' },+ { key: 'time', label: 'Created (Unix Time)', format: 'number' },+ { key: 'kids', label: 'Comment IDs' },+ ],+ },+ ],+};