Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
feat(anonymization): implement anonymizeText mutation and associated service
Dmitry Ng2f4da118e07c
diff --git a/backend/migrations/sql/20260510_120000_anonymize_privilege.sql b/backend/migrations/sql/20260510_120000_anonymize_privilege.sqlnew file mode 100644index 00000000..5e30b630--- /dev/null+++ b/backend/migrations/sql/20260510_120000_anonymize_privilege.sql@@ -0,0 +1,16 @@+-- +goose Up+-- +goose StatementBegin++INSERT INTO privileges (role_id, name) VALUES+ (1, 'anonymize.call'),+ (2, 'anonymize.call')+ ON CONFLICT DO NOTHING;++-- +goose StatementEnd++-- +goose Down+-- +goose StatementBegin++DELETE FROM privileges WHERE name = 'anonymize.call';++-- +goose StatementEnddiff --git a/backend/pkg/graph/generated.go b/backend/pkg/graph/generated.goindex dc661684..2b7e4bf0 100644--- a/backend/pkg/graph/generated.go+++ b/backend/pkg/graph/generated.go@@ -346,6 +346,7 @@ type ComplexityRoot struct {Mutation struct {AddFavoriteFlow func(childComplexity int, flowID int64) int+ AnonymizeText func(childComplexity int, text string) intCallAssistant func(childComplexity int, flowID int64, assistantID int64, input string, useAgents bool, resourceIds []int64) intCreateAPIToken func(childComplexity int, input model.CreateAPITokenInput) intCreateAssistant func(childComplexity int, flowID int64, modelProvider string, input string, useAgents bool, resourceIds []int64) int@@ -746,6 +747,7 @@ type MutationResolver interface {CreateKnowledgeDocument(ctx context.Context, input model.CreateKnowledgeDocumentInput) (*model.KnowledgeDocument, error)UpdateKnowledgeDocument(ctx context.Context, id string, input model.UpdateKnowledgeDocumentInput) (*model.KnowledgeDocument, error)DeleteKnowledgeDocument(ctx context.Context, id string) (model.ResultType, error)+ AnonymizeText(ctx context.Context, text string) (string, error)}type QueryResolver interface {Providers(ctx context.Context) ([]*model.Provider, error)@@ -2226,6 +2228,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity inreturn e.complexity.Mutation.AddFavoriteFlow(childComplexity, args["flowId"].(int64)), true+ case "Mutation.anonymizeText":+ if e.complexity.Mutation.AnonymizeText == nil {+ break+ }++ args, err := ec.field_Mutation_anonymizeText_args(context.TODO(), rawArgs)+ if err != nil {+ return 0, false+ }++ return e.complexity.Mutation.AnonymizeText(childComplexity, args["text"].(string)), true+case "Mutation.callAssistant":if e.complexity.Mutation.CallAssistant == nil {break@@ -4728,6 +4742,38 @@ func (ec *executionContext) field_Mutation_addFavoriteFlow_argsFlowID(return zeroVal, nil}+func (ec *executionContext) field_Mutation_anonymizeText_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {+ var err error+ args := map[string]interface{}{}+ arg0, err := ec.field_Mutation_anonymizeText_argsText(ctx, rawArgs)+ if err != nil {+ return nil, err+ }+ args["text"] = arg0+ return args, nil+}+func (ec *executionContext) field_Mutation_anonymizeText_argsText(+ ctx context.Context,+ rawArgs map[string]interface{},+) (string, error) {+ // We won't call the directive if the argument is null.+ // Set call_argument_directives_with_null to true to call directives+ // even if the argument is null.+ _, ok := rawArgs["text"]+ if !ok {+ var zeroVal string+ return zeroVal, nil+ }++ ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("text"))+ if tmp, ok := rawArgs["text"]; ok {+ return ec.unmarshalNString2string(ctx, tmp)+ }++ var zeroVal string+ return zeroVal, nil+}+func (ec *executionContext) field_Mutation_callAssistant_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {var err errorargs := map[string]interface{}{}@@ -19331,6 +19377,61 @@ func (ec *executionContext) fieldContext_Mutation_deleteKnowledgeDocument(ctx coreturn fc, nil}+func (ec *executionContext) _Mutation_anonymizeText(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {+ fc, err := ec.fieldContext_Mutation_anonymizeText(ctx, field)+ if err != nil {+ return graphql.Null+ }+ ctx = graphql.WithFieldContext(ctx, fc)+ defer func() {+ if r := recover(); r != nil {+ ec.Error(ctx, ec.Recover(ctx, r))+ ret = graphql.Null+ }+ }()+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {+ ctx = rctx // use context from middleware stack in children+ return ec.resolvers.Mutation().AnonymizeText(rctx, fc.Args["text"].(string))+ })+ if err != nil {+ ec.Error(ctx, err)+ return graphql.Null+ }+ if resTmp == nil {+ if !graphql.HasFieldError(ctx, fc) {+ ec.Errorf(ctx, "must not be null")+ }+ return graphql.Null+ }+ res := resTmp.(string)+ fc.Result = res+ return ec.marshalNString2string(ctx, field.Selections, res)+}++func (ec *executionContext) fieldContext_Mutation_anonymizeText(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {+ fc = &graphql.FieldContext{+ Object: "Mutation",+ Field: field,+ IsMethod: true,+ IsResolver: true,+ Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {+ return nil, errors.New("field of type String does not have child fields")+ },+ }+ defer func() {+ if r := recover(); r != nil {+ err = ec.Recover(ctx, r)+ ec.Error(ctx, err)+ }+ }()+ ctx = graphql.WithFieldContext(ctx, fc)+ if fc.Args, err = ec.field_Mutation_anonymizeText_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {+ ec.Error(ctx, err)+ return fc, err+ }+ return fc, nil+}+func (ec *executionContext) _PromptValidationResult_result(ctx context.Context, field graphql.CollectedField, obj *model.PromptValidationResult) (ret graphql.Marshaler) {fc, err := ec.fieldContext_PromptValidationResult_result(ctx, field)if err != nil {@@ -37641,6 +37742,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)if out.Values[i] == graphql.Null {out.Invalids++}+ case "anonymizeText":+ out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {+ return ec._Mutation_anonymizeText(ctx, field)+ })+ if out.Values[i] == graphql.Null {+ out.Invalids+++ }default:panic("unknown field " + strconv.Quote(field.Name))}diff --git a/backend/pkg/graph/resolver.go b/backend/pkg/graph/resolver.goindex e7fa6719..8307b348 100644--- a/backend/pkg/graph/resolver.go+++ b/backend/pkg/graph/resolver.go@@ -11,6 +11,7 @@ import ("pentagi/pkg/templates""github.com/sirupsen/logrus"+ "github.com/vxcontrol/cloud/anonymizer")// This file will not be regenerated automatically.@@ -27,4 +28,5 @@ type Resolver struct {Controller controller.FlowControllerSubscriptions subscriptions.SubscriptionsControllerKnowledge knowledge.KnowledgeStore+ Replacer anonymizer.Replacer}diff --git a/backend/pkg/graph/schema.graphqls b/backend/pkg/graph/schema.graphqlsindex a60935fb..b10d787c 100644--- a/backend/pkg/graph/schema.graphqls+++ b/backend/pkg/graph/schema.graphqls@@ -1027,6 +1027,7 @@ type Mutation {createKnowledgeDocument(input: CreateKnowledgeDocumentInput!): KnowledgeDocument!updateKnowledgeDocument(id: String!, input: UpdateKnowledgeDocumentInput!): KnowledgeDocument!deleteKnowledgeDocument(id: String!): ResultType!+ anonymizeText(text: String!): String!}type Subscription {diff --git a/backend/pkg/graph/schema.resolvers.go b/backend/pkg/graph/schema.resolvers.goindex aaeb4b38..b216ba74 100644--- a/backend/pkg/graph/schema.resolvers.go+++ b/backend/pkg/graph/schema.resolvers.go@@ -1181,6 +1181,24 @@ func (r *mutationResolver) DeleteKnowledgeDocument(ctx context.Context, id strinreturn model.ResultTypeSuccess, nil}+// AnonymizeText is the resolver for the anonymizeText field.+func (r *mutationResolver) AnonymizeText(ctx context.Context, text string) (string, error) {+ uid, _, err := validatePermission(ctx, "anonymize.call")+ if err != nil {+ return "", err+ }++ r.Logger.WithFields(logrus.Fields{+ "uid": uid,+ }).Debug("anonymize text")++ if r.Replacer == nil {+ return "", fmt.Errorf("anonymizer is not available")+ }++ return r.Replacer.ReplaceString(text), nil+}+// Providers is the resolver for the providers field.func (r *queryResolver) Providers(ctx context.Context) ([]*model.Provider, error) {uid, _, err := validatePermission(ctx, "providers.view")diff --git a/backend/pkg/server/docs/docs.go b/backend/pkg/server/docs/docs.goindex 771e1d43..ea9f801e 100644--- a/backend/pkg/server/docs/docs.go+++ b/backend/pkg/server/docs/docs.go@@ -140,6 +140,75 @@ const docTemplate = `{}}},+ "/anonymize/text": {+ "post": {+ "security": [+ {+ "BearerAuth": []+ }+ ],+ "description": "Replace sensitive data patterns (credentials, keys, PII, etc.) in the provided text with safe placeholders.",+ "consumes": [+ "application/json"+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "Anonymize"+ ],+ "summary": "Anonymize text",+ "parameters": [+ {+ "description": "Text to anonymize",+ "name": "json",+ "in": "body",+ "required": true,+ "schema": {+ "$ref": "#/definitions/services.anonymizeTextRequest"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "anonymized text returned successfully",+ "schema": {+ "allOf": [+ {+ "$ref": "#/definitions/SuccessResponse"+ },+ {+ "type": "object",+ "properties": {+ "data": {+ "$ref": "#/definitions/services.anonymizeTextResponse"+ }+ }+ }+ ]+ }+ },+ "400": {+ "description": "invalid request body",+ "schema": {+ "$ref": "#/definitions/ErrorResponse"+ }+ },+ "403": {+ "description": "anonymize.call permission required",+ "schema": {+ "$ref": "#/definitions/ErrorResponse"+ }+ },+ "503": {+ "description": "anonymizer is not configured",+ "schema": {+ "$ref": "#/definitions/ErrorResponse"+ }+ }+ }+ }+ },"/assistantlogs/": {"get": {"security": [@@ -9683,6 +9752,25 @@ const docTemplate = `{}}},+ "services.anonymizeTextRequest": {+ "type": "object",+ "required": [+ "text"+ ],+ "properties": {+ "text": {+ "type": "string"+ }+ }+ },+ "services.anonymizeTextResponse": {+ "type": "object",+ "properties": {+ "text": {+ "type": "string"+ }+ }+ },"services.assistantlogs": {"type": "object","properties": {diff --git a/backend/pkg/server/docs/swagger.json b/backend/pkg/server/docs/swagger.jsonindex 090a04c7..13c616ff 100644--- a/backend/pkg/server/docs/swagger.json+++ b/backend/pkg/server/docs/swagger.json@@ -132,6 +132,75 @@}}},+ "/anonymize/text": {+ "post": {+ "security": [+ {+ "BearerAuth": []+ }+ ],+ "description": "Replace sensitive data patterns (credentials, keys, PII, etc.) in the provided text with safe placeholders.",+ "consumes": [+ "application/json"+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "Anonymize"+ ],+ "summary": "Anonymize text",+ "parameters": [+ {+ "description": "Text to anonymize",+ "name": "json",+ "in": "body",+ "required": true,+ "schema": {+ "$ref": "#/definitions/services.anonymizeTextRequest"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "anonymized text returned successfully",+ "schema": {+ "allOf": [+ {+ "$ref": "#/definitions/SuccessResponse"+ },+ {+ "type": "object",+ "properties": {+ "data": {+ "$ref": "#/definitions/services.anonymizeTextResponse"+ }+ }+ }+ ]+ }+ },+ "400": {+ "description": "invalid request body",+ "schema": {+ "$ref": "#/definitions/ErrorResponse"+ }+ },+ "403": {+ "description": "anonymize.call permission required",+ "schema": {+ "$ref": "#/definitions/ErrorResponse"+ }+ },+ "503": {+ "description": "anonymizer is not configured",+ "schema": {+ "$ref": "#/definitions/ErrorResponse"+ }+ }+ }+ }+ },"/assistantlogs/": {"get": {"security": [@@ -9675,6 +9744,25 @@}}},+ "services.anonymizeTextRequest": {+ "type": "object",+ "required": [+ "text"+ ],+ "properties": {+ "text": {+ "type": "string"+ }+ }+ },+ "services.anonymizeTextResponse": {+ "type": "object",+ "properties": {+ "text": {+ "type": "string"+ }+ }+ },"services.assistantlogs": {"type": "object","properties": {diff --git a/backend/pkg/server/docs/swagger.yaml b/backend/pkg/server/docs/swagger.yamlindex 6afd04d5..e1725cd6 100644--- a/backend/pkg/server/docs/swagger.yaml+++ b/backend/pkg/server/docs/swagger.yaml@@ -1748,6 +1748,18 @@ definitions:total:type: integertype: object+ services.anonymizeTextRequest:+ properties:+ text:+ type: string+ required:+ - text+ type: object+ services.anonymizeTextResponse:+ properties:+ text:+ type: string+ type: objectservices.assistantlogs:properties:assistantlogs:@@ -2053,6 +2065,48 @@ paths:summary: Retrieve agentlogs listtags:- Agentlogs+ /anonymize/text:+ post:+ consumes:+ - application/json+ description: Replace sensitive data patterns (credentials, keys, PII, etc.)+ in the provided text with safe placeholders.+ parameters:+ - description: Text to anonymize+ in: body+ name: json+ required: true+ schema:+ $ref: '#/definitions/services.anonymizeTextRequest'+ produces:+ - application/json+ responses:+ "200":+ description: anonymized text returned successfully+ schema:+ allOf:+ - $ref: '#/definitions/SuccessResponse'+ - properties:+ data:+ $ref: '#/definitions/services.anonymizeTextResponse'+ type: object+ "400":+ description: invalid request body+ schema:+ $ref: '#/definitions/ErrorResponse'+ "403":+ description: anonymize.call permission required+ schema:+ $ref: '#/definitions/ErrorResponse'+ "503":+ description: anonymizer is not configured+ schema:+ $ref: '#/definitions/ErrorResponse'+ security:+ - BearerAuth: []+ summary: Anonymize text+ tags:+ - Anonymize/assistantlogs/:get:parameters:diff --git a/backend/pkg/server/response/errors.go b/backend/pkg/server/response/errors.goindex c8572982..f2964042 100644--- a/backend/pkg/server/response/errors.go+++ b/backend/pkg/server/response/errors.go@@ -138,18 +138,23 @@ var ErrAssistantsInvalidData = NewHttpError(500, "Assistants.InvalidData", "inva// resourcesvar ErrResourcesInvalidRequest = NewHttpError(400, "Resources.InvalidRequest", "invalid resource request data")-var ErrResourcesNotFound = NewHttpError(404, "Resources.NotFound", "resource not found")-var ErrResourcesAlreadyExists = NewHttpError(409, "Resources.AlreadyExists", "resource already exists")-var ErrResourcesInvalidData = NewHttpError(400, "Resources.InvalidData", "invalid resource data")-var ErrResourcesConflict = NewHttpError(409, "Resources.Conflict", "resource conflict: use force=true to merge")+var ErrResourcesNotFound = NewHttpError(404, "Resources.NotFound", "resource not found")+var ErrResourcesAlreadyExists = NewHttpError(409, "Resources.AlreadyExists", "resource already exists")+var ErrResourcesInvalidData = NewHttpError(400, "Resources.InvalidData", "invalid resource data")+var ErrResourcesConflict = NewHttpError(409, "Resources.Conflict", "resource conflict: use force=true to merge")// knowledgevar ErrKnowledgeInvalidRequest = NewHttpError(400, "Knowledge.InvalidRequest", "invalid knowledge request data")-var ErrKnowledgeNotFound = NewHttpError(404, "Knowledge.NotFound", "knowledge document not found")-var ErrKnowledgeUnauthorized = NewHttpError(403, "Knowledge.Unauthorized", "not authorized to manage this knowledge document")-var ErrKnowledgeStoreUnavail = NewHttpError(503, "Knowledge.StoreUnavailable", "knowledge store (embedding provider) is not configured")-var ErrKnowledgeInvalidData = NewHttpError(500, "Knowledge.InvalidData", "invalid knowledge document data")+var ErrKnowledgeNotFound = NewHttpError(404, "Knowledge.NotFound", "knowledge document not found")+var ErrKnowledgeUnauthorized = NewHttpError(403, "Knowledge.Unauthorized", "not authorized to manage this knowledge document")+var ErrKnowledgeStoreUnavail = NewHttpError(503, "Knowledge.StoreUnavailable", "knowledge store (embedding provider) is not configured")+var ErrKnowledgeInvalidData = NewHttpError(500, "Knowledge.InvalidData", "invalid knowledge document data")++// anonymize++var ErrAnonymizeInvalidRequest = NewHttpError(400, "Anonymize.InvalidRequest", "invalid anonymize request data")+var ErrAnonymizeUnavailable = NewHttpError(503, "Anonymize.Unavailable", "anonymizer is not configured")// tokensdiff --git a/backend/pkg/server/router.go b/backend/pkg/server/router.goindex dac98832..8e475386 100644--- a/backend/pkg/server/router.go+++ b/backend/pkg/server/router.go@@ -37,6 +37,8 @@ import ("github.com/sirupsen/logrus"ginSwagger "github.com/swaggo/gin-swagger""github.com/swaggo/gin-swagger/swaggerFiles"+ "github.com/vxcontrol/cloud/anonymizer"+ "github.com/vxcontrol/cloud/anonymizer/patterns""github.com/vxcontrol/langchaingo/vectorstores/pgvector")@@ -144,6 +146,22 @@ func NewRouter(var knowledgeStore knowledge.KnowledgeStoreknowledgeStore = knowledge.NewKnowledgeStore(db, pgStore, embedder, subscriptions.NewKnowledgePublisher)+ // ---- Anonymizer replacer ------------------------------------------------+ // Shared singleton used by the GraphQL anonymizeText mutation.+ // Falls back to a no-op nil replacer on failure so the rest of the server still starts correctly.+ var textReplacer anonymizer.Replacer+ if allPatterns, err := patterns.LoadPatterns(patterns.PatternListTypeAll); err != nil {+ logrus.WithError(err).Warn("failed to load anonymizer patterns; anonymizeText mutation will be unavailable")+ } else {+ allPatterns.Patterns = append(allPatterns.Patterns, cfg.GetSecretPatterns()...)++ if r, err := anonymizer.NewReplacer(allPatterns.Regexes(), allPatterns.Names()); err != nil {+ logrus.WithError(err).Warn("failed to create anonymizer replacer; anonymizeText mutation will be unavailable")+ } else {+ textReplacer = r+ }+ }+// servicesauthService := services.NewAuthService(services.AuthServiceConfig{@@ -176,8 +194,9 @@ func NewRouter(analyticsService := services.NewAnalyticsService(orm)tokenService := services.NewTokenService(orm, cfg.CookieSigningSalt, tokenCache, subscriptions)knowledgeService := services.NewKnowledgeService(orm, knowledgeStore)+ anonymizerService := services.NewAnonymizerService(textReplacer)graphqlService := services.NewGraphqlService(- db, cfg, baseURL, cfg.CorsOrigins, tokenCache, providers, controller, subscriptions, knowledgeStore,+ db, cfg, baseURL, cfg.CorsOrigins, tokenCache, providers, controller, subscriptions, knowledgeStore, textReplacer,)router := gin.Default()@@ -271,6 +290,7 @@ func NewRouter(setVecstorelogsGroup(privateGroup, vecstorelogService)setScreenshotsGroup(privateGroup, screenshotService)setPromptsGroup(privateGroup, promptService)+ setAnonymizeGroup(privateGroup, anonymizerService)setAnalyticsGroup(privateGroup, analyticsService)}@@ -571,6 +591,13 @@ func setScreenshotsGroup(parent *gin.RouterGroup, svc *services.ScreenshotServic}}+func setAnonymizeGroup(parent *gin.RouterGroup, svc *services.AnonymizerService) {+ group := parent.Group("/anonymize")+ {+ group.POST("/text", svc.AnonymizeText)+ }+}+func setPromptsGroup(parent *gin.RouterGroup, svc *services.PromptService) {promptsViewGroup := parent.Group("/prompts"){diff --git a/backend/pkg/server/services/anonymizer.go b/backend/pkg/server/services/anonymizer.gonew file mode 100644index 00000000..36183973--- /dev/null+++ b/backend/pkg/server/services/anonymizer.go@@ -0,0 +1,67 @@+package services++import (+ "net/http"+ "slices"++ "pentagi/pkg/server/logger"+ "pentagi/pkg/server/response"++ "github.com/gin-gonic/gin"+ "github.com/vxcontrol/cloud/anonymizer"+)++type anonymizeTextRequest struct {+ Text string `json:"text" binding:"required"`+}++type anonymizeTextResponse struct {+ Text string `json:"text"`+}++// AnonymizerService handles text anonymization via the REST API.+type AnonymizerService struct {+ replacer anonymizer.Replacer+}++func NewAnonymizerService(replacer anonymizer.Replacer) *AnonymizerService {+ return &AnonymizerService{replacer: replacer}+}++// AnonymizeText replaces sensitive data patterns in the provided text.+// @Summary Anonymize text+// @Description Replace sensitive data patterns (credentials, keys, PII, etc.) in the provided text with safe placeholders.+// @Tags Anonymize+// @Accept json+// @Produce json+// @Security BearerAuth+// @Param json body anonymizeTextRequest true "Text to anonymize"+// @Success 200 {object} response.successResp{data=anonymizeTextResponse} "anonymized text returned successfully"+// @Failure 400 {object} response.errorResp "invalid request body"+// @Failure 403 {object} response.errorResp "anonymize.call permission required"+// @Failure 503 {object} response.errorResp "anonymizer is not configured"+// @Router /anonymize/text [post]+func (s *AnonymizerService) AnonymizeText(c *gin.Context) {+ privs := c.GetStringSlice("prm")+ if !slices.Contains(privs, "anonymize.call") {+ logger.FromContext(c).Errorf("error filtering user role permissions: permission not found")+ response.Error(c, response.ErrNotPermitted, nil)+ return+ }++ if s.replacer == nil {+ response.Error(c, response.ErrAnonymizeUnavailable, nil)+ return+ }++ var req anonymizeTextRequest+ if err := c.ShouldBindJSON(&req); err != nil {+ logger.FromContext(c).WithError(err).Error("error binding anonymize request")+ response.Error(c, response.ErrAnonymizeInvalidRequest, err)+ return+ }++ response.Success(c, http.StatusOK, anonymizeTextResponse{+ Text: s.replacer.ReplaceString(req.Text),+ })+}diff --git a/backend/pkg/server/services/graphql.go b/backend/pkg/server/services/graphql.goindex 99029b72..c9ff618f 100644--- a/backend/pkg/server/services/graphql.go+++ b/backend/pkg/server/services/graphql.go@@ -29,6 +29,7 @@ import ("github.com/gorilla/websocket""github.com/sirupsen/logrus""github.com/vektah/gqlparser/v2/ast"+ "github.com/vxcontrol/cloud/anonymizer")var (@@ -58,6 +59,7 @@ func NewGraphqlService(controller controller.FlowController,subscriptions subscriptions.SubscriptionsController,knowledgeStore knowledge.KnowledgeStore,+ replacer anonymizer.Replacer,) *GraphqlService {srv := handler.New(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{DB: db,@@ -69,6 +71,7 @@ func NewGraphqlService(Controller: controller,Subscriptions: subscriptions,Knowledge: knowledgeStore,+ Replacer: replacer,}}))component := "pentagi-gql"diff --git a/frontend/graphql-schema.graphql b/frontend/graphql-schema.graphqlindex 5f129441..b2a034ff 100644--- a/frontend/graphql-schema.graphql+++ b/frontend/graphql-schema.graphql@@ -1009,6 +1009,10 @@ mutation deleteFavoriteFlow($flowId: ID!) {deleteFavoriteFlow(flowId: $flowId)}+mutation anonymizeText($text: String!) {+ anonymizeText(text: $text)+}+# ==================== Flow Templates ====================query flowTemplates {diff --git a/frontend/src/graphql/types.ts b/frontend/src/graphql/types.tsindex f348a634..5047a0b7 100644--- a/frontend/src/graphql/types.ts+++ b/frontend/src/graphql/types.ts@@ -452,6 +452,7 @@ export type ModelUsageStats = {export type Mutation = {addFavoriteFlow: ResultType;+ anonymizeText: Scalars['String']['output'];callAssistant: ResultType;createAPIToken: ApiTokenWithSecret;createAssistant: FlowAssistant;@@ -487,6 +488,10 @@ export type MutationAddFavoriteFlowArgs = {flowId: Scalars['ID']['input'];};+export type MutationAnonymizeTextArgs = {+ text: Scalars['String']['input'];+};+export type MutationCallAssistantArgs = {assistantId: Scalars['ID']['input'];flowId: Scalars['ID']['input'];@@ -1977,6 +1982,12 @@ export type DeleteFavoriteFlowMutationVariables = Exact<{export type DeleteFavoriteFlowMutation = { deleteFavoriteFlow: ResultType };+export type AnonymizeTextMutationVariables = Exact<{+ text: Scalars['String']['input'];+}>;++export type AnonymizeTextMutation = { anonymizeText: string };+export type FlowTemplatesQueryVariables = Exact<{ [key: string]: never }>;export type FlowTemplatesQuery = { flowTemplates: Array<FlowTemplateFragmentFragment> };@@ -5560,6 +5571,42 @@ export type DeleteFavoriteFlowMutationOptions = Apollo.BaseMutationOptions<DeleteFavoriteFlowMutation,DeleteFavoriteFlowMutationVariables>;+export const AnonymizeTextDocument = gql`+ mutation anonymizeText($text: String!) {+ anonymizeText(text: $text)+ }+`;+export type AnonymizeTextMutationFn = Apollo.MutationFunction<AnonymizeTextMutation, AnonymizeTextMutationVariables>;++/**+ * __useAnonymizeTextMutation__+ *+ * To run a mutation, you first call `useAnonymizeTextMutation` within a React component and pass it any options that fit your needs.+ * When your component renders, `useAnonymizeTextMutation` returns a tuple that includes:+ * - A mutate function that you can call at any time to execute the mutation+ * - An object with fields that represent the current status of the mutation's execution+ *+ * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;+ *+ * @example+ * const [anonymizeTextMutation, { data, loading, error }] = useAnonymizeTextMutation({+ * variables: {+ * text: // value for 'text'+ * },+ * });+ */+export function useAnonymizeTextMutation(+ baseOptions?: Apollo.MutationHookOptions<AnonymizeTextMutation, AnonymizeTextMutationVariables>,+) {+ const options = { ...defaultOptions, ...baseOptions };+ return Apollo.useMutation<AnonymizeTextMutation, AnonymizeTextMutationVariables>(AnonymizeTextDocument, options);+}+export type AnonymizeTextMutationHookResult = ReturnType<typeof useAnonymizeTextMutation>;+export type AnonymizeTextMutationResult = Apollo.MutationResult<AnonymizeTextMutation>;+export type AnonymizeTextMutationOptions = Apollo.BaseMutationOptions<+ AnonymizeTextMutation,+ AnonymizeTextMutationVariables+>;export const FlowTemplatesDocument = gql`query flowTemplates {flowTemplates {