MCPcopy Index your code
hub / github.com/coder/coder / parseDynamicToolNames

Function parseDynamicToolNames

coderd/x/chatd/chatd.go:9590–9603  ·  view source on GitHub ↗

parseDynamicToolNames unmarshals the dynamic tools JSON column and returns a map of tool names. This centralizes the repeated pattern of deserializing DynamicTools into a name set.

(raw pqtype.NullRawMessage)

Source from the content-addressed store, hash-verified

9588// and returns a map of tool names. This centralizes the repeated
9589// pattern of deserializing DynamicTools into a name set.
9590func parseDynamicToolNames(raw pqtype.NullRawMessage) (map[string]bool, error) {
9591 if !raw.Valid || len(raw.RawMessage) == 0 {
9592 return make(map[string]bool), nil
9593 }
9594 var tools []codersdk.DynamicTool
9595 if err := json.Unmarshal(raw.RawMessage, &tools); err != nil {
9596 return nil, xerrors.Errorf("unmarshal dynamic tools: %w", err)
9597 }
9598 names := make(map[string]bool, len(tools))
9599 for _, t := range tools {
9600 names[t.Name] = true
9601 }
9602 return names, nil
9603}
9604
9605// maybeFinalizeTurnStatusLabelAndPush updates the cached turn status label
9606// for parent chats and optionally sends a web push notification.

Callers 3

SubmitToolResultsMethod · 0.85
appendDynamicToolsFunction · 0.85

Calls 2

UnmarshalMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected