From 0dcb87e1bc73cb3a6d08b4c427913c3829998408 Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Tue, 11 Mar 2025 16:46:38 -0400 Subject: [PATCH 1/2] chore: expose recreate credentials route to admins Signed-off-by: Grant Linville --- go.mod | 6 +++--- go.sum | 12 ++++++------ pkg/api/handlers/credentials.go | 9 +++++++++ pkg/api/router/router.go | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index ffb0075a64..f5173aaf0c 100644 --- a/go.mod +++ b/go.mod @@ -17,10 +17,10 @@ require ( github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.3 - github.com/gptscript-ai/chat-completion-client v0.0.0-20250128181713-57857b74f9f1 + github.com/gptscript-ai/chat-completion-client v0.0.0-20250224164718-139cb4507b1d github.com/gptscript-ai/cmd v0.0.0-20250122115124-a3d65e9d2432 - github.com/gptscript-ai/go-gptscript v0.9.6-0.20250222170845-eee4337500a6 - github.com/gptscript-ai/gptscript v0.9.6-0.20250222165900-86e85f032cc9 + github.com/gptscript-ai/go-gptscript v0.9.6-0.20250314150104-8d1f06fa87a4 + github.com/gptscript-ai/gptscript v0.9.6-0.20250314150052-cee1a753e167 github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de github.com/mhale/smtpd v0.8.3 github.com/obot-platform/kinm v0.0.0-20250307141751-3a6f13867f67 diff --git a/go.sum b/go.sum index cbe6bf7c1f..adff85e451 100644 --- a/go.sum +++ b/go.sum @@ -303,14 +303,14 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86 h1:m9yLtIEd0z1ia8qFjq3u0Ozb6QKwidyL856JLJp6nbA= github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86/go.mod h1:lK3K5EZx4dyT24UG3yCt0wmspkYqrj4D/8kxdN3relk= -github.com/gptscript-ai/chat-completion-client v0.0.0-20250128181713-57857b74f9f1 h1:D8VmhL68Fm6YI7fue4wkzd1TqODn//LtcJtPvWk8BQ8= -github.com/gptscript-ai/chat-completion-client v0.0.0-20250128181713-57857b74f9f1/go.mod h1:7P/o6/IWa1KqsntVf68hSnLKuu3+xuqm6lYhch1w4jo= +github.com/gptscript-ai/chat-completion-client v0.0.0-20250224164718-139cb4507b1d h1:p5uqZufDIMQzAALblZFkr8fwbnZbFXbBCR1ZMAFylXk= +github.com/gptscript-ai/chat-completion-client v0.0.0-20250224164718-139cb4507b1d/go.mod h1:7P/o6/IWa1KqsntVf68hSnLKuu3+xuqm6lYhch1w4jo= github.com/gptscript-ai/cmd v0.0.0-20250122115124-a3d65e9d2432 h1:cJh/Hl1HFd1qLpdkaZvsFTC2mXlIuiK7FgvSfaSOWmw= github.com/gptscript-ai/cmd v0.0.0-20250122115124-a3d65e9d2432/go.mod h1:DJAo1xTht1LDkNYFNydVjTHd576TC7MlpsVRl3oloVw= -github.com/gptscript-ai/go-gptscript v0.9.6-0.20250222170845-eee4337500a6 h1:vsZ09cWfNWUXT6AOVQc1GpfEdIxcLusUs6Hgo9IgAKs= -github.com/gptscript-ai/go-gptscript v0.9.6-0.20250222170845-eee4337500a6/go.mod h1:QvGPZoRuAiA8P5EzPI05kTrs+LZ0ipHywUGsKruSknw= -github.com/gptscript-ai/gptscript v0.9.6-0.20250222165900-86e85f032cc9 h1:TIHbI5k7kwv/ijm8qzjoBRh6DRq1FtjP+OLYu9dfDA8= -github.com/gptscript-ai/gptscript v0.9.6-0.20250222165900-86e85f032cc9/go.mod h1:uvb92bYHRX9wFHSS1jkg5Y7GBQgTb8iHP+l/wPsWCx8= +github.com/gptscript-ai/go-gptscript v0.9.6-0.20250314150104-8d1f06fa87a4 h1:V30gwE9c6yEYQmWoKCvrfpGmsTTlEicHr5nGJZV4Uyk= +github.com/gptscript-ai/go-gptscript v0.9.6-0.20250314150104-8d1f06fa87a4/go.mod h1:QvGPZoRuAiA8P5EzPI05kTrs+LZ0ipHywUGsKruSknw= +github.com/gptscript-ai/gptscript v0.9.6-0.20250314150052-cee1a753e167 h1:EegFwD2jIRkTPDLP56QWJxOOZVGkKundyoES6JNWe2c= +github.com/gptscript-ai/gptscript v0.9.6-0.20250314150052-cee1a753e167/go.mod h1:wQ9GU40Po6fSBEciAQI2kxeo32qK4DybbpD6bIOBPtM= github.com/gptscript-ai/tui v0.0.0-20250204145344-33cd15de4cee h1:70PHW6Xw70yNNZ5aX936XqcMLwNmfMZpCV3FCOGKpxE= github.com/gptscript-ai/tui v0.0.0-20250204145344-33cd15de4cee/go.mod h1:iwHxuueg2paOak7zIg0ESBWx7A0wIHGopAratbgaPNY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= diff --git a/pkg/api/handlers/credentials.go b/pkg/api/handlers/credentials.go index ce8e1e52cf..59f7f20d2d 100644 --- a/pkg/api/handlers/credentials.go +++ b/pkg/api/handlers/credentials.go @@ -51,3 +51,12 @@ func convertCredential(cred gptscript.Credential) types.Credential { ExpiresAt: types.NewTimeFromPointer(cred.ExpiresAt), } } + +func RecreateAllCredentials(req api.Context) error { + err := req.GPTClient.RecreateAllCredentials(req.Context()) + if err != nil { + return err + } + + return nil +} diff --git a/pkg/api/router/router.go b/pkg/api/router/router.go index f789d05be2..d0c9921448 100644 --- a/pkg/api/router/router.go +++ b/pkg/api/router/router.go @@ -300,6 +300,7 @@ func Router(services *services.Services) (http.Handler, error) { mux.HandleFunc("DELETE /api/agents/{context}/credentials/{id}", handlers.DeleteCredential) mux.HandleFunc("GET /api/credentials", handlers.ListCredentials) mux.HandleFunc("DELETE /api/credentials/{id}", handlers.DeleteCredential) + mux.HandleFunc("POST /api/credentials/recreate-all", handlers.RecreateAllCredentials) mux.HandleFunc("GET /api/threads/{context}/credentials", handlers.ListCredentials) mux.HandleFunc("DELETE /api/threads/{context}/credentials/{id}", handlers.DeleteCredential) From d27e83f93078bedf4f18db7aabd02a4d357c96a8 Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Fri, 14 Mar 2025 11:25:19 -0400 Subject: [PATCH 2/2] PR feedback Signed-off-by: Grant Linville --- pkg/api/handlers/credentials.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/api/handlers/credentials.go b/pkg/api/handlers/credentials.go index 59f7f20d2d..59c307f4e2 100644 --- a/pkg/api/handlers/credentials.go +++ b/pkg/api/handlers/credentials.go @@ -53,10 +53,5 @@ func convertCredential(cred gptscript.Credential) types.Credential { } func RecreateAllCredentials(req api.Context) error { - err := req.GPTClient.RecreateAllCredentials(req.Context()) - if err != nil { - return err - } - - return nil + return req.GPTClient.RecreateAllCredentials(req.Context()) }