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(amazon-s3): add AI actions and output schemas (#16204)

Kishan Parmarc801bc438f85
diff --git a/packages/pieces/community/amazon-s3/package.json b/packages/pieces/community/amazon-s3/package.json
index 503f48dd771..c908d07fd50 100644
--- a/packages/pieces/community/amazon-s3/package.json
+++ b/packages/pieces/community/amazon-s3/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-amazon-s3",
- "version": "0.7.1",
+ "version": "0.8.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/amazon-s3/src/index.ts b/packages/pieces/community/amazon-s3/src/index.ts
index 05990cfc080..148a9ee975d 100644
--- a/packages/pieces/community/amazon-s3/src/index.ts
+++ b/packages/pieces/community/amazon-s3/src/index.ts
@@ -12,6 +12,7 @@ import { deleteFile } from './lib/actions/delete-file';
import { listFiles } from './lib/actions/list-files';
import { decryptPgpFile } from './lib/actions/decrypt-pgp-file';
import { amazonS3CombinedAuth } from './lib/auth';
+import { amazonS3AiActions } from './lib/actions/ai';
export const amazonS3 = createPiece({
displayName: 'Amazon S3',
@@ -22,6 +23,6 @@ export const amazonS3 = createPiece({
authors: ["Willianwg", "kishanprmr", "MoShizzle", "AbdulTheActivePiecer", "khaledmashaly", "abuaboud", "Kevinyu-alan", "hugh-codes"],
categories: [PieceCategory.DEVELOPER_TOOLS],
auth: amazonS3CombinedAuth,
- actions: [amazons3UploadFile, readFile, generateSignedUrl, generateSignedUploadUrl, moveFile, deleteFile, listFiles, decryptPgpFile],
+ actions: [amazons3UploadFile, readFile, generateSignedUrl, generateSignedUploadUrl, moveFile, deleteFile, listFiles, decryptPgpFile, ...amazonS3AiActions],
triggers: [newFile],
});
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/ai-common.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/ai-common.ts
new file mode 100644
index 00000000000..a1575f31b05
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/ai-common.ts
@@ -0,0 +1,71 @@
+import { S3ServiceException } from '@aws-sdk/client-s3';
+
+async function call<T>({ request, key }: { request: () => Promise<T>; key?: string }): Promise<T> {
+ try {
+ return await request();
+ } catch (error) {
+ throw toActionError({ error, key });
+ }
+}
+
+function copySource({
+ bucket,
+ key,
+ versionId,
+}: {
+ bucket: string;
+ key: string;
+ versionId?: string;
+}): string {
+ const source = encodeURIComponent(`${bucket}/${key}`);
+ return versionId ? `${source}?versionId=${encodeURIComponent(versionId)}` : source;
+}
+
+function isTextContentType(contentType: string | undefined): boolean {
+ if (!contentType) {
+ return false;
+ }
+ const type = contentType.toLowerCase();
+ return type.startsWith('text/') || TEXT_TYPE_MARKERS.some((marker) => type.includes(marker));
+}
+
+function toIso(date: Date | undefined): string | null {
+ return date ? date.toISOString() : null;
+}
+
+function toActionError({ error, key }: { error: unknown; key?: string }): Error {
+ if (!(error instanceof S3ServiceException)) {
+ return error instanceof Error ? error : new Error(String(error));
+ }
+ const status = error.$metadata.httpStatusCode;
+ const target = key ? ` "${key}"` : '';
+ if (status === 404 || error.name === 'NoSuchKey' || error.name === 'NotFound') {
+ return new Error(`File${target} was not found in the bucket (${error.name}).`);
+ }
+ if (status === 403) {
+ return new Error(
+ `Access denied${
+ target ? ` for${target}` : ''
+ }: the connection's IAM policy does not allow this S3 operation (${
+ error.message || error.name
+ }).`,
+ );
+ }
+ if (status === 412) {
+ return new Error(`A file already exists at${target} and overwriting was not allowed.`);
+ }
+ return new Error(`${error.name}: ${error.message}`);
+}
+
+const TEXT_TYPE_MARKERS = [
+ 'json',
+ 'xml',
+ 'csv',
+ 'yaml',
+ 'javascript',
+ 'markdown',
+ 'ndjson',
+ 'x-www-form-urlencoded',
+];
+
+export const s3AiCommon = { call, copySource, isTextContentType, toIso };
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/copy-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/copy-file.ts
new file mode 100644
index 00000000000..dbfe2a880ad
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/copy-file.ts
@@ -0,0 +1,68 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3CopyFileOutputSchema } from '../../output-schemas';
+
+export const amazonS3CopyFile = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_copy_file',
+ outputSchema: amazonS3CopyFileOutputSchema,
+ displayName: 'Copy File',
+ description: 'Copies a file to another key in the connected bucket.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Copies a file to a new key in the connected S3 bucket, keeping its content type and metadata; a file already at the destination key is replaced. To restore an old version, pass its version id from List File Versions and the same key as destination. Files over 5 GB cannot be copied in one call and fail with the S3 error.',
+ idempotent: true,
+ },
+ props: {
+ sourceKey: Property.ShortText({
+ displayName: 'Source File Key',
+ description: 'The full key of the file to copy, as returned by List Files.',
+ required: true,
+ }),
+ destinationKey: Property.ShortText({
+ displayName: 'Destination File Key',
+ description: 'The full key to copy to, including the file name, e.g. "archive/q1.csv".',
+ required: true,
+ }),
+ sourceVersionId: Property.ShortText({
+ displayName: 'Source Version ID',
+ description:
+ 'A version id from List File Versions to copy an older version. Leave empty for the current version.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { sourceKey, destinationKey, sourceVersionId } = context.propsValue;
+
+ const response = await s3AiCommon.call({
+ key: sourceKey,
+ request: () =>
+ s3.copyObject({
+ Bucket: bucket,
+ Key: destinationKey,
+ CopySource: s3AiCommon.copySource({
+ bucket,
+ key: sourceKey,
+ versionId: sourceVersionId || undefined,
+ }),
+ }),
+ });
+
+ return {
+ sourceKey,
+ destinationKey,
+ sourceVersionId: response.CopySourceVersionId ?? null,
+ versionId: response.VersionId ?? null,
+ etag: response.CopyObjectResult?.ETag ?? null,
+ lastModified: s3AiCommon.toIso(response.CopyObjectResult?.LastModified),
+ };
+ },
+});
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/delete-file-tags.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/delete-file-tags.ts
new file mode 100644
index 00000000000..c09e21562fc
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/delete-file-tags.ts
@@ -0,0 +1,47 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3DeleteFileTagsOutputSchema } from '../../output-schemas';
+
+export const amazonS3DeleteFileTags = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_delete_file_tags',
+ outputSchema: amazonS3DeleteFileTagsOutputSchema,
+ displayName: 'Delete File Tags',
+ description: 'Removes all tags from a file.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Removes every tag from a file in the connected S3 bucket; the file itself is not changed. To remove only some tags, use Set File Tags with the tags to keep. Running it on a file with no tags succeeds.',
+ idempotent: true,
+ },
+ props: {
+ key: Property.ShortText({
+ displayName: 'File Key',
+ description: 'The full key (path) of the file, as returned by List Files.',
+ required: true,
+ }),
+ versionId: Property.ShortText({
+ displayName: 'Version ID',
+ description: 'A version id from List File Versions. Leave empty for the current version.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { key, versionId } = context.propsValue;
+
+ const response = await s3AiCommon.call({
+ key,
+ request: () =>
+ s3.deleteObjectTagging({ Bucket: bucket, Key: key, VersionId: versionId || undefined }),
+ });
+
+ return { key, versionId: response.VersionId ?? null, deleted: true };
+ },
+});
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/delete-files.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/delete-files.ts
new file mode 100644
index 00000000000..41b138b172c
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/delete-files.ts
@@ -0,0 +1,80 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3DeleteFilesOutputSchema } from '../../output-schemas';
+
+export const amazonS3DeleteFiles = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_delete_files',
+ outputSchema: amazonS3DeleteFilesOutputSchema,
+ displayName: 'Delete Files',
+ description: 'Deletes up to 1000 files from the connected bucket in one call.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes up to 1000 files by key from the connected S3 bucket in one call and reports which keys were deleted and which failed. On a versioned bucket this adds a delete marker and older versions stay restorable. Keys that do not exist count as deleted, so repeating the call is safe.',
+ idempotent: true,
+ },
+ props: {
+ keys: Property.Array({
+ displayName: 'File Keys',
+ description: 'The full keys of the files to delete (1–1000), as returned by List Files.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const keys = context.propsValue.keys.filter(
+ (key): key is string => typeof key === 'string' && key !== '',
+ );
+ const invalid = context.propsValue.keys.length - keys.length;
+
+ if (invalid > 0) {
+ throw new Error(
+ `File Keys must be non-empty strings; ${invalid} entr${
+ invalid === 1 ? 'y is' : 'ies are'
+ } not. Nothing was deleted.`,
+ );
+ }
+ if (keys.length === 0) {
+ throw new Error('Provide at least one file key to delete.');
+ }
+ if (keys.length > MAX_KEYS) {
+ throw new Error(`At most ${MAX_KEYS} keys can be deleted in one call; got ${keys.length}.`);
+ }
+
+ const response = await s3AiCommon.call({
+ request: () =>
+ s3.deleteObjects({
+ Bucket: bucket,
+ Delete: { Objects: keys.map((key) => ({ Key: key })), Quiet: false },
+ }),
+ });
+
+ const deleted = (response.Deleted ?? []).map((item) => ({
+ key: item.Key ?? null,
+ versionId: item.VersionId ?? null,
+ deleteMarker: item.DeleteMarker ?? false,
+ }));
+ const failed = (response.Errors ?? []).map((item) => ({
+ key: item.Key ?? null,
+ code: item.Code ?? null,
+ message: item.Message ?? null,
+ }));
+
+ return {
+ success: failed.length === 0,
+ deletedCount: deleted.length,
+ failedCount: failed.length,
+ deleted,
+ failed,
+ };
+ },
+});
+
+const MAX_KEYS = 1000;
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/get-file-metadata.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/get-file-metadata.ts
new file mode 100644
index 00000000000..a9aa8474174
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/get-file-metadata.ts
@@ -0,0 +1,61 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3GetFileMetadataOutputSchema } from '../../output-schemas';
+
+export const amazonS3GetFileMetadata = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_get_file_metadata',
+ outputSchema: amazonS3GetFileMetadataOutputSchema,
+ displayName: 'Get File Metadata',
+ description:
+ "Gets a file's size, content type, last modified date and custom metadata without downloading it.",
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Gets a file's size, content type, last modified date, ETag, storage class and custom metadata without downloading its content. Use it to check that a key exists or inspect a file before reading it; use Read File for the content. Pass a version id from List File Versions to inspect an older version.",
+ idempotent: true,
+ },
+ props: {
+ key: Property.ShortText({
+ displayName: 'File Key',
+ description:
+ 'The full key (path) of the file, e.g. "reports/2024/q1.csv", as returned by List Files.',
+ required: true,
+ }),
+ versionId: Property.ShortText({
+ displayName: 'Version ID',
+ description: 'A version id from List File Versions. Leave empty for the current version.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { key, versionId } = context.propsValue;
+
+ const response = await s3AiCommon.call({
+ key,
+ request: () => s3.headObject({ Bucket: bucket, Key: key, VersionId: versionId || undefined }),
+ });
+
+ return {
+ key,
+ versionId: response.VersionId ?? null,
+ size: response.ContentLength ?? null,
+ contentType: response.ContentType ?? null,
+ lastModified: s3AiCommon.toIso(response.LastModified),
+ etag: response.ETag ?? null,
+ storageClass: response.StorageClass ?? 'STANDARD',
+ contentEncoding: response.ContentEncoding ?? null,
+ contentDisposition: response.ContentDisposition ?? null,
+ cacheControl: response.CacheControl ?? null,
+ serverSideEncryption: response.ServerSideEncryption ?? null,
+ metadata: response.Metadata ?? {},
+ };
+ },
+});
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/get-file-tags.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/get-file-tags.ts
new file mode 100644
index 00000000000..350756335df
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/get-file-tags.ts
@@ -0,0 +1,51 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3GetFileTagsOutputSchema } from '../../output-schemas';
+
+export const amazonS3GetFileTags = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_get_file_tags',
+ outputSchema: amazonS3GetFileTagsOutputSchema,
+ displayName: 'Get File Tags',
+ description: 'Gets the tags on a file.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets the key-value tags on a file in the connected S3 bucket (at most 10 per file); a file with no tags returns an empty list. Read these before Set File Tags when adding a tag, since setting replaces the whole set.',
+ idempotent: true,
+ },
+ props: {
+ key: Property.ShortText({
+ displayName: 'File Key',
+ description: 'The full key (path) of the file, as returned by List Files.',
+ required: true,
+ }),
+ versionId: Property.ShortText({
+ displayName: 'Version ID',
+ description: 'A version id from List File Versions. Leave empty for the current version.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { key, versionId } = context.propsValue;
+
+ const response = await s3AiCommon.call({
+ key,
+ request: () =>
+ s3.getObjectTagging({ Bucket: bucket, Key: key, VersionId: versionId || undefined }),
+ });
+ const tags = (response.TagSet ?? []).map((tag) => ({
+ key: tag.Key ?? null,
+ value: tag.Value ?? null,
+ }));
+
+ return { key, versionId: response.VersionId ?? null, tags, count: tags.length };
+ },
+});
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/index.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/index.ts
new file mode 100644
index 00000000000..ec2c0a8e381
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/index.ts
@@ -0,0 +1,25 @@
+import { amazonS3CopyFile } from './copy-file';
+import { amazonS3DeleteFileTags } from './delete-file-tags';
+import { amazonS3DeleteFiles } from './delete-files';
+import { amazonS3GetFileMetadata } from './get-file-metadata';
+import { amazonS3GetFileTags } from './get-file-tags';
+import { amazonS3ListFileVersions } from './list-file-versions';
+import { amazonS3ListFilesAi } from './list-files';
+import { amazonS3MoveFileAi } from './move-file';
+import { amazonS3ReadFileAi } from './read-file';
+import { amazonS3SetFileTags } from './set-file-tags';
+import { amazonS3UploadFileAi } from './upload-file';
+
+export const amazonS3AiActions = [
+ amazonS3ListFilesAi,
+ amazonS3GetFileMetadata,
+ amazonS3ReadFileAi,
+ amazonS3UploadFileAi,
+ amazonS3CopyFile,
+ amazonS3MoveFileAi,
+ amazonS3DeleteFiles,
+ amazonS3GetFileTags,
+ amazonS3SetFileTags,
+ amazonS3DeleteFileTags,
+ amazonS3ListFileVersions,
+];
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/list-file-versions.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/list-file-versions.ts
new file mode 100644
index 00000000000..41b420a4df3
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/list-file-versions.ts
@@ -0,0 +1,91 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3ListFileVersionsOutputSchema } from '../../output-schemas';
+
+export const amazonS3ListFileVersions = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_list_file_versions',
+ outputSchema: amazonS3ListFileVersionsOutputSchema,
+ displayName: 'List File Versions',
+ description: 'Lists the versions and delete markers of files in the connected bucket.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists every stored version and delete marker of files under a key prefix in the connected S3 bucket, newest first per key, one page at a time; pass nextKeyMarker and nextVersionIdMarker to continue. The returned version ids work with Read File, Get File Metadata and Copy File, e.g. to restore a version by copying it over the current key. On a bucket without versioning each file has one version with id "null".',
+ idempotent: true,
+ },
+ props: {
+ prefix: Property.ShortText({
+ displayName: 'Key Prefix',
+ description:
+ 'Only list versions of keys that start with this prefix, e.g. a full file key or "reports/". Leave empty for the whole bucket.',
+ required: false,
+ }),
+ maxResults: Property.Number({
+ displayName: 'Max Results',
+ description:
+ 'Maximum number of versions and delete markers to return in this page (1–1000). Defaults to 100.',
+ required: false,
+ }),
+ keyMarker: Property.ShortText({
+ displayName: 'Key Marker',
+ description: 'The nextKeyMarker from a previous call, to get the next page.',
+ required: false,
+ }),
+ versionIdMarker: Property.ShortText({
+ displayName: 'Version ID Marker',
+ description: 'The nextVersionIdMarker from a previous call; use together with Key Marker.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { prefix, maxResults, keyMarker, versionIdMarker } = context.propsValue;
+
+ if (versionIdMarker && !keyMarker) {
+ throw new Error('Version ID Marker needs Key Marker as well.');
+ }
+
+ const response = await s3AiCommon.call({
+ request: () =>
+ s3.listObjectVersions({
+ Bucket: bucket,
+ Prefix: prefix || undefined,
+ MaxKeys: Math.min(Math.max(maxResults ?? 100, 1), 1000),
+ KeyMarker: keyMarker || undefined,
+ VersionIdMarker: versionIdMarker || undefined,
+ }),
+ });
+
+ const versions = (response.Versions ?? []).map((version) => ({
+ key: version.Key ?? null,
+ versionId: version.VersionId ?? null,
+ isLatest: version.IsLatest ?? false,
+ size: version.Size ?? null,
+ lastModified: s3AiCommon.toIso(version.LastModified),
+ etag: version.ETag ?? null,
+ storageClass: version.StorageClass ?? null,
+ }));
+ const deleteMarkers = (response.DeleteMarkers ?? []).map((marker) => ({
+ key: marker.Key ?? null,
+ versionId: marker.VersionId ?? null,
+ isLatest: marker.IsLatest ?? false,
+ lastModified: s3AiCommon.toIso(marker.LastModified),
+ }));
+
+ return {
+ versions,
+ deleteMarkers,
+ count: versions.length + deleteMarkers.length,
+ isTruncated: response.IsTruncated ?? false,
+ nextKeyMarker: response.NextKeyMarker ?? null,
+ nextVersionIdMarker: response.NextVersionIdMarker ?? null,
+ };
+ },
+});
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/list-files.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/list-files.ts
new file mode 100644
index 00000000000..02ca255711d
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/list-files.ts
@@ -0,0 +1,92 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3ListFilesOutputSchema } from '../../output-schemas';
+
+export const amazonS3ListFilesAi = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_list_files',
+ outputSchema: amazonS3ListFilesOutputSchema,
+ displayName: 'List Files',
+ description:
+ 'Lists files in the connected bucket, optionally under a folder, one page at a time.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists files (object keys) in the connected S3 bucket, optionally under a folder prefix, in key order, one page at a time; pass the returned nextContinuationToken to get the next page. Set "List Folders Separately" to see only the immediate files and subfolders of a prefix instead of every nested file. Use it to find the exact key that the read, copy, move, tag and delete actions need.',
+ idempotent: true,
+ },
+ props: {
+ prefix: Property.ShortText({
+ displayName: 'Folder Prefix',
+ description:
+ 'Only list keys that start with this prefix, e.g. "invoices/2024/". Leave empty for the whole bucket.',
+ required: false,
+ }),
+ listFoldersSeparately: Property.Checkbox({
+ displayName: 'List Folders Separately',
+ description:
+ 'Group keys by "/": return the immediate subfolders under the prefix in "folders" and only the files directly in it in "files".',
+ required: false,
+ defaultValue: false,
+ }),
+ maxResults: Property.Number({
+ displayName: 'Max Results',
+ description:
+ 'Maximum number of files and folders to return in this page (1–1000). Defaults to 100.',
+ required: false,
+ }),
+ continuationToken: Property.ShortText({
+ displayName: 'Continuation Token',
+ description: 'The nextContinuationToken from a previous call, to get the next page.',
+ required: false,
+ }),
+ startAfter: Property.ShortText({
+ displayName: 'Start After Key',
+ description:
+ 'Only list keys that sort after this key. Ignored when a continuation token is given.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { prefix, listFoldersSeparately, maxResults, continuationToken, startAfter } =
+ context.propsValue;
+
+ const response = await s3AiCommon.call({
+ request: () =>
+ s3.listObjectsV2({
+ Bucket: bucket,
+ Prefix: prefix || undefined,
+ Delimiter: listFoldersSeparately ? '/' : undefined,
+ MaxKeys: Math.min(Math.max(maxResults ?? 100, 1), 1000),
+ ContinuationToken: continuationToken || undefined,
+ StartAfter: startAfter || undefined,
+ }),
+ });
+
+ const files = (response.Contents ?? []).map((object) => ({
+ key: object.Key ?? null,
+ size: object.Size ?? null,
+ lastModified: s3AiCommon.toIso(object.LastModified),
+ etag: object.ETag ?? null,
+ storageClass: object.StorageClass ?? null,
+ }));
+ const folders = (response.CommonPrefixes ?? []).flatMap((folder) =>
+ folder.Prefix ? [folder.Prefix] : [],
+ );
+
+ return {
+ files,
+ folders,
+ count: files.length,
+ isTruncated: response.IsTruncated ?? false,
+ nextContinuationToken: response.NextContinuationToken ?? null,
+ };
+ },
+});
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/move-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/move-file.ts
new file mode 100644
index 00000000000..6825da9e96e
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/move-file.ts
@@ -0,0 +1,65 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3MoveFileOutputSchema } from '../../output-schemas';
+
+export const amazonS3MoveFileAi = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_move_file',
+ outputSchema: amazonS3MoveFileOutputSchema,
+ displayName: 'Move File',
+ description: 'Moves or renames a file within the connected bucket.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Moves or renames a file in the connected S3 bucket by copying it to the destination key and then deleting the source key; a file already at the destination is replaced. Not idempotent: after the first run the source key no longer exists, so a repeat fails. Files over 5 GB cannot be moved in one call.',
+ idempotent: false,
+ },
+ props: {
+ sourceKey: Property.ShortText({
+ displayName: 'Source File Key',
+ description: 'The full key of the file to move, as returned by List Files.',
+ required: true,
+ }),
+ destinationKey: Property.ShortText({
+ displayName: 'Destination File Key',
+ description: 'The new full key, including the file name, e.g. "archive/2024/q1.csv".',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { sourceKey, destinationKey } = context.propsValue;
+
+ if (sourceKey === destinationKey) {
+ throw new Error('Source and destination keys are the same.');
+ }
+
+ const copied = await s3AiCommon.call({
+ key: sourceKey,
+ request: () =>
+ s3.copyObject({
+ Bucket: bucket,
+ Key: destinationKey,
+ CopySource: s3AiCommon.copySource({ bucket, key: sourceKey }),
+ }),
+ });
+ await s3AiCommon.call({
+ key: sourceKey,
+ request: () => s3.deleteObject({ Bucket: bucket, Key: sourceKey }),
+ });
+
+ return {
+ sourceKey,
+ destinationKey,
+ versionId: copied.VersionId ?? null,
+ etag: copied.CopyObjectResult?.ETag ?? null,
+ lastModified: s3AiCommon.toIso(copied.CopyObjectResult?.LastModified),
+ };
+ },
+});
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/read-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/read-file.ts
new file mode 100644
index 00000000000..f5f0929d6a9
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/read-file.ts
@@ -0,0 +1,105 @@
+import { Readable } from 'node:stream';
+
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3ReadFileOutputSchema } from '../../output-schemas';
+
+export const amazonS3ReadFileAi = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_read_file',
+ outputSchema: amazonS3ReadFileOutputSchema,
+ displayName: 'Read File',
+ description: 'Reads a file, returning text content inline and the file itself for later steps.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads a file by key and returns it as a stored file for later steps. For text files (text/*, JSON, CSV, XML, YAML) up to 10 MB it also returns the text in "content", decoded with the declared charset (UTF-8 when none) and cut at 100,000 characters with "truncated" set; binary files, larger files and unsupported charsets return content null. Pass a version id from List File Versions to read an older version.',
+ idempotent: true,
+ },
+ props: {
+ key: Property.ShortText({
+ displayName: 'File Key',
+ description:
+ 'The full key (path) of the file, e.g. "reports/2024/q1.csv", as returned by List Files.',
+ required: true,
+ }),
+ versionId: Property.ShortText({
+ displayName: 'Version ID',
+ description: 'A version id from List File Versions. Leave empty for the current version.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { key, versionId } = context.propsValue;
+
+ const response = await s3AiCommon.call({
+ key,
+ request: () => s3.getObject({ Bucket: bucket, Key: key, VersionId: versionId || undefined }),
+ });
+ if (!response.Body) {
+ throw new Error(`File "${key}" returned no content.`);
+ }
+
+ const fileName = key.split('/').pop() || key;
+ const size = response.ContentLength ?? null;
+ const isText = s3AiCommon.isTextContentType(response.ContentType);
+ const inlineText = isText && size !== null && size <= MAX_INLINE_BYTES;
+
+ const { content, truncated, data } = inlineText
+ ? readText({
+ bytes: await response.Body.transformToByteArray(),
+ contentType: response.ContentType,
+ })
+ : { content: null, truncated: isText, data: response.Body };
+
+ if (!(data instanceof Buffer) && !(data instanceof Readable)) {
+ throw new Error(`Could not read file "${key}" from S3.`);
+ }
+ const file = await context.files.write({ fileName, data });
+
+ return {
+ key,
+ versionId: response.VersionId ?? null,
+ contentType: response.ContentType ?? null,
+ size,
+ lastModified: s3AiCommon.toIso(response.LastModified),
+ etag: response.ETag ?? null,
+ content,
+ truncated,
+ file,
+ };
+ },
+});
+
+function readText({ bytes, contentType }: { bytes: Uint8Array; contentType: string | undefined }) {
+ const data = Buffer.from(bytes);
+ const decoder = textDecoder({ contentType });
+ if (!decoder) {
+ return { content: null, truncated: false, data };
+ }
+ const text = decoder.decode(data);
+ return {
+ content: text.slice(0, MAX_INLINE_CHARS),
+ truncated: text.length > MAX_INLINE_CHARS,
+ data,
+ };
+}
+
+function textDecoder({ contentType }: { contentType: string | undefined }): TextDecoder | null {
+ const charset = /charset=["']?([^;"'\s]+)/i.exec(contentType ?? '')?.[1] ?? 'utf-8';
+ try {
+ return new TextDecoder(charset);
+ } catch {
+ return null;
+ }
+}
+
+const MAX_INLINE_BYTES = 10 * 1024 * 1024;
+const MAX_INLINE_CHARS = 100_000;
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/set-file-tags.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/set-file-tags.ts
new file mode 100644
index 00000000000..ec5c7a7fedd
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/set-file-tags.ts
@@ -0,0 +1,76 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3GetFileTagsOutputSchema } from '../../output-schemas';
+
+export const amazonS3SetFileTags = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_set_file_tags',
+ outputSchema: amazonS3GetFileTagsOutputSchema,
+ displayName: 'Set File Tags',
+ description: 'Replaces all tags on a file with the given set.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Replaces the whole tag set on a file in the connected S3 bucket with the given key-value pairs (1–10 tags; keys up to 128 and values up to 256 characters). Tags not in the input are removed, so to add one, read the current tags with Get File Tags and send them all. Use Delete File Tags to clear every tag.',
+ idempotent: true,
+ },
+ props: {
+ key: Property.ShortText({
+ displayName: 'File Key',
+ description: 'The full key (path) of the file, as returned by List Files.',
+ required: true,
+ }),
+ tags: Property.Object({
+ displayName: 'Tags',
+ description:
+ 'The complete tag set as key-value pairs, e.g. {"project": "alpha", "status": "final"}.',
+ required: true,
+ }),
+ versionId: Property.ShortText({
+ displayName: 'Version ID',
+ description: 'A version id from List File Versions. Leave empty for the current version.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { key, tags, versionId } = context.propsValue;
+
+ const tagSet = Object.entries(tags).map(([name, value]) => ({
+ Key: name,
+ Value: typeof value === 'string' ? value : JSON.stringify(value),
+ }));
+ if (tagSet.length === 0) {
+ throw new Error('Provide at least one tag, or use Delete File Tags to remove all tags.');
+ }
+ if (tagSet.length > MAX_TAGS) {
+ throw new Error(`A file can have at most ${MAX_TAGS} tags; got ${tagSet.length}.`);
+ }
+
+ const response = await s3AiCommon.call({
+ key,
+ request: () =>
+ s3.putObjectTagging({
+ Bucket: bucket,
+ Key: key,
+ VersionId: versionId || undefined,
+ Tagging: { TagSet: tagSet },
+ }),
+ });
+
+ return {
+ key,
+ versionId: response.VersionId ?? null,
+ tags: tagSet.map((tag) => ({ key: tag.Key, value: tag.Value })),
+ count: tagSet.length,
+ };
+ },
+});
+
+const MAX_TAGS = 10;
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/ai/upload-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/ai/upload-file.ts
new file mode 100644
index 00000000000..26e47cb289a
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/ai/upload-file.ts
@@ -0,0 +1,116 @@
+import { Upload } from '@aws-sdk/lib-storage';
+import mime from 'mime-types';
+
+import { streamUtils } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { s3AiCommon } from './ai-common';
+import { amazonS3CombinedAuth, S3AuthProps } from '../../auth';
+import { resolveS3Client } from '../../common';
+import { amazonS3UploadFileOutputSchema } from '../../output-schemas';
+
+export const amazonS3UploadFileAi = createAction({
+ auth: amazonS3CombinedAuth,
+ name: 'amazon_s3_upload_file',
+ outputSchema: amazonS3UploadFileOutputSchema,
+ displayName: 'Upload File',
+ description: 'Uploads a file or text content to an exact key in the connected bucket.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Writes a file or text content to an exact key in the connected S3 bucket, replacing any file already at that key unless "Do Not Overwrite" is set. Provide exactly one of File or Text Content. The content type is taken from the input, else guessed from the key\'s extension. Re-running with the same key and content leaves the same result.',
+ idempotent: true,
+ },
+ props: {
+ key: Property.ShortText({
+ displayName: 'File Key',
+ description:
+ 'The full key (path) to write, including the file name and extension, e.g. "reports/2024/q1.csv".',
+ required: true,
+ }),
+ file: Property.File({
+ displayName: 'File',
+ description: 'The file to upload. Leave empty when using Text Content.',
+ required: false,
+ streaming: true,
+ }),
+ textContent: Property.LongText({
+ displayName: 'Text Content',
+ description:
+ 'Text to store as the file content, e.g. CSV or JSON. Leave empty when using File.',
+ required: false,
+ }),
+ contentType: Property.ShortText({
+ displayName: 'Content Type',
+ description: 'MIME type, e.g. "text/csv". Leave empty to guess from the key\'s extension.',
+ required: false,
+ }),
+ metadata: Property.Object({
+ displayName: 'Custom Metadata',
+ description: 'Key-value pairs stored with the file as user metadata (x-amz-meta-*).',
+ required: false,
+ }),
+ doNotOverwrite: Property.Checkbox({
+ displayName: 'Do Not Overwrite',
+ description: 'Fail instead of replacing a file that already exists at this key.',
+ required: false,
+ defaultValue: false,
+ }),
+ },
+ async run(context) {
+ const authProps: S3AuthProps = context.auth.props;
+ const { bucket } = authProps;
+ const s3 = await resolveS3Client({ authProps, server: context.server });
+ const { key, file, textContent, contentType, metadata, doNotOverwrite } = context.propsValue;
+
+ const hasText = textContent !== undefined && textContent !== null && textContent !== '';
+ if (file && hasText) {
+ throw new Error('Provide either File or Text Content, not both.');
+ }
+ if (!file && !hasText) {
+ throw new Error('Provide File or Text Content to upload.');
+ }
+
+ const resolvedContentType =
+ contentType ||
+ mime.lookup(key) ||
+ (file?.extension ? mime.lookup(file.extension) : false) ||
+ (hasText ? 'text/plain; charset=utf-8' : 'application/octet-stream');
+ const body = file
+ ? streamUtils.toStreamingBody(file).body
+ : Buffer.from(textContent ?? '', 'utf8');
+
+ const response = await s3AiCommon.call({
+ key,
+ request: () =>
+ new Upload({
+ client: s3,
+ params: {
+ Bucket: bucket,
+ Key: key,
+ Body: body,
+ ContentType: resolvedContentType,
+ Metadata: metadata ? toStringRecord({ value: metadata }) : undefined,
+ IfNoneMatch: doNotOverwrite ? '*' : undefined,
+ },
+ }).done(),
+ });
+
+ return {
+ key,
+ contentType: resolvedContentType,
+ etag: response.ETag ?? null,
+ versionId: response.VersionId ?? null,
+ };
+ },
+});
+
+function toStringRecord({ value }: { value: Record<string, unknown> }): Record<string, string> {
+ return Object.fromEntries(
+ Object.entries(value).map(([name, item]) => [
+ name,
+ typeof item === 'string' ? item : JSON.stringify(item),
+ ]),
+ );
+}
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/decrypt-pgp-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/decrypt-pgp-file.ts
index be3712197bb..5005be20f61 100644
--- a/packages/pieces/community/amazon-s3/src/lib/actions/decrypt-pgp-file.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/decrypt-pgp-file.ts
@@ -4,10 +4,12 @@ import { S3 } from '@aws-sdk/client-s3';
import * as openpgp from 'openpgp';
import { amazonS3CombinedAuth, S3AuthProps } from '../auth';
import { createS3, createSecretsManagerClient, getTemporaryCredentials, isOidcAuth } from '../common';
+import { readFileOutputSchema } from '../output-schemas';
export const decryptPgpFile = createAction({
auth: amazonS3CombinedAuth,
name: 'decrypt-pgp-file',
+ outputSchema: readFileOutputSchema,
classification: 'READ',
displayName: 'Decrypt PGP File',
description: 'Decrypt a PGP encrypted file from S3 using a private key stored in AWS Secrets Manager',
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/delete-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/delete-file.ts
index 500fdd647f1..18401f11317 100644
--- a/packages/pieces/community/amazon-s3/src/lib/actions/delete-file.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/delete-file.ts
@@ -1,10 +1,12 @@
import { Property, createAction } from '@activepieces/pieces-framework';
import { amazonS3CombinedAuth, S3AuthProps } from '../auth';
import { resolveS3Client } from '../common';
+import { deleteFileOutputSchema } from '../output-schemas';
export const deleteFile = createAction({
auth: amazonS3CombinedAuth,
name: 'deleteFile',
+ outputSchema: deleteFileOutputSchema,
classification: 'DESTRUCTIVE',
displayName: 'Delete File',
description: 'Deletes an existing file.',
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/generate-signed-upload-url.ts b/packages/pieces/community/amazon-s3/src/lib/actions/generate-signed-upload-url.ts
index b9cde96ac84..367df296a37 100644
--- a/packages/pieces/community/amazon-s3/src/lib/actions/generate-signed-upload-url.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/generate-signed-upload-url.ts
@@ -3,10 +3,12 @@ import { PutObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { amazonS3CombinedAuth, AccessKeyAuthProps, OidcAuthProps, S3AuthProps } from '../auth';
import { createS3, createS3WithAssumeRole, isOidcAuth, MAX_STS_DURATION_SECONDS, MIN_STS_DURATION_SECONDS } from '../common';
+import { generateSignedUploadUrlOutputSchema } from '../output-schemas';
export const generateSignedUploadUrl = createAction({
auth: amazonS3CombinedAuth,
name: 'generate-signed-upload-url',
+ outputSchema: generateSignedUploadUrlOutputSchema,
classification: 'READ',
displayName: 'Generate Signed Upload URL',
description:
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/generate-signed-url.ts b/packages/pieces/community/amazon-s3/src/lib/actions/generate-signed-url.ts
index 08b7300ade9..45b9ee7f0bb 100644
--- a/packages/pieces/community/amazon-s3/src/lib/actions/generate-signed-url.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/generate-signed-url.ts
@@ -3,10 +3,12 @@ import { GetObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { amazonS3CombinedAuth, AccessKeyAuthProps, OidcAuthProps, S3AuthProps } from '../auth';
import { createS3, createS3WithAssumeRole, isOidcAuth, MAX_STS_DURATION_SECONDS, MIN_STS_DURATION_SECONDS } from '../common';
+import { generateSignedUrlOutputSchema } from '../output-schemas';
export const generateSignedUrl = createAction({
auth: amazonS3CombinedAuth,
name: 'generate-signed-url',
+ outputSchema: generateSignedUrlOutputSchema,
classification: 'READ',
displayName: 'Generate signed URL',
description: 'Generate a signed URL for a file in a s3 bucket',
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/list-files.ts b/packages/pieces/community/amazon-s3/src/lib/actions/list-files.ts
index eac3c64423f..221f67d0389 100644
--- a/packages/pieces/community/amazon-s3/src/lib/actions/list-files.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/list-files.ts
@@ -2,6 +2,7 @@ import { Property, createAction } from '@activepieces/pieces-framework';
import { amazonS3CombinedAuth, S3AuthProps } from '../auth';
import { resolveS3Client } from '../common';
import { ListObjectsV2CommandInput } from '@aws-sdk/client-s3';
+import { listFilesOutputSchema } from '../output-schemas';
interface S3File {
key: string;
@@ -20,10 +21,11 @@ interface ListFilesResult {
export const listFiles = createAction({
auth: amazonS3CombinedAuth,
name: 'list-files',
+ outputSchema: listFilesOutputSchema,
classification: 'SEARCH',
displayName: 'List Files',
description: 'List all files from an S3 bucket folder/prefix.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Lists objects in the configured S3 bucket, optionally filtered to a folder prefix (empty prefix lists the whole bucket), capped at a maximum count (1-1000, default 1000) and sorted newest-first. Use to discover files or look up an object key before reading, moving, or deleting it. Read-only and idempotent.',
idempotent: true,
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/move-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/move-file.ts
index 36da08ce0d2..58b88273770 100644
--- a/packages/pieces/community/amazon-s3/src/lib/actions/move-file.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/move-file.ts
@@ -1,14 +1,16 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { amazonS3CombinedAuth, S3AuthProps } from '../auth';
import { resolveS3Client } from '../common';
+import { moveFileOutputSchema } from '../output-schemas';
export const moveFile = createAction({
auth: amazonS3CombinedAuth,
name: 'moveFile',
+ outputSchema: moveFileOutputSchema,
classification: 'WRITE',
displayName: 'Move File',
description: 'Move a File to Another Folder',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Moves an object within the configured S3 bucket by copying it to a new key under the destination folder (keeping the same filename) and then deleting the original. Use to relocate or archive a file. Not idempotent — the source object is deleted on the first successful run, so a repeat call errors because the source key no longer exists.',
idempotent: false,
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/read-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/read-file.ts
index 380b1d070f9..5e6980dc891 100644
--- a/packages/pieces/community/amazon-s3/src/lib/actions/read-file.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/read-file.ts
@@ -2,14 +2,16 @@ import { Readable } from 'node:stream';
import { Property, createAction } from '@activepieces/pieces-framework';
import { amazonS3CombinedAuth, S3AuthProps } from '../auth';
import { resolveS3Client } from '../common';
+import { readFileOutputSchema } from '../output-schemas';
export const readFile = createAction({
auth: amazonS3CombinedAuth,
name: 'read-file',
+ outputSchema: readFileOutputSchema,
classification: 'READ',
displayName: 'Read File',
description: 'Read a file from S3 to use it in other steps',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Downloads a single object from the configured S3 bucket by its full key (path) and makes its contents available as a file for later steps. Use to fetch a known file when you have its exact key. Reading the same key repeatedly returns the same content with no side effect (idempotent).',
idempotent: true,
diff --git a/packages/pieces/community/amazon-s3/src/lib/actions/upload-file.ts b/packages/pieces/community/amazon-s3/src/lib/actions/upload-file.ts
index 984e65e4be6..9da6074215d 100644
--- a/packages/pieces/community/amazon-s3/src/lib/actions/upload-file.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/actions/upload-file.ts
@@ -5,14 +5,16 @@ import { amazonS3CombinedAuth, S3AuthProps } from '../auth';
import { resolveS3Client } from '../common';
import { ObjectCannedACL } from '@aws-sdk/client-s3';
import mime from 'mime-types';
+import { uploadFileOutputSchema } from '../output-schemas';
export const amazons3UploadFile = createAction({
auth: amazonS3CombinedAuth,
name: 'upload-file',
+ outputSchema: uploadFileOutputSchema,
classification: 'WRITE',
displayName: 'Upload File',
description: 'Upload an File to S3',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Uploads a file to the configured S3 bucket, optionally setting a destination filename, content type, and canned ACL (e.g. private vs. public-read). Use to store new content in S3. Not idempotent: when no filename is given a unique timestamp-based key is generated, so each call writes a new object.',
idempotent: false,
diff --git a/packages/pieces/community/amazon-s3/src/lib/output-schemas.ts b/packages/pieces/community/amazon-s3/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..72c070bd906
--- /dev/null
+++ b/packages/pieces/community/amazon-s3/src/lib/output-schemas.ts
@@ -0,0 +1,211 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const fileFields: OutputSchema['fields'] = [
+ { key: 'key', label: 'File Key' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ { key: 'lastModified', label: 'Last Modified', format: 'datetime' },
+ { key: 'etag', label: 'ETag' },
+ { key: 'storageClass', label: 'Storage Class' },
+];
+
+const tagFields: OutputSchema['fields'] = [
+ { key: 'key', label: 'File Key' },
+ { key: 'versionId', label: 'Version ID' },
+ {
+ key: 'tags',
+ label: 'Tags',
+ labelKey: 'key',
+ listItems: [
+ { key: 'key', label: 'Tag Key' },
+ { key: 'value', label: 'Tag Value' },
+ ],
+ },
+ { key: 'count', label: 'Tag Count', format: 'number' },
+];
+
+export const amazonS3ListFilesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'files', label: 'Files', labelKey: 'key', listItems: fileFields },
+ { key: 'folders', label: 'Folders' },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'isTruncated', label: 'Has More', format: 'boolean' },
+ { key: 'nextContinuationToken', label: 'Next Continuation Token' },
+ ],
+};
+
+export const amazonS3GetFileMetadataOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'key', label: 'File Key' },
+ { key: 'versionId', label: 'Version ID' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ { key: 'contentType', label: 'Content Type' },
+ { key: 'lastModified', label: 'Last Modified', format: 'datetime' },
+ { key: 'etag', label: 'ETag' },
+ { key: 'storageClass', label: 'Storage Class' },
+ { key: 'contentEncoding', label: 'Content Encoding' },
+ { key: 'contentDisposition', label: 'Content Disposition' },
+ { key: 'cacheControl', label: 'Cache Control' },
+ { key: 'serverSideEncryption', label: 'Server-Side Encryption' },
+ { key: 'metadata', label: 'Custom Metadata', dynamicKey: true },
+ ],
+};
+
+export const amazonS3ReadFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'key', label: 'File Key' },
+ { key: 'versionId', label: 'Version ID' },
+ { key: 'contentType', label: 'Content Type' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ { key: 'lastModified', label: 'Last Modified', format: 'datetime' },
+ { key: 'etag', label: 'ETag' },
+ { key: 'content', label: 'Text Content' },
+ { key: 'truncated', label: 'Truncated', format: 'boolean' },
+ { key: 'file', label: 'File', format: 'url' },
+ ],
+};
+
+export const amazonS3UploadFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'key', label: 'File Key' },
+ { key: 'contentType', label: 'Content Type' },
+ { key: 'etag', label: 'ETag' },
+ { key: 'versionId', label: 'Version ID' },
+ ],
+};
+
+export const amazonS3CopyFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'sourceKey', label: 'Source File Key' },
+ { key: 'destinationKey', label: 'Destination File Key' },
+ { key: 'sourceVersionId', label: 'Source Version ID' },
+ { key: 'versionId', label: 'Version ID' },
+ { key: 'etag', label: 'ETag' },
+ { key: 'lastModified', label: 'Last Modified', format: 'datetime' },
+ ],
+};
+
+export const amazonS3MoveFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'sourceKey', label: 'Source File Key' },
+ { key: 'destinationKey', label: 'Destination File Key' },
+ { key: 'versionId', label: 'Version ID' },
+ { key: 'etag', label: 'ETag' },
+ { key: 'lastModified', label: 'Last Modified', format: 'datetime' },
+ ],
+};
+
+export const amazonS3DeleteFilesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'All Deleted', format: 'boolean' },
+ { key: 'deletedCount', label: 'Deleted Count', format: 'number' },
+ { key: 'failedCount', label: 'Failed Count', format: 'number' },
+ {
+ key: 'deleted',
+ label: 'Deleted Files',
+ labelKey: 'key',
+ listItems: [
+ { key: 'key', label: 'File Key' },
+ { key: 'versionId', label: 'Version ID' },
+ { key: 'deleteMarker', label: 'Delete Marker', format: 'boolean' },
+ ],
+ },
+ { key: 'failed', label: 'Failed Files' },
+ ],
+};
+
+export const amazonS3GetFileTagsOutputSchema: OutputSchema = { fields: tagFields };
+
+export const amazonS3DeleteFileTagsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'key', label: 'File Key' },
+ { key: 'versionId', label: 'Version ID' },
+ { key: 'deleted', label: 'Deleted', format: 'boolean' },
+ ],
+};
+
+export const amazonS3ListFileVersionsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'versions',
+ label: 'Versions',
+ labelKey: 'key',
+ listItems: [
+ ...fileFields,
+ { key: 'versionId', label: 'Version ID' },
+ { key: 'isLatest', label: 'Is Latest', format: 'boolean' },
+ ],
+ },
+ { key: 'deleteMarkers', label: 'Delete Markers' },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'isTruncated', label: 'Has More', format: 'boolean' },
+ { key: 'nextKeyMarker', label: 'Next Key Marker' },
+ { key: 'nextVersionIdMarker', label: 'Next Version ID Marker' },
+ ],
+};
+
+export const generateSignedUrlOutputSchema: OutputSchema = {
+ fields: [{ key: 'signedUrl', label: 'Signed URL', value: '', format: 'url' }],
+};
+
+export const generateSignedUploadUrlOutputSchema: OutputSchema = {
+ fields: [{ key: 'url', label: 'Signed Upload URL', format: 'url' }],
+};
+
+export const newFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'Key', label: 'File Key' },
+ { key: 'LastModified', label: 'Last Modified', format: 'datetime' },
+ { key: 'ETag', label: 'ETag' },
+ { key: 'Size', label: 'Size', format: 'filesize' },
+ { key: 'StorageClass', label: 'Storage Class' },
+ { key: 'ChecksumAlgorithm', label: 'Checksum Algorithm' },
+ { key: 'ChecksumType', label: 'Checksum Type' },
+ ],
+};
+
+export const deleteFileOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: '$metadata',
+ label: 'Response',
+ children: [
+ { key: 'httpStatusCode', label: 'HTTP Status Code', format: 'number' },
+ { key: 'requestId', label: 'Request ID' },
+ ],
+ },
+ ],
+};
+
+export const listFilesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'files', label: 'Files', labelKey: 'key', listItems: fileFields },
+ { key: 'isTruncated', label: 'Has More', format: 'boolean' },
+ ],
+};
+
+export const moveFileOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'CopyObjectResult',
+ label: 'Copy Result',
+ children: [
+ { key: 'ETag', label: 'ETag' },
+ { key: 'LastModified', label: 'Last Modified', format: 'datetime' },
+ { key: 'ChecksumType', label: 'Checksum Type' },
+ { key: 'ChecksumCRC32', label: 'Checksum CRC32' },
+ ],
+ },
+ { key: 'ServerSideEncryption', label: 'Server-Side Encryption' },
+ ],
+};
+
+export const readFileOutputSchema: OutputSchema = {
+ fields: [{ key: 'file', label: 'File', value: '', format: 'url' }],
+};
+
+export const uploadFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'fileName', label: 'File Key' },
+ { key: 'etag', label: 'ETag' },
+ ],
+};
diff --git a/packages/pieces/community/amazon-s3/src/lib/triggers/new-file.ts b/packages/pieces/community/amazon-s3/src/lib/triggers/new-file.ts
index 16e42c5c0ec..6fe3b1cda79 100644
--- a/packages/pieces/community/amazon-s3/src/lib/triggers/new-file.ts
+++ b/packages/pieces/community/amazon-s3/src/lib/triggers/new-file.ts
@@ -5,6 +5,7 @@ import { MarkdownVariant } from '@activepieces/pieces-framework';
import dayjs from 'dayjs';
import { amazonS3CombinedAuth, S3AuthProps } from '../auth';
import { resolveS3Client } from '../common';
+import { newFileOutputSchema } from '../output-schemas';
const polling: Polling<AppConnectionValueForAuthProperty<typeof amazonS3CombinedAuth>, { folderPath?: string }> = {
strategy: DedupeStrategy.TIMEBASED,
@@ -27,6 +28,7 @@ const polling: Polling<AppConnectionValueForAuthProperty<typeof amazonS3Combined
export const newFile = createTrigger({
auth: amazonS3CombinedAuth,
name: 'new_file',
+ outputSchema: newFileOutputSchema,
classification: 'READ',
displayName: 'New or Updated File',
description: 'Triggers when you add or update a file in your bucket. The bucket/folder you choose must not contain more than 10,000 files.',