MCPcopy Create free account
hub / github.com/compozy/agh / networkChannelUpdate

Method networkChannelUpdate

internal/daemon/native_create_tools.go:103–149  ·  view source on GitHub ↗
(
	ctx context.Context,
	scope toolspkg.Scope,
	req toolspkg.CallRequest,
)

Source from the content-addressed store, hash-verified

101}
102
103func (n *daemonNativeTools) networkChannelUpdate(
104 ctx context.Context,
105 scope toolspkg.Scope,
106 req toolspkg.CallRequest,
107) (toolspkg.ToolResult, error) {
108 var input networkChannelUpdateInput
109 if err := decodeNativeInput(req, &input); err != nil {
110 return toolspkg.ToolResult{}, err
111 }
112 channel, err := nativeNetworkChannel(req.ToolID, input.Channel)
113 if err != nil {
114 return toolspkg.ToolResult{}, err
115 }
116 if input.Purpose == nil && input.FanoutPolicy == nil && input.CoordinatorPeerID == nil {
117 return toolspkg.ToolResult{}, nativeRequiredInputError(req.ToolID, nativeNetworkChannelUpdateRequiredFields)
118 }
119 workspaceID, err := n.nativeNetworkWorkspaceID(ctx, req.ToolID, input.WorkspaceID, scope)
120 if err != nil {
121 return toolspkg.ToolResult{}, err
122 }
123 ref := store.NetworkChannelRef{WorkspaceID: workspaceID, Channel: channel}
124 patch := store.NetworkChannelPatch{}
125 if input.Purpose != nil {
126 purpose := strings.TrimSpace(*input.Purpose)
127 patch.Purpose = &purpose
128 }
129 if input.FanoutPolicy != nil {
130 policy := strings.TrimSpace(*input.FanoutPolicy)
131 fanoutPolicy := store.NormalizeNetworkFanoutPolicy(policy)
132 if err := store.ValidateNetworkFanoutPolicy(fanoutPolicy); err != nil {
133 return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err)
134 }
135 patch.FanoutPolicy = &fanoutPolicy
136 }
137 if input.CoordinatorPeerID != nil {
138 coordinatorPeerID := strings.TrimSpace(*input.CoordinatorPeerID)
139 patch.CoordinatorPeerID = &coordinatorPeerID
140 }
141 if err := n.deps.NetworkStore.PatchNetworkChannel(ctx, ref, patch); err != nil {
142 return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err)
143 }
144 entry, err := n.deps.NetworkStore.GetNetworkChannel(ctx, ref)
145 if err != nil {
146 return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err)
147 }
148 return structuredNetworkResult(nativeNetworkChannelPayload(entry), "channel "+channel)
149}
150
151func (n *daemonNativeTools) agentCreate(
152 ctx context.Context,

Callers

nothing calls this directly

Calls 11

decodeNativeInputFunction · 0.85
nativeNetworkChannelFunction · 0.85
nativeRequiredInputErrorFunction · 0.85
nativeNetworkInputErrorFunction · 0.85
structuredNetworkResultFunction · 0.85
PatchNetworkChannelMethod · 0.65
GetNetworkChannelMethod · 0.65

Tested by

no test coverage detected