Skip to content

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

feat(pieces): add AI agent atomics for apitable and claude (#15703)

Kishan Parmar47bb91b64d17
diff --git a/bun.lock b/bun.lock
index 2051d39bfcc..6186e2d4138 100644
--- a/bun.lock
+++ b/bun.lock
@@ -697,13 +697,14 @@
},
"packages/pieces/community/apitable": {
"name": "@activepieces/piece-apitable",
- "version": "0.2.0",
+ "version": "0.3.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
"@activepieces/pieces-common": "workspace:*",
"@activepieces/pieces-framework": "workspace:*",
"dayjs": "1.11.9",
+ "form-data": "4.0.6",
},
"devDependencies": {
"tslib": "2.6.2",
@@ -1862,7 +1863,7 @@
},
"packages/pieces/community/claude": {
"name": "@activepieces/piece-claude",
- "version": "0.5.0",
+ "version": "0.6.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/apitable/package.json b/packages/pieces/community/apitable/package.json
index 95ae7eb7768..30b352842c9 100644
--- a/packages/pieces/community/apitable/package.json
+++ b/packages/pieces/community/apitable/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-apitable",
- "version": "0.2.0",
+ "version": "0.3.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
@@ -12,6 +12,7 @@
"@activepieces/pieces-common": "workspace:*",
"@activepieces/pieces-framework": "workspace:*",
"dayjs": "1.11.9",
+ "form-data": "4.0.6",
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*"
},
diff --git a/packages/pieces/community/apitable/src/index.ts b/packages/pieces/community/apitable/src/index.ts
index 92fc9d8d588..2faa0d9c74d 100644
--- a/packages/pieces/community/apitable/src/index.ts
+++ b/packages/pieces/community/apitable/src/index.ts
@@ -9,6 +9,14 @@ import { PieceCategory } from '@activepieces/pieces-framework';
import { createRecordAction } from './lib/actions/create-record';
import { findRecordAction } from './lib/actions/find-record';
import { updateRecordAction } from './lib/actions/update-record';
+import { deleteRecordAction } from './lib/actions/delete-record';
+import { listSpacesAction } from './lib/actions/list-spaces';
+import { listDatasheetsAction } from './lib/actions/list-datasheets';
+import { getDatasheetFieldsAction } from './lib/actions/get-datasheet-fields';
+import { listViewsAction } from './lib/actions/list-views';
+import { uploadAttachmentAction } from './lib/actions/upload-attachment';
+import { searchNodesAction } from './lib/actions/search-nodes';
+import { getNodeDetailsAction } from './lib/actions/get-node-details';
import { newRecordTrigger } from './lib/triggers/new-record';
import { makeClient } from './lib/common';
import { APITableAuth } from './lib/auth';
@@ -17,7 +25,7 @@ export const apitable = createPiece({
displayName: 'AITable',
auth: APITableAuth,
description: `Interactive spreadsheets with collaboration`,
- minimumSupportedRelease: '0.30.0',
+ minimumSupportedRelease: '0.87.0',
logoUrl: 'https://cdn.activepieces.com/pieces/apitable.png',
categories: [PieceCategory.PRODUCTIVITY],
authors: [
@@ -31,6 +39,14 @@ export const apitable = createPiece({
createRecordAction,
updateRecordAction,
findRecordAction,
+ deleteRecordAction,
+ listSpacesAction,
+ listDatasheetsAction,
+ getDatasheetFieldsAction,
+ listViewsAction,
+ uploadAttachmentAction,
+ searchNodesAction,
+ getNodeDetailsAction,
createCustomApiCallAction({
baseUrl: (auth) => {
return (auth?.props.apiTableUrl ?? '');
diff --git a/packages/pieces/community/apitable/src/lib/actions/create-record.ts b/packages/pieces/community/apitable/src/lib/actions/create-record.ts
index 2a4bf1b3e46..944c5fd9740 100644
--- a/packages/pieces/community/apitable/src/lib/actions/create-record.ts
+++ b/packages/pieces/community/apitable/src/lib/actions/create-record.ts
@@ -5,6 +5,7 @@ import {
} from '@activepieces/pieces-framework';
import { APITableCommon, createNewFields, makeClient } from '../common';
import { APITableAuth } from '../auth';
+import { createRecordActionOutputSchema } from '../output-schemas';
export const createRecordAction = createAction({
auth: APITableAuth,
@@ -23,6 +24,7 @@ export const createRecordAction = createAction({
datasheet_id: APITableCommon.datasheet_id,
fields: APITableCommon.fields,
},
+ outputSchema: createRecordActionOutputSchema,
async run(context) {
const auth = context.auth;
const datasheetId = context.propsValue.datasheet_id;
diff --git a/packages/pieces/community/apitable/src/lib/actions/delete-record.ts b/packages/pieces/community/apitable/src/lib/actions/delete-record.ts
new file mode 100644
index 00000000000..59cd0c88063
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/actions/delete-record.ts
@@ -0,0 +1,41 @@
+import { Property, createAction } from '@activepieces/pieces-framework';
+import { APITableCommon, makeClient } from '../common';
+import { APITableAuth } from '../auth';
+import { deleteRecordActionOutputSchema } from '../output-schemas';
+
+export const deleteRecordAction = createAction({
+ auth: APITableAuth,
+ name: 'apitable_delete_record',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Record',
+ description: 'Deletes one or more records from a datasheet.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes one or more records from an AITable datasheet by record ID; obtain the IDs from Find Records first. Use only when records should be removed entirely, not just updated. Not idempotent: retrying after a successful delete errors because the records no longer exist.',
+ idempotent: false,
+ },
+ props: {
+ space_id: APITableCommon.space_id,
+ datasheet_id: APITableCommon.datasheet_id,
+ recordIds: Property.Array({
+ displayName: 'Record IDs',
+ description: 'The IDs of the records to delete.',
+ required: true,
+ }),
+ },
+ outputSchema: deleteRecordActionOutputSchema,
+ async run(context) {
+ const datasheetId = context.propsValue.datasheet_id as string;
+ const recordIds = context.propsValue.recordIds as string[];
+
+ const client = makeClient(context.auth.props);
+ const response = await client.deleteRecords(datasheetId, recordIds);
+
+ if (!response.success) {
+ throw new Error(JSON.stringify(response, undefined, 2));
+ }
+
+ return response;
+ },
+});
diff --git a/packages/pieces/community/apitable/src/lib/actions/find-record.ts b/packages/pieces/community/apitable/src/lib/actions/find-record.ts
index a9a382ad7ab..c1b674ce0bf 100644
--- a/packages/pieces/community/apitable/src/lib/actions/find-record.ts
+++ b/packages/pieces/community/apitable/src/lib/actions/find-record.ts
@@ -6,6 +6,7 @@ import {
import { APITableCommon, makeClient } from '../common';
import { APITableAuth } from '../auth';
import { prepareQuery } from '../common/client';
+import { findRecordActionOutputSchema } from '../output-schemas';
export const findRecordAction = createAction({
auth: APITableAuth,
@@ -55,6 +56,7 @@ export const findRecordAction = createAction({
required: false,
}),
},
+ outputSchema: findRecordActionOutputSchema,
async run(context) {
const datasheetId = context.propsValue.datasheet_id;
const recordIds = context.propsValue.recordIds ?? []
diff --git a/packages/pieces/community/apitable/src/lib/actions/get-datasheet-fields.ts b/packages/pieces/community/apitable/src/lib/actions/get-datasheet-fields.ts
new file mode 100644
index 00000000000..6b6ff2e1392
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/actions/get-datasheet-fields.ts
@@ -0,0 +1,35 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { APITableCommon, makeClient } from '../common';
+import { APITableAuth } from '../auth';
+import { getDatasheetFieldsActionOutputSchema } from '../output-schemas';
+
+export const getDatasheetFieldsAction = createAction({
+ auth: APITableAuth,
+ name: 'apitable_get_datasheet_fields',
+ classification: 'READ',
+ displayName: 'Get Datasheet Fields',
+ description: 'Reads the field (column) definitions of a datasheet.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Reads the field (column) definitions of an AITable datasheet, including each field\'s name, type, and the option list for select/member fields. Use before creating or updating records to learn the valid field names and choices for that datasheet. Idempotent: it only reads data.',
+ idempotent: true,
+ },
+ props: {
+ space_id: APITableCommon.space_id,
+ datasheet_id: APITableCommon.datasheet_id,
+ },
+ outputSchema: getDatasheetFieldsActionOutputSchema,
+ async run(context) {
+ const client = makeClient(context.auth.props);
+ const response = await client.getDatasheetFields(
+ context.propsValue.datasheet_id as string
+ );
+
+ if (!response.success) {
+ throw new Error(JSON.stringify(response, undefined, 2));
+ }
+
+ return response;
+ },
+});
diff --git a/packages/pieces/community/apitable/src/lib/actions/get-node-details.ts b/packages/pieces/community/apitable/src/lib/actions/get-node-details.ts
new file mode 100644
index 00000000000..13ba734ff6a
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/actions/get-node-details.ts
@@ -0,0 +1,40 @@
+import { Property, createAction } from '@activepieces/pieces-framework';
+import { APITableCommon, makeClient } from '../common';
+import { APITableAuth } from '../auth';
+import { getNodeDetailsActionOutputSchema } from '../output-schemas';
+
+export const getNodeDetailsAction = createAction({
+ auth: APITableAuth,
+ name: 'apitable_get_node_details',
+ classification: 'READ',
+ displayName: 'Get Node Details',
+ description: 'Reads the details of a single file node, including its children.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Reads a single AITable node (datasheet, folder, form, dashboard, etc.) by ID, returning its name, type, and, for a folder, the child nodes inside it. Use to confirm a node\'s type or list a folder\'s contents; obtain the node ID from Search Nodes or List Datasheets. Idempotent: it only reads data.',
+ idempotent: true,
+ },
+ props: {
+ space_id: APITableCommon.space_id,
+ node_id: Property.ShortText({
+ displayName: 'Node ID',
+ description: 'The ID of the node to read.',
+ required: true,
+ }),
+ },
+ outputSchema: getNodeDetailsActionOutputSchema,
+ async run(context) {
+ const client = makeClient(context.auth.props);
+ const response = await client.getNodeDetails(
+ context.propsValue.space_id as string,
+ context.propsValue.node_id
+ );
+
+ if (!response.success) {
+ throw new Error(JSON.stringify(response, undefined, 2));
+ }
+
+ return response;
+ },
+});
diff --git a/packages/pieces/community/apitable/src/lib/actions/list-datasheets.ts b/packages/pieces/community/apitable/src/lib/actions/list-datasheets.ts
new file mode 100644
index 00000000000..f315ea3c32e
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/actions/list-datasheets.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { APITableCommon, makeClient } from '../common';
+import { APITableAuth } from '../auth';
+import { listDatasheetsActionOutputSchema } from '../output-schemas';
+
+export const listDatasheetsAction = createAction({
+ auth: APITableAuth,
+ name: 'apitable_list_datasheets',
+ classification: 'SEARCH',
+ displayName: 'List Datasheets',
+ description: 'Lists the datasheets available in a space.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the datasheets in an AITable space, returning each datasheet\'s ID and name. Use to discover a datasheet ID before creating, finding, updating, or deleting its records. Idempotent: it only reads data.',
+ idempotent: true,
+ },
+ props: {
+ space_id: APITableCommon.space_id,
+ },
+ outputSchema: listDatasheetsActionOutputSchema,
+ async run(context) {
+ const client = makeClient(context.auth.props);
+ const response = await client.listDatasheets(
+ context.propsValue.space_id as string
+ );
+
+ if (!response.success) {
+ throw new Error(JSON.stringify(response, undefined, 2));
+ }
+
+ return response;
+ },
+});
diff --git a/packages/pieces/community/apitable/src/lib/actions/list-spaces.ts b/packages/pieces/community/apitable/src/lib/actions/list-spaces.ts
new file mode 100644
index 00000000000..4f3674dab4c
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/actions/list-spaces.ts
@@ -0,0 +1,30 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { makeClient } from '../common';
+import { APITableAuth } from '../auth';
+import { listSpacesActionOutputSchema } from '../output-schemas';
+
+export const listSpacesAction = createAction({
+ auth: APITableAuth,
+ name: 'apitable_list_spaces',
+ classification: 'SEARCH',
+ displayName: 'List Spaces',
+ description: 'Lists the spaces available to the authenticated account.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists every space (workspace) the authenticated AITable account can access, returning each space\'s ID and name. Use to discover a space ID before listing its datasheets. Idempotent: it only reads data.',
+ idempotent: true,
+ },
+ props: {},
+ outputSchema: listSpacesActionOutputSchema,
+ async run(context) {
+ const client = makeClient(context.auth.props);
+ const response = await client.listSpaces();
+
+ if (!response.success) {
+ throw new Error(JSON.stringify(response, undefined, 2));
+ }
+
+ return response;
+ },
+});
diff --git a/packages/pieces/community/apitable/src/lib/actions/list-views.ts b/packages/pieces/community/apitable/src/lib/actions/list-views.ts
new file mode 100644
index 00000000000..25372ba73b7
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/actions/list-views.ts
@@ -0,0 +1,35 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { APITableCommon, makeClient } from '../common';
+import { APITableAuth } from '../auth';
+import { listViewsActionOutputSchema } from '../output-schemas';
+
+export const listViewsAction = createAction({
+ auth: APITableAuth,
+ name: 'apitable_list_views',
+ classification: 'SEARCH',
+ displayName: 'List Views',
+ description: 'Lists the views of a datasheet.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the views (Grid, Kanban, Gallery, etc.) of an AITable datasheet, returning each view\'s ID, name, and type. Use to discover a view ID to scope Find Records to that view\'s rows and sort order. Idempotent: it only reads data.',
+ idempotent: true,
+ },
+ props: {
+ space_id: APITableCommon.space_id,
+ datasheet_id: APITableCommon.datasheet_id,
+ },
+ outputSchema: listViewsActionOutputSchema,
+ async run(context) {
+ const client = makeClient(context.auth.props);
+ const response = await client.listViews(
+ context.propsValue.datasheet_id as string
+ );
+
+ if (!response.success) {
+ throw new Error(JSON.stringify(response, undefined, 2));
+ }
+
+ return response;
+ },
+});
diff --git a/packages/pieces/community/apitable/src/lib/actions/search-nodes.ts b/packages/pieces/community/apitable/src/lib/actions/search-nodes.ts
new file mode 100644
index 00000000000..4b0acb94b12
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/actions/search-nodes.ts
@@ -0,0 +1,58 @@
+import { Property, createAction } from '@activepieces/pieces-framework';
+import { APITableCommon, makeClient } from '../common';
+import { APITableAuth } from '../auth';
+import { searchNodesActionOutputSchema } from '../output-schemas';
+
+export const searchNodesAction = createAction({
+ auth: APITableAuth,
+ name: 'apitable_search_nodes',
+ classification: 'SEARCH',
+ displayName: 'Search Nodes',
+ description:
+ 'Searches the file nodes (datasheets, folders, forms, dashboards, etc.) in a space.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches every file node in an AITable space by type and/or name query, regardless of folder hierarchy; returns id, name, type and parent for each match. Use to find folders, forms, dashboards, or mirrors that List Datasheets does not surface since it only returns datasheets. Idempotent: it only reads data.',
+ idempotent: true,
+ },
+ props: {
+ space_id: APITableCommon.space_id,
+ type: Property.StaticDropdown({
+ displayName: 'Node Type',
+ description: 'The type of node to search for.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Datasheet', value: 'Datasheet' },
+ { label: 'Folder', value: 'Folder' },
+ { label: 'Form', value: 'Form' },
+ { label: 'Dashboard', value: 'Dashboard' },
+ { label: 'Mirror', value: 'Mirror' },
+ ],
+ },
+ }),
+ query: Property.ShortText({
+ displayName: 'Name Query',
+ description: 'Filter results to node names containing this text.',
+ required: false,
+ }),
+ },
+ outputSchema: searchNodesActionOutputSchema,
+ async run(context) {
+ const client = makeClient(context.auth.props);
+ const response = await client.searchNodes(
+ context.propsValue.space_id as string,
+ {
+ type: context.propsValue.type,
+ query: context.propsValue.query,
+ }
+ );
+
+ if (!response.success) {
+ throw new Error(JSON.stringify(response, undefined, 2));
+ }
+
+ return response;
+ },
+});
diff --git a/packages/pieces/community/apitable/src/lib/actions/update-record.ts b/packages/pieces/community/apitable/src/lib/actions/update-record.ts
index afe1023849c..e1dac94cb72 100644
--- a/packages/pieces/community/apitable/src/lib/actions/update-record.ts
+++ b/packages/pieces/community/apitable/src/lib/actions/update-record.ts
@@ -6,6 +6,7 @@ import {
} from '@activepieces/pieces-framework';
import { APITableCommon, createNewFields, makeClient } from '../common';
import { APITableAuth } from '../auth';
+import { updateRecordActionOutputSchema } from '../output-schemas';
export const updateRecordAction = createAction({
auth: APITableAuth,
@@ -29,6 +30,7 @@ export const updateRecordAction = createAction({
}),
fields: APITableCommon.fields,
},
+ outputSchema: updateRecordActionOutputSchema,
async run(context) {
const auth = context.auth;
const datasheetId = context.propsValue.datasheet_id;
diff --git a/packages/pieces/community/apitable/src/lib/actions/upload-attachment.ts b/packages/pieces/community/apitable/src/lib/actions/upload-attachment.ts
new file mode 100644
index 00000000000..9785b8c6306
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/actions/upload-attachment.ts
@@ -0,0 +1,45 @@
+import { Property, createAction } from '@activepieces/pieces-framework';
+import { APITableCommon, makeClient } from '../common';
+import { APITableAuth } from '../auth';
+import { uploadAttachmentActionOutputSchema } from '../output-schemas';
+
+export const uploadAttachmentAction = createAction({
+ auth: APITableAuth,
+ name: 'apitable_upload_attachment',
+ classification: 'WRITE',
+ displayName: 'Upload Attachment',
+ description: 'Uploads a file to a datasheet and returns its storage URL.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Uploads a single file to an AITable datasheet and returns its stored token and URL. Use to obtain the URL for a file before writing it into an Attachment field with Create Record or Update Record. Not idempotent: each call stores a new file, so repeating it duplicates the upload.',
+ idempotent: false,
+ },
+ props: {
+ space_id: APITableCommon.space_id,
+ datasheet_id: APITableCommon.datasheet_id,
+ file: Property.File({
+ displayName: 'File',
+ description: 'The file to upload.',
+ required: true,
+ }),
+ },
+ outputSchema: uploadAttachmentActionOutputSchema,
+ async run(context) {
+ const datasheetId = context.propsValue.datasheet_id as string;
+ const file = context.propsValue.file;
+
+ const client = makeClient(context.auth.props);
+ const response = await client.uploadAttachment(
+ datasheetId,
+ file.filename,
+ file.data
+ );
+
+ if (!response.success) {
+ throw new Error(JSON.stringify(response, undefined, 2));
+ }
+
+ return response;
+ },
+});
diff --git a/packages/pieces/community/apitable/src/lib/common/client.ts b/packages/pieces/community/apitable/src/lib/common/client.ts
index 8387a1792d3..a5d15ee4337 100644
--- a/packages/pieces/community/apitable/src/lib/common/client.ts
+++ b/packages/pieces/community/apitable/src/lib/common/client.ts
@@ -6,6 +6,7 @@ import {
httpClient,
} from '@activepieces/pieces-common';
import { AITableFieldType } from './constants';
+import FormData from 'form-data';
function emptyValueFilter(
accessor: (key: string) => any
@@ -20,6 +21,16 @@ function emptyValueFilter(
};
}
+type NodeSummary = {
+ id: string;
+ name: string;
+ type: string;
+ icon: string;
+ isFav: boolean;
+ permission: number;
+ parentId?: string;
+};
+
export function prepareQuery(request?: Record<string, any>): QueryParams {
const params: QueryParams = {};
if (!request) return params;
@@ -38,7 +49,8 @@ export class AITableClient {
method: HttpMethod,
resourceUri: string,
query?: QueryParams,
- body: any | undefined = undefined
+ body: any | undefined = undefined,
+ headers?: Record<string, string>
): Promise<T> {
const baseUrl = this.apiTableUrl.replace(/\/$/, '');
const res = await httpClient.sendRequest<T>({
@@ -50,45 +62,79 @@ export class AITableClient {
},
queryParams: query,
body: body,
+ headers: headers,
});
return res.body;
}
async listSpaces() {
return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
data: {
spaces: {
id: string;
name: string;
+ isAdmin: boolean;
}[];
};
}>(HttpMethod.GET, '/v1/spaces');
}
async listDatasheets(space_id: string) {
return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
data: {
- nodes: {
- id: string;
- name: string;
- }[];
+ nodes: NodeSummary[];
};
}>(HttpMethod.GET, `/v2/spaces/${space_id}/nodes`, { type: 'Datasheet' });
}
+ async searchNodes(
+ space_id: string,
+ query?: { type?: string; query?: string }
+ ) {
+ return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
+ data: {
+ nodes: NodeSummary[];
+ };
+ }>(HttpMethod.GET, `/v2/spaces/${space_id}/nodes`, prepareQuery(query));
+ }
+
+ async getNodeDetails(space_id: string, node_id: string) {
+ return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
+ data: NodeSummary & {
+ children?: NodeSummary[];
+ };
+ }>(HttpMethod.GET, `/v1/spaces/${space_id}/nodes/${node_id}`);
+ }
+
async getDatasheetFields(datasheet_id: string) {
return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
data: {
fields: {
id: string;
name: string;
type: AITableFieldType;
- desc: string;
+ editable: boolean;
+ isPrimary?: boolean;
property?: {
- format?: string;
defaultValue?: string;
options?: {
+ id: string;
name: string;
- id?: string;
+ color?: { name: string; value: string };
}[];
};
}[];
@@ -97,26 +143,43 @@ export class AITableClient {
}
async createRecord(datasheet_id: string, request: object) {
- return await this.makeRequest(
- HttpMethod.POST,
- `/v1/datasheets/${datasheet_id}/records`,
- undefined,
- request
- );
+ return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
+ data: {
+ records: {
+ recordId: string;
+ fields: Record<string, unknown>;
+ }[];
+ };
+ }>(HttpMethod.POST, `/v1/datasheets/${datasheet_id}/records`, undefined, request);
}
async updateRecord(datasheet_id: string, request: object) {
- return await this.makeRequest(
- HttpMethod.PATCH,
- `/v1/datasheets/${datasheet_id}/records`,
- undefined,
- request
- );
+ return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
+ data: {
+ records: {
+ recordId: string;
+ createdAt: number;
+ updatedAt: number;
+ fields: Record<string, unknown>;
+ }[];
+ };
+ }>(HttpMethod.PATCH, `/v1/datasheets/${datasheet_id}/records`, undefined, request);
}
async listRecords(datasheet_id: string, query?: QueryParams) {
return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
data: {
total: number;
+ pageNum: number;
+ pageSize: number;
records: {
recordId: string;
createdAt: number;
@@ -126,4 +189,54 @@ export class AITableClient {
};
}>(HttpMethod.GET, `/v1/datasheets/${datasheet_id}/records`, query);
}
+
+ async uploadAttachment(datasheet_id: string, filename: string, file: Buffer) {
+ const formData = new FormData();
+ formData.append('file', file, { filename });
+ return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
+ data: {
+ token: string;
+ mimeType: string;
+ size: number;
+ width?: number;
+ height?: number;
+ name: string;
+ url: string;
+ };
+ }>(
+ HttpMethod.POST,
+ `/v1/datasheets/${datasheet_id}/attachments`,
+ undefined,
+ formData,
+ formData.getHeaders()
+ );
+ }
+
+ async listViews(datasheet_id: string) {
+ return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
+ data: {
+ views: {
+ id: string;
+ name: string;
+ type: string;
+ }[];
+ };
+ }>(HttpMethod.GET, `/v1/datasheets/${datasheet_id}/views`);
+ }
+
+ async deleteRecords(datasheet_id: string, recordIds: string[]) {
+ return await this.makeRequest<{
+ success: boolean;
+ code: number;
+ message: string;
+ }>(HttpMethod.DELETE, `/v1/datasheets/${datasheet_id}/records`, {
+ recordIds: recordIds.join(','),
+ });
+ }
}
diff --git a/packages/pieces/community/apitable/src/lib/output-schemas.ts b/packages/pieces/community/apitable/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..5fc67e9308b
--- /dev/null
+++ b/packages/pieces/community/apitable/src/lib/output-schemas.ts
@@ -0,0 +1,261 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const envelopeFields: OutputSchema['fields'] = [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'code', label: 'Code', format: 'number' },
+ { key: 'message', label: 'Message' },
+];
+
+const createdRecordFields: OutputSchema['fields'] = [
+ { key: 'recordId', label: 'Record ID' },
+ { key: 'fields', label: 'Fields', dynamicKey: true },
+];
+
+const recordFields: OutputSchema['fields'] = [
+ { key: 'recordId', label: 'Record ID' },
+ { key: 'createdAt', label: 'Created At', format: 'datetime' },
+ { key: 'updatedAt', label: 'Updated At', format: 'datetime' },
+ { key: 'fields', label: 'Fields', dynamicKey: true },
+];
+
+const datasheetFieldFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Field ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'type', label: 'Type' },
+ { key: 'editable', label: 'Editable', format: 'boolean' },
+ { key: 'isPrimary', label: 'Primary Field', format: 'boolean' },
+ {
+ key: 'property',
+ label: 'Property',
+ children: [
+ { key: 'defaultValue', label: 'Default Value' },
+ {
+ key: 'options',
+ label: 'Options',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'ID' },
+ { key: 'name', label: 'Name' },
+ {
+ key: 'color',
+ label: 'Color',
+ children: [
+ { key: 'name', label: 'Name' },
+ { key: 'value', label: 'Value' },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+];
+
+const nodeSummaryFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Node ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'type', label: 'Type' },
+ { key: 'icon', label: 'Icon' },
+ { key: 'isFav', label: 'Favorite', format: 'boolean' },
+ { key: 'permission', label: 'Permission', format: 'number' },
+];
+
+export const createRecordActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ {
+ key: 'records',
+ label: 'Records',
+ labelKey: 'recordId',
+ listItems: createdRecordFields,
+ },
+ ],
+ },
+ ],
+};
+
+export const updateRecordActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ {
+ key: 'records',
+ label: 'Records',
+ labelKey: 'recordId',
+ listItems: recordFields,
+ },
+ ],
+ },
+ ],
+};
+
+export const findRecordActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ { key: 'total', label: 'Total', format: 'number' },
+ { key: 'pageNum', label: 'Page Number', format: 'number' },
+ { key: 'pageSize', label: 'Page Size', format: 'number' },
+ {
+ key: 'records',
+ label: 'Records',
+ labelKey: 'recordId',
+ listItems: recordFields,
+ },
+ ],
+ },
+ ],
+};
+
+export const listSpacesActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ {
+ key: 'spaces',
+ label: 'Spaces',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'Space ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'isAdmin', label: 'Is Admin', format: 'boolean' },
+ ],
+ },
+ ],
+ },
+ ],
+};
+
+export const listDatasheetsActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ {
+ key: 'nodes',
+ label: 'Datasheets',
+ labelKey: 'name',
+ listItems: [...nodeSummaryFields, { key: 'parentId', label: 'Parent ID' }],
+ },
+ ],
+ },
+ ],
+};
+
+export const searchNodesActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ {
+ key: 'nodes',
+ label: 'Nodes',
+ labelKey: 'name',
+ listItems: [...nodeSummaryFields, { key: 'parentId', label: 'Parent ID' }],
+ },
+ ],
+ },
+ ],
+};
+
+export const getNodeDetailsActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Node',
+ children: [
+ ...nodeSummaryFields,
+ {
+ key: 'children',
+ label: 'Children',
+ labelKey: 'name',
+ listItems: nodeSummaryFields,
+ },
+ ],
+ },
+ ],
+};
+
+export const listViewsActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ {
+ key: 'views',
+ label: 'Views',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'View ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'type', label: 'Type' },
+ ],
+ },
+ ],
+ },
+ ],
+};
+
+export const getDatasheetFieldsActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ {
+ key: 'fields',
+ label: 'Fields',
+ labelKey: 'name',
+ listItems: datasheetFieldFields,
+ },
+ ],
+ },
+ ],
+};
+
+export const uploadAttachmentActionOutputSchema: OutputSchema = {
+ fields: [
+ ...envelopeFields,
+ {
+ key: 'data',
+ label: 'Data',
+ children: [
+ { key: 'token', label: 'Token' },
+ { key: 'name', label: 'File Name' },
+ { key: 'mimeType', label: 'MIME Type' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ { key: 'width', label: 'Width', format: 'number' },
+ { key: 'height', label: 'Height', format: 'number' },
+ { key: 'url', label: 'URL', format: 'url' },
+ ],
+ },
+ ],
+};
+
+export const deleteRecordActionOutputSchema: OutputSchema = {
+ fields: envelopeFields,
+};
+
+export const newRecordTriggerOutputSchema: OutputSchema = {
+ fields: recordFields,
+};
diff --git a/packages/pieces/community/apitable/src/lib/triggers/new-record.ts b/packages/pieces/community/apitable/src/lib/triggers/new-record.ts
index 7c32f353520..53fe1165056 100644
--- a/packages/pieces/community/apitable/src/lib/triggers/new-record.ts
+++ b/packages/pieces/community/apitable/src/lib/triggers/new-record.ts
@@ -11,6 +11,7 @@ import {
} from '@activepieces/pieces-common';
import { APITableCommon, makeClient } from '../common';
import dayjs from 'dayjs';
+import { newRecordTriggerOutputSchema } from '../output-schemas';
const polling: Polling<
AppConnectionValueForAuthProperty<typeof APITableAuth>,
@@ -52,6 +53,7 @@ export const newRecordTrigger = createTrigger({
space_id: APITableCommon.space_id,
datasheet_id: APITableCommon.datasheet_id,
},
+ outputSchema: newRecordTriggerOutputSchema,
sampleData: {
recordId: 'rec2T5ppW1Mal',
createdAt: 1689772153000,
diff --git a/packages/pieces/community/claude/package.json b/packages/pieces/community/claude/package.json
index 59aecb9dde7..b133e1825ae 100644
--- a/packages/pieces/community/claude/package.json
+++ b/packages/pieces/community/claude/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-claude",
- "version": "0.5.0",
+ "version": "0.6.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/claude/src/index.ts b/packages/pieces/community/claude/src/index.ts
index 3703a3762c0..0399909c9b2 100644
--- a/packages/pieces/community/claude/src/index.ts
+++ b/packages/pieces/community/claude/src/index.ts
@@ -1,21 +1,39 @@
-import { PieceAuth, createPiece } from '@activepieces/pieces-framework';
+import { createPiece } from '@activepieces/pieces-framework';
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import { askClaude } from './lib/actions/send-prompt';
import { baseUrl } from './lib/common/common';
import { PieceCategory } from '@activepieces/pieces-framework';
import { extractStructuredDataAction } from './lib/actions/extract-structured-data';
+import { listModelsAction } from './lib/actions/list-models';
+import { getModelAction } from './lib/actions/get-model';
+import { createMessageBatchAction } from './lib/actions/create-message-batch';
+import { getMessageBatchAction } from './lib/actions/get-message-batch';
+import { listMessageBatchesAction } from './lib/actions/list-message-batches';
+import { cancelMessageBatchAction } from './lib/actions/cancel-message-batch';
+import { deleteMessageBatchAction } from './lib/actions/delete-message-batch';
+import { getMessageBatchResultsAction } from './lib/actions/get-message-batch-results';
+import { countTokensAction } from './lib/actions/count-tokens';
import { claudeAuth } from './lib/auth';
export const claude = createPiece({
displayName: 'Anthropic Claude',
auth: claudeAuth,
- minimumSupportedRelease: '0.63.0',
+ minimumSupportedRelease: '0.87.0',
logoUrl: 'https://cdn.activepieces.com/pieces/claude.png',
categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],
authors: ['dennisrongo','kishanprmr'],
actions: [
askClaude,
extractStructuredDataAction,
+ listModelsAction,
+ getModelAction,
+ createMessageBatchAction,
+ getMessageBatchAction,
+ listMessageBatchesAction,
+ cancelMessageBatchAction,
+ deleteMessageBatchAction,
+ getMessageBatchResultsAction,
+ countTokensAction,
createCustomApiCallAction({
auth: claudeAuth,
baseUrl: () => baseUrl,
diff --git a/packages/pieces/community/claude/src/lib/actions/cancel-message-batch.ts b/packages/pieces/community/claude/src/lib/actions/cancel-message-batch.ts
new file mode 100644
index 00000000000..0342d4e39eb
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/cancel-message-batch.ts
@@ -0,0 +1,29 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { cancelMessageBatchActionOutputSchema } from '../output-schemas';
+
+export const cancelMessageBatchAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'cancel_message_batch',
+ classification: 'WRITE',
+ displayName: 'Cancel Message Batch',
+ description: 'Cancels an in-progress message batch. Already-completed requests in the batch are not undone.',
+ aiMetadata: {
+ description:
+ "Cancels a message batch that is still 'in_progress'. The batch moves to 'canceling' and the system finishes any non-interruptible requests already underway before finalizing; check request_counts.canceled via Get Message Batch to see how many were actually stopped. Idempotent: canceling an already-canceling or ended batch has no further effect.",
+ idempotent: true,
+ },
+ props: {
+ messageBatchId: Property.ShortText({
+ displayName: 'Message Batch ID',
+ required: true,
+ }),
+ },
+ outputSchema: cancelMessageBatchActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ return anthropic.messages.batches.cancel(context.propsValue.messageBatchId);
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/actions/count-tokens.ts b/packages/pieces/community/claude/src/lib/actions/count-tokens.ts
new file mode 100644
index 00000000000..ab747ff1011
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/count-tokens.ts
@@ -0,0 +1,39 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { modelDropdown } from '../common/common';
+import { countTokensActionOutputSchema } from '../output-schemas';
+
+export const countTokensAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'count_tokens',
+ classification: 'READ',
+ displayName: 'Count Tokens',
+ description: 'Counts how many input tokens a prompt would use for a given model, without generating a response.',
+ aiMetadata: {
+ description:
+ 'Counts the input tokens a prompt and optional system prompt would use for a given Claude model, without sending it to be answered. Use to check a prompt fits a model\'s context window or to estimate cost before calling Ask Claude or Extract Structured Data. Idempotent: it only counts, it never generates.',
+ idempotent: true,
+ },
+ props: {
+ model: modelDropdown,
+ systemPrompt: Property.LongText({
+ displayName: 'System Prompt',
+ required: false,
+ }),
+ prompt: Property.LongText({
+ displayName: 'Prompt',
+ required: true,
+ }),
+ },
+ outputSchema: countTokensActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ return anthropic.messages.countTokens({
+ model: context.propsValue.model,
+ system: context.propsValue.systemPrompt,
+ messages: [{ role: 'user', content: context.propsValue.prompt }],
+ });
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/actions/create-message-batch.ts b/packages/pieces/community/claude/src/lib/actions/create-message-batch.ts
new file mode 100644
index 00000000000..565db49cc44
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/create-message-batch.ts
@@ -0,0 +1,44 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { createMessageBatchActionOutputSchema } from '../output-schemas';
+
+export const createMessageBatchAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'create_message_batch',
+ classification: 'WRITE',
+ displayName: 'Create Message Batch',
+ description: 'Submits a batch of Messages API requests to be processed asynchronously, at up to 24 hours turnaround.',
+ aiMetadata: {
+ description:
+ "Submits multiple Messages API requests as a single asynchronous batch (up to 24h to complete), cheaper than calling Ask Claude repeatedly for large volumes. Each request needs a unique custom_id and a params object shaped like the Messages API (model, messages, max_tokens, system). Poll status with Get Message Batch and read output with Get Message Batch Results once processing_status is 'ended'. Not idempotent: each call creates a new batch.",
+ idempotent: false,
+ },
+ props: {
+ requests: Property.Json({
+ displayName: 'Requests',
+ description:
+ 'Array of { custom_id, params } objects. Each custom_id must be unique within the batch; each params object matches the Messages API request body (model, messages, max_tokens, system, etc).',
+ required: true,
+ defaultValue: [
+ {
+ custom_id: 'request-1',
+ params: {
+ model: 'claude-3-5-haiku-latest',
+ max_tokens: 1024,
+ messages: [{ role: 'user', content: 'Hello, Claude!' }],
+ },
+ },
+ ],
+ }),
+ },
+ outputSchema: createMessageBatchActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ return anthropic.messages.batches.create({
+ requests: context.propsValue
+ .requests as unknown as Anthropic.Messages.BatchCreateParams['requests'],
+ });
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/actions/delete-message-batch.ts b/packages/pieces/community/claude/src/lib/actions/delete-message-batch.ts
new file mode 100644
index 00000000000..b7ff42f5a3e
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/delete-message-batch.ts
@@ -0,0 +1,29 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { deleteMessageBatchActionOutputSchema } from '../output-schemas';
+
+export const deleteMessageBatchAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'delete_message_batch',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Message Batch',
+ description: 'Deletes a message batch and its results. The batch must have finished processing first.',
+ aiMetadata: {
+ description:
+ "Permanently deletes a message batch, once its processing_status is 'ended' (an in-progress batch must be canceled first via Cancel Message Batch). This removes access to the batch's results. Not idempotent: deleting an already-deleted batch fails with not_found.",
+ idempotent: false,
+ },
+ props: {
+ messageBatchId: Property.ShortText({
+ displayName: 'Message Batch ID',
+ required: true,
+ }),
+ },
+ outputSchema: deleteMessageBatchActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ return anthropic.messages.batches.delete(context.propsValue.messageBatchId);
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/actions/get-message-batch-results.ts b/packages/pieces/community/claude/src/lib/actions/get-message-batch-results.ts
new file mode 100644
index 00000000000..8029df2b3bc
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/get-message-batch-results.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { getMessageBatchResultsActionOutputSchema } from '../output-schemas';
+
+const DEFAULT_MAX_RESULTS = 100;
+
+export const getMessageBatchResultsAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'get_message_batch_results',
+ classification: 'READ',
+ displayName: 'Get Message Batch Results',
+ description: 'Reads the per-request results of a finished message batch.',
+ aiMetadata: {
+ description:
+ "Reads the results of a message batch once Get Message Batch reports processing_status 'ended', returning each request's custom_id alongside its outcome ('succeeded' with the Message, or 'errored'/'canceled'/'expired'). Results are not guaranteed to be in request order; match on custom_id. Idempotent: it only reads data.",
+ idempotent: true,
+ },
+ props: {
+ messageBatchId: Property.ShortText({
+ displayName: 'Message Batch ID',
+ required: true,
+ }),
+ maxResults: Property.Number({
+ displayName: 'Max Results',
+ description: `Maximum number of results to return (default ${DEFAULT_MAX_RESULTS}).`,
+ required: false,
+ }),
+ },
+ outputSchema: getMessageBatchResultsActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ const maxResults = context.propsValue.maxResults ?? DEFAULT_MAX_RESULTS;
+ if (!Number.isInteger(maxResults) || maxResults <= 0) {
+ throw new Error('Max Results must be a positive integer.');
+ }
+ const decoder = await anthropic.messages.batches.results(context.propsValue.messageBatchId);
+
+ const results = [];
+ for await (const result of decoder) {
+ results.push(result);
+ if (results.length >= maxResults) {
+ break;
+ }
+ }
+ return { results };
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/actions/get-message-batch.ts b/packages/pieces/community/claude/src/lib/actions/get-message-batch.ts
new file mode 100644
index 00000000000..1cc172be033
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/get-message-batch.ts
@@ -0,0 +1,29 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { getMessageBatchActionOutputSchema } from '../output-schemas';
+
+export const getMessageBatchAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'get_message_batch',
+ classification: 'READ',
+ displayName: 'Get Message Batch',
+ description: 'Reads the status and request counts of a message batch, to poll for completion.',
+ aiMetadata: {
+ description:
+ "Reads a message batch by ID, returning its processing_status ('in_progress', 'canceling', or 'ended') and a tally of succeeded/errored/canceled/expired requests. Poll this after Create Message Batch until processing_status is 'ended', then call Get Message Batch Results. Idempotent: it only reads data.",
+ idempotent: true,
+ },
+ props: {
+ messageBatchId: Property.ShortText({
+ displayName: 'Message Batch ID',
+ required: true,
+ }),
+ },
+ outputSchema: getMessageBatchActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ return anthropic.messages.batches.retrieve(context.propsValue.messageBatchId);
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/actions/get-model.ts b/packages/pieces/community/claude/src/lib/actions/get-model.ts
new file mode 100644
index 00000000000..fb94920c5ec
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/get-model.ts
@@ -0,0 +1,30 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { getModelActionOutputSchema } from '../output-schemas';
+
+export const getModelAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'get_model',
+ classification: 'READ',
+ displayName: 'Get Model',
+ description: 'Reads details for a single Claude model, or resolves a model alias to its ID.',
+ aiMetadata: {
+ description:
+ "Reads a single Claude model by ID or alias (e.g. 'claude-3-7-sonnet-latest'), returning its resolved ID, display name, and release date. Use to confirm a model ID is valid or resolve an alias before using it elsewhere. Idempotent: it only reads data.",
+ idempotent: true,
+ },
+ props: {
+ modelId: Property.ShortText({
+ displayName: 'Model ID',
+ description: 'The model ID or alias to look up.',
+ required: true,
+ }),
+ },
+ outputSchema: getModelActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ return anthropic.models.retrieve(context.propsValue.modelId);
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/actions/list-message-batches.ts b/packages/pieces/community/claude/src/lib/actions/list-message-batches.ts
new file mode 100644
index 00000000000..63625e8593a
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/list-message-batches.ts
@@ -0,0 +1,50 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { listMessageBatchesActionOutputSchema } from '../output-schemas';
+
+export const listMessageBatchesAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'list_message_batches',
+ classification: 'SEARCH',
+ displayName: 'List Message Batches',
+ description: 'Lists message batches, most recently created first.',
+ aiMetadata: {
+ description:
+ 'Lists message batches in the workspace, most recently created first, returning each batch\'s ID and processing_status. Use to discover a batch ID before calling Get Message Batch, Get Message Batch Results, Cancel Message Batch, or Delete Message Batch. Idempotent: it only reads data.',
+ idempotent: true,
+ },
+ props: {
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Number of batches to return per page (default 20, max 1000).',
+ required: false,
+ }),
+ afterId: Property.ShortText({
+ displayName: 'After ID',
+ description: 'Return the page of batches immediately after this batch ID.',
+ required: false,
+ }),
+ beforeId: Property.ShortText({
+ displayName: 'Before ID',
+ description: 'Return the page of batches immediately before this batch ID.',
+ required: false,
+ }),
+ },
+ outputSchema: listMessageBatchesActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ const page = await anthropic.messages.batches.list({
+ limit: context.propsValue.limit,
+ after_id: context.propsValue.afterId,
+ before_id: context.propsValue.beforeId,
+ });
+ return {
+ data: page.data,
+ has_more: page.has_more,
+ first_id: page.first_id,
+ last_id: page.last_id,
+ };
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/actions/list-models.ts b/packages/pieces/community/claude/src/lib/actions/list-models.ts
new file mode 100644
index 00000000000..928c170e17b
--- /dev/null
+++ b/packages/pieces/community/claude/src/lib/actions/list-models.ts
@@ -0,0 +1,28 @@
+import { createAction } from '@activepieces/pieces-framework';
+import Anthropic from '@anthropic-ai/sdk';
+import { claudeAuth } from '../auth';
+import { listModelsActionOutputSchema } from '../output-schemas';
+
+export const listModelsAction = createAction({
+ audience: 'ai',
+ auth: claudeAuth,
+ name: 'list_models',
+ classification: 'SEARCH',
+ displayName: 'List Models',
+ description: 'Lists the Claude models available to this API key.',
+ aiMetadata: {
+ description:
+ "Lists the Claude models available for use, most recently released first, returning each model's ID and display name. Use to discover a valid model ID before calling Ask Claude, Extract Structured Data, or Create Message Batch. Idempotent: it only reads data.",
+ idempotent: true,
+ },
+ props: {},
+ outputSchema: listModelsActionOutputSchema,
+ async run(context) {
+ const anthropic = new Anthropic({ apiKey: context.auth.secret_text });
+ const models = [];
+ for await (const model of anthropic.models.list({ limit: 1000 })) {
+ models.push(model);
+ }
+ return { models };
+ },
+});
diff --git a/packages/pieces/community/claude/src/lib/output-schemas.ts b/packages/pieces/community/claude/src/lib/output-schemas.ts
index 349721c9ebe..1b80e6fa382 100644
--- a/packages/pieces/community/claude/src/lib/output-schemas.ts
+++ b/packages/pieces/community/claude/src/lib/output-schemas.ts
@@ -31,3 +31,152 @@ export const extractStructuredDataActionOutputSchema: OutputSchema = {
},
],
};
+
+const capabilitySupportFields: OutputSchema['fields'] = [
+ { key: 'supported', label: 'Supported', format: 'boolean' },
+];
+
+const modelCapabilitiesFields: OutputSchema['fields'] = [
+ { key: 'batch', label: 'Batch API', children: capabilitySupportFields },
+ { key: 'citations', label: 'Citations', children: capabilitySupportFields },
+ { key: 'code_execution', label: 'Code Execution', children: capabilitySupportFields },
+ { key: 'image_input', label: 'Image Input', children: capabilitySupportFields },
+ { key: 'pdf_input', label: 'PDF Input', children: capabilitySupportFields },
+ { key: 'structured_outputs', label: 'Structured Outputs', children: capabilitySupportFields },
+ {
+ key: 'thinking',
+ label: 'Extended Thinking',
+ children: [
+ { key: 'supported', label: 'Supported', format: 'boolean' },
+ {
+ key: 'types',
+ label: 'Types',
+ children: [
+ { key: 'adaptive', label: 'Adaptive', children: capabilitySupportFields },
+ { key: 'enabled', label: 'Enabled', children: capabilitySupportFields },
+ ],
+ },
+ ],
+ },
+];
+
+const modelFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Model ID' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'max_input_tokens', label: 'Max Input Tokens', format: 'number' },
+ { key: 'max_tokens', label: 'Max Output Tokens', format: 'number' },
+ { key: 'capabilities', label: 'Capabilities', children: modelCapabilitiesFields },
+];
+
+const requestCountsFields: OutputSchema['fields'] = [
+ { key: 'processing', label: 'Processing', format: 'number' },
+ { key: 'succeeded', label: 'Succeeded', format: 'number' },
+ { key: 'errored', label: 'Errored', format: 'number' },
+ { key: 'canceled', label: 'Canceled', format: 'number' },
+ { key: 'expired', label: 'Expired', format: 'number' },
+];
+
+const messageBatchFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Batch ID' },
+ { key: 'processing_status', label: 'Status' },
+ { key: 'request_counts', label: 'Request Counts', children: requestCountsFields },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'expires_at', label: 'Expires At', format: 'datetime' },
+ { key: 'ended_at', label: 'Ended At', format: 'datetime' },
+ { key: 'archived_at', label: 'Archived At', format: 'datetime' },
+ { key: 'cancel_initiated_at', label: 'Cancel Initiated At', format: 'datetime' },
+ { key: 'results_url', label: 'Results URL', format: 'url' },
+];
+
+export const listModelsActionOutputSchema: OutputSchema = {
+ fields: [{ key: 'models', label: 'Models', labelKey: 'display_name', listItems: modelFields }],
+};
+
+export const getModelActionOutputSchema: OutputSchema = { fields: modelFields };
+
+export const createMessageBatchActionOutputSchema: OutputSchema = { fields: messageBatchFields };
+
+export const getMessageBatchActionOutputSchema: OutputSchema = { fields: messageBatchFields };
+
+export const listMessageBatchesActionOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Batches', labelKey: 'id', listItems: messageBatchFields },
+ { key: 'has_more', label: 'Has More', format: 'boolean' },
+ { key: 'first_id', label: 'First ID' },
+ { key: 'last_id', label: 'Last ID' },
+ ],
+};
+
+export const cancelMessageBatchActionOutputSchema: OutputSchema = { fields: messageBatchFields };
+
+export const deleteMessageBatchActionOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Batch ID' },
+ { key: 'type', label: 'Type' },
+ ],
+};
+
+export const getMessageBatchResultsActionOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'results',
+ label: 'Results',
+ labelKey: 'custom_id',
+ listItems: [
+ { key: 'custom_id', label: 'Custom ID' },
+ {
+ key: 'result',
+ label: 'Result',
+ children: [
+ { key: 'type', label: 'Type' },
+ {
+ key: 'message',
+ label: 'Message',
+ children: [
+ { key: 'id', label: 'Message ID' },
+ { key: 'model', label: 'Model' },
+ { key: 'stop_reason', label: 'Stop Reason' },
+ {
+ key: 'content',
+ label: 'Content',
+ listItems: [
+ { key: 'type', label: 'Type' },
+ { key: 'text', label: 'Text' },
+ ],
+ },
+ {
+ key: 'usage',
+ label: 'Usage',
+ children: [
+ { key: 'input_tokens', label: 'Input Tokens', format: 'number' },
+ { key: 'output_tokens', label: 'Output Tokens', format: 'number' },
+ ],
+ },
+ ],
+ },
+ {
+ key: 'error',
+ label: 'Error',
+ children: [
+ { key: 'request_id', label: 'Request ID' },
+ {
+ key: 'error',
+ label: 'Error',
+ children: [
+ { key: 'type', label: 'Type' },
+ { key: 'message', label: 'Message' },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
+};
+
+export const countTokensActionOutputSchema: OutputSchema = {
+ fields: [{ key: 'input_tokens', label: 'Input Tokens', format: 'number' }],
+};