Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom play book #61

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

Custom play book #61

wants to merge 25 commits into from

Conversation

PineappleChild
Copy link

@PineappleChild PineappleChild commented Apr 1, 2025

  • Added a custom playbook form that can generate playbook content using gpt-4o.
  • The playbook view table shows both built-in and custom playbooks, which are distinguished by a type category on the table.
  • The custom playbooks have an edit button allowing a user to access and edit the form to change the playbook description and content, along with using AI to generate more/new content, if needed, when editing.
  • Only custom playbooks can be edited
  • The edit form follows a similar style to that of the edit monitor, with a delete button in the edit form that asks for confirmation before deleting a custom playbook. If a custom playbook is being used for monitoring, then an error message appears, and the user is prevented from deleting the playbook before deleting the monitoring schedule
  • The custom playbooks work with both scheduling and the chat(they appear in the scheduling form and can be accessed by both the chat and the scheduling form/scheduler)
  • The code is split up in a similar way to that of the monitoring folder, with a separate file under db/ for db interactions and a separate file under tools/ for tools used by action.ts
  • Built-in and Custom playbooks can have their content copied into a new create custom playbook form; there is now a button to carry this out on the playbook table page. Each subsequent copy of the same playbook is identified by a (Copy 1), (Copy 2),...
    -The playbook table page only shows the run playbook button; all other features are in a dropdown menu to the right of the run playbook button

@PineappleChild PineappleChild requested review from tsg and SferaDev April 1, 2025 12:25
Copy link

vercel bot commented Apr 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
agent ✅ Ready (Inspect) Visit Preview Apr 4, 2025 5:18pm

Copy link
Member

@tsg tsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, but overall looks good!

export async function getCustomPlaybooks(projectId?: string, asUserId?: string): Promise<customPlaybook[]> {
if (!projectId) {
throw new Error('[INVALID_INPUT] Project ID is required');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to make projectId required as a parameter? The fact that you have to check for it existing here is dubious.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the code, and there is no apparent reason for projectId to be an optional parameter. I updated the code to reflect this.

export async function getTools(
connection: Connection,
asUserId?: string,
asProjectId?: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I realized it might have worked to use connection.projectId and then you don't need the asProjectId param. Or is there any case when asProjectId would be different from connection.projectId?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The asProjectId parameter is needed when getTools is called in runners.ts as getTools needs schedule.projectId to be passed into the method for the getPlaybooks portion of getTools to work with the scheduler. In all other cases, where getTools is called, connection.projectId is used instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could have used connections.projectId in runners.ts as well, it should be the same. Butthis way is maybe more explicit/clear, and I might have told you to add it :) Let's leave it like this, thanks for checking.

return listPlaybooks();
const playbookNames = listPlaybooks();
const projectId = asProjectId || connection.projectId;
const customPlaybookNames = await actionListCustomPlaybooksNames(projectId, asUserId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I'd say we have stuff in components import stuff from lib but preferably not the other way around. Just to reduce the chances of circular deps.

Since actionListCustomPlaybooksNames really only calls getListOfCustomPlaybooksNames I think you can just call that directly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the method calls for actionListCustomPlaybooksNames and actionGetCustomPlaybookContent to getListOfCustomPlaybooksNames and getCustomPlaybookContent, respectively, in the aidba.ts file to remove potential circular dependencies.

}

//get a custom playbook by Name (used in scheduler since names are given though getPlaybook)
export async function actionGetCustomPlaybookByName(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function used anywhere? I could find any matches.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, there are no references to this method. I will remove it from playbooks/action.ts.

… dependencies for actionGetCustomPlaybookContent and actionGetListOfCustomPlaybooksNames
…book functionality to be more consistent with the style given in editing monitoring schedules edit form
…ry to delete it, they are unable to delete the playbook until it is deleted from the scheduler
…ser is warned if a playbook is being used for monitoring when they try to delete it, they are unable to delete the playbook until it is deleted from the scheduler
…ser is warned if a playbook is being used for monitoring when they try to delete it, they are unable to delete the playbook until it is deleted from the scheduler
…able page, and added copy playbook feature for custom and built in playbooks
Copy link
Member

@SferaDev SferaDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! My only general comment is that there are many comments that feel redundant with the names of variables or functions. Code organization is good though and the feature seems to work as expected. Thanks!

Copy link
Member

@tsg tsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge from my PoV as well. Nice work @PineappleChild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants