This plugin allows you to integrate S3 functionalities into your Virtuals Game. With this plugin, you can upload files to S3, download files from S3, and more.
To install the plugin, use npm or yarn:
npm install @virtuals-protocol/game-s3-plugin
or
yarn add @virtuals-protocol/game-s3-plugin
First, import the S3Plugin
class from the plugin:
import S3Plugin from "@virtuals-protocol/game-s3-plugin";
Create a worker with the necessary Twitter credentials:
const s3Plugin = new S3Plugin({
credentials: {
accessKeyId: "AKEXAMPLES3S",
secretAccessKey: "SKEXAMPLES3S,
},
region: "us-east-1",
bucket: "virtuals-game-bucket",
endpoint: "http://localhost:8014",
sslEnabled: false,
forcePathStyle: true,
});
Create an agent and add the worker to it:
import { GameAgent } from "@virtuals-protocol/game";
const agent = new GameAgent("GAME_API_KEY", {
name: "S3 Agent",
goal: "Upload and download files to S3",
description: "An agent that can upload and download files to S3",
workers: [s3Plugin.getWorker()],
});
Initialize and run the agent:
(async () => {
await agent.init();
const task1 =
"Upload a file to the S3 bucket at the path `./package.json` and key `hello/world`, and use a signed URL with a TTL of 900 seconds";
const task2 =
"Download a file from the S3 bucket at key `hello/world` to the a file at `./test.txt`";
while (true) {
await agent.step({
verbose: true,
});
await agentS3Worker.runTask(task1, {
verbose: true,
});
await agentS3Worker.runTask(task2, {
verbose: true,
});
}
})();
The S3Plugin
provides several functions that can be used by the agent:
-
uploadFileFunction
: Upload a file to S3. Possible arguments:file_path
,object_key
,use_signed_url
,ttl
. -
downloadFileFunction
: Download a file from S3. Possible arguments:file_path
,object_key
.
This project is licensed under the MIT License.