Compare commits
1 Commits
main
...
feat/agent
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f449fa3c8 |
@ -52,7 +52,7 @@ export class LoadToolsService {
|
||||
id: 'postiz',
|
||||
name: 'postiz',
|
||||
description:
|
||||
'Agent that helps schedule and list social media posts for users',
|
||||
'Agent that helps schedule, list and delete social media posts for users',
|
||||
instructions: ({ requestContext }) => {
|
||||
const ui: string = requestContext.get('ui' as never);
|
||||
return `
|
||||
@ -63,6 +63,7 @@ export class LoadToolsService {
|
||||
- Schedule posts into the future, or now, adding texts, images and videos
|
||||
- List the posts scheduled between two dates (postsListTool)
|
||||
- Update the settings of a scheduled post or draft that was not published yet (postSettingsTool)
|
||||
- Delete a post (deletePostTool)
|
||||
- Generate pictures for posts
|
||||
- Generate videos for posts
|
||||
- Generate text for posts
|
||||
@ -88,7 +89,7 @@ export class LoadToolsService {
|
||||
- To find or inspect existing posts, use postsListTool with a UTC start and end date - it returns every post scheduled in that window. To cover "all my upcoming posts", pass a wide window starting now.
|
||||
- To change the provider settings of an existing post that was not published yet (scheduled or draft), first find it with postsListTool, then use postSettingsTool with the post's id. It only updates the settings - the content and the publish date stay as they are - and only the keys you pass are changed (get them with the integrationSchema tool). Show the user which post and which settings will change and get their confirmation first.
|
||||
- Never open the "modal with populated content" to edit an existing post - that modal only CREATES a new post, so using it to edit would duplicate the post. It is only for brand new posts.
|
||||
- You can create, schedule and update posts, but you CANNOT delete posts - there is no delete capability. Never offer to delete a post. If the user asks you to delete one, tell them deletion is a destructive action and they should delete it themselves in the Postiz app (the calendar).
|
||||
- To delete a post, first find it with postsListTool, then use deletePostTool with the post's id, one post per call. It deletes the post together with its thread items / comments and cannot be undone; a post scheduled to several channels is a separate post per channel, so delete each one; a published post is only removed from Postiz and stays live on the social network. Always show the user which post(s) will be deleted and get their explicit confirmation first.
|
||||
- Between tools, we will reference things like: [output:name] and [input:name] to set the information right.
|
||||
- When outputting a date for the user, make sure it's human readable with time
|
||||
- The content of the post, HTML, Each line must be wrapped in <p> here is the possible tags: h1, h2, h3, u, strong, li, ul, p (you can\'t have u and strong together), don't use a "code" box
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
import { AgentToolInterface } from '@gitroom/nestjs-libraries/chat/agent.tool.interface';
|
||||
import { createTool } from '@mastra/core/tools';
|
||||
import { z } from 'zod';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PostsService } from '@gitroom/nestjs-libraries/database/prisma/posts/posts.service';
|
||||
import { checkAuth } from '@gitroom/nestjs-libraries/chat/auth.context';
|
||||
|
||||
@Injectable()
|
||||
export class DeletePostTool implements AgentToolInterface {
|
||||
constructor(private _postsService: PostsService) {}
|
||||
name = 'deletePostTool';
|
||||
|
||||
run() {
|
||||
return createTool({
|
||||
id: 'deletePostTool',
|
||||
mcp: {
|
||||
annotations: {
|
||||
title: 'Delete Post',
|
||||
readOnlyHint: false,
|
||||
destructiveHint: true,
|
||||
idempotentHint: false,
|
||||
openWorldHint: false,
|
||||
},
|
||||
},
|
||||
description: `
|
||||
Delete an existing post (the same as the "Delete Post" API endpoint). This cannot be undone.
|
||||
Find the post first (list your posts) and pass its "id" here, one post per call.
|
||||
It deletes the post together with all of its thread items / comments. A post that was scheduled to several channels is a separate post per channel, each with its own "id" - deleting one leaves the others in place.
|
||||
A post that was already published is only removed from Postiz - it stays live on the social network.
|
||||
Always show the user which post(s) will be deleted and get their explicit confirmation before calling this tool.
|
||||
If it fails, the result contains output.errors.
|
||||
`,
|
||||
inputSchema: z.object({
|
||||
id: z.string().describe('The "id" of the post to delete'),
|
||||
}),
|
||||
outputSchema: z.object({
|
||||
output: z
|
||||
.object({
|
||||
id: z.string(),
|
||||
})
|
||||
.or(z.object({ errors: z.string() })),
|
||||
}),
|
||||
execute: async (inputData, context) => {
|
||||
checkAuth(inputData, context);
|
||||
const organizationId = JSON.parse(
|
||||
(context?.requestContext as any)?.get('organization') as string
|
||||
).id;
|
||||
|
||||
try {
|
||||
const post = await this._postsService.getPost(
|
||||
organizationId,
|
||||
inputData.id
|
||||
);
|
||||
|
||||
if (!post?.group) {
|
||||
return { output: { errors: 'Post not found' } };
|
||||
}
|
||||
|
||||
await this._postsService.deletePost(organizationId, post.group);
|
||||
|
||||
return { output: { id: inputData.id } };
|
||||
} catch (err: any) {
|
||||
return {
|
||||
output: {
|
||||
errors: 'Post not found or failed to delete',
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -59,7 +59,7 @@ A single LinkedIn post with one comment
|
||||
- socialPost array length will be 20
|
||||
- postsAndComments array length will be one
|
||||
|
||||
Do not use this to update or delete existing posts.
|
||||
Do not use this to update or delete existing posts - use postSettingsTool to update the settings of a post and deletePostTool to delete one.
|
||||
If validation fails, the result contains output.errors describing what to fix; the call can be retried with corrected parameters.
|
||||
`,
|
||||
inputSchema: z.object({
|
||||
|
||||
@ -39,7 +39,7 @@ List the organization's posts scheduled to be published between two dates (the s
|
||||
Returns every post in the window whatever its state (scheduled, draft, published, errored).
|
||||
"startDate" and "endDate" are required (UTC) - to list all upcoming posts, pass a wide window (for example from now to a year ahead).
|
||||
Each item has an "id", its publish date, state, content, channel and current provider settings.
|
||||
Posts cannot be deleted through the Postiz tools - if the user wants to delete a post, tell them to do it themselves in the Postiz app; never offer to delete a post.
|
||||
To delete a post, pass its "id" to deletePostTool - only after the user explicitly confirmed which post(s) to delete.
|
||||
`,
|
||||
inputSchema: z.object({
|
||||
startDate: z
|
||||
|
||||
@ -14,6 +14,7 @@ import { GroupListTool } from '@gitroom/nestjs-libraries/chat/tools/group.list.t
|
||||
import { UploadFromUrlTool } from '@gitroom/nestjs-libraries/chat/tools/upload.from.url.tool';
|
||||
import { PostsListTool } from '@gitroom/nestjs-libraries/chat/tools/posts.list.tool';
|
||||
import { PostSettingsTool } from '@gitroom/nestjs-libraries/chat/tools/post.settings.tool';
|
||||
import { DeletePostTool } from '@gitroom/nestjs-libraries/chat/tools/delete.post.tool';
|
||||
import { UploadWidgetTool } from '@gitroom/nestjs-libraries/chat/tools/upload.widget.tool';
|
||||
import { UploadWidgetTicketTool } from '@gitroom/nestjs-libraries/chat/tools/upload.widget.ticket.tool';
|
||||
import { UploadWidgetStatusTool } from '@gitroom/nestjs-libraries/chat/tools/upload.widget.status.tool';
|
||||
@ -26,6 +27,7 @@ export const toolList = [
|
||||
IntegrationSchedulePostTool,
|
||||
PostsListTool,
|
||||
PostSettingsTool,
|
||||
DeletePostTool,
|
||||
GenerateVideoOptionsTool,
|
||||
VideoFunctionTool,
|
||||
GenerateVideoTool,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user