( ctx context.Context, scope toolspkg.Scope, req toolspkg.CallRequest, )
| 101 | } |
| 102 | |
| 103 | func (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 | |
| 151 | func (n *daemonNativeTools) agentCreate( |
| 152 | ctx context.Context, |
nothing calls this directly
no test coverage detected