Skip to content

Commit b2966e2

Browse files
committed
chore(codersdk/toolsdk): add typed argument to toolsdk.Tool
1 parent 08ad910 commit b2966e2

File tree

4 files changed

+274
-231
lines changed

4 files changed

+274
-231
lines changed

cli/exp_mcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ func getAgentToken(fs afero.Fs) (string, error) {
695695

696696
// mcpFromSDK adapts a toolsdk.Tool to go-mcp's server.ServerTool.
697697
// It assumes that the tool responds with a valid JSON object.
698-
func mcpFromSDK(sdkTool toolsdk.Tool[any]) server.ServerTool {
698+
func mcpFromSDK(sdkTool toolsdk.Tool[any, any]) server.ServerTool {
699699
// NOTE: some clients will silently refuse to use tools if there is an issue
700700
// with the tool's schema or configuration.
701701
if sdkTool.Schema.Properties == nil {

coderd/workspaceagents.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,30 @@ func (api *API) patchWorkspaceAgentAppStatus(rw http.ResponseWriter, r *http.Req
345345
return
346346
}
347347

348+
if len(req.Message) > 160 {
349+
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
350+
Message: "Message is too long.",
351+
Detail: "Message must be less than 160 characters.",
352+
Validations: []codersdk.ValidationError{
353+
{Field: "message", Detail: "Message must be less than 160 characters."},
354+
},
355+
})
356+
return
357+
}
358+
359+
switch req.State {
360+
case codersdk.WorkspaceAppStatusStateComplete, codersdk.WorkspaceAppStatusStateFailure, codersdk.WorkspaceAppStatusStateWorking: // valid states
361+
default:
362+
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
363+
Message: "Invalid state provided.",
364+
Detail: fmt.Sprintf("invalid state: %q", req.State),
365+
Validations: []codersdk.ValidationError{
366+
{Field: "state", Detail: "State must be one of: complete, failure, working."},
367+
},
368+
})
369+
return
370+
}
371+
348372
workspace, err := api.Database.GetWorkspaceByAgentID(ctx, workspaceAgent.ID)
349373
if err != nil {
350374
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{

0 commit comments

Comments
 (0)